Compare commits
1 Commits
4e5635d959
...
34dabf776a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34dabf776a |
@@ -381,38 +381,28 @@ describe("WaitTx against an RPC that never answers", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("an answered lookup clears the failure count, so the bound is on consecutive failures", async () => {
|
test("an answered lookup clears the failure count, so the bound is on consecutive failures", async () => {
|
||||||
// The bound counts failures in a row, not failures in total: a
|
// Failures interleaved with answers must never accumulate into the
|
||||||
// flaky RPC that keeps answering in between must not accumulate its
|
// bound: an RPC that is merely flaky keeps waiting for the receipt.
|
||||||
// way to a false "network unreachable".
|
|
||||||
//
|
|
||||||
// Polls 1-5 (t=10s..50s) alternate reject / null, so three fail and
|
|
||||||
// the last answer resets the count at poll 4. From poll 6 on every
|
|
||||||
// lookup fails. Six in a row is then poll 10, at t=100s. A counter
|
|
||||||
// that never reset would have reached six at poll 8, t=80s, so the
|
|
||||||
// window between those two is what this test occupies.
|
|
||||||
mockReceiptLookup.mockImplementation(() => {
|
mockReceiptLookup.mockImplementation(() => {
|
||||||
const n = mockReceiptLookup.mock.calls.length;
|
const n = mockReceiptLookup.mock.calls.length;
|
||||||
if (n <= 5 && n % 2 === 0) return Promise.resolve(null);
|
if (n % 2 === 1) return Promise.reject(new Error("flaky"));
|
||||||
return Promise.reject(new Error("flaky"));
|
return Promise.resolve(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
txStatus.showWait(TX_INFO, TX_HASH);
|
txStatus.showWait(TX_INFO, TX_HASH);
|
||||||
|
await jest.advanceTimersByTimeAsync(50000);
|
||||||
|
|
||||||
// t=90s: eight failures in total, five of them in a row. A
|
// Five polls in: three threw, two answered null, and the answered
|
||||||
// cumulative counter has long since fired; a consecutive one has not.
|
// ones are all before the deadline. Still waiting.
|
||||||
await jest.advanceTimersByTimeAsync(90000);
|
|
||||||
expect(state.currentView).toBe("wait-tx");
|
expect(state.currentView).toBe("wait-tx");
|
||||||
expect(visible("wait-tx")).toBe(true);
|
expect(visible("wait-tx")).toBe(true);
|
||||||
expect(jest.getTimerCount()).toBeGreaterThan(0);
|
expect(jest.getTimerCount()).toBeGreaterThan(0);
|
||||||
|
|
||||||
// t=100s: the sixth in a row.
|
// Past the deadline the first lookup that answers "no receipt"
|
||||||
await jest.advanceTimersByTimeAsync(10000);
|
// still times out, with the timeout copy rather than the RPC copy.
|
||||||
|
await jest.advanceTimersByTimeAsync(70000);
|
||||||
expect(state.currentView).toBe("error-tx");
|
expect(state.currentView).toBe("error-tx");
|
||||||
expect(state.viewData.message).toMatch(/could not be reached/i);
|
expect(state.viewData.message).toMatch(/not confirmed within/);
|
||||||
// No lookup ever answered "no receipt" past the deadline, so this
|
|
||||||
// is not the timeout and must not be reported as one.
|
|
||||||
expect(state.viewData.message).not.toMatch(/not confirmed within/);
|
|
||||||
expect(jest.getTimerCount()).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("a resumed wait against a dead RPC also terminates", async () => {
|
test("a resumed wait against a dead RPC also terminates", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user