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 () => {
|
||||
// The bound counts failures in a row, not failures in total: a
|
||||
// flaky RPC that keeps answering in between must not accumulate its
|
||||
// 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.
|
||||
// Failures interleaved with answers must never accumulate into the
|
||||
// bound: an RPC that is merely flaky keeps waiting for the receipt.
|
||||
mockReceiptLookup.mockImplementation(() => {
|
||||
const n = mockReceiptLookup.mock.calls.length;
|
||||
if (n <= 5 && n % 2 === 0) return Promise.resolve(null);
|
||||
return Promise.reject(new Error("flaky"));
|
||||
if (n % 2 === 1) return Promise.reject(new Error("flaky"));
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
|
||||
txStatus.showWait(TX_INFO, TX_HASH);
|
||||
await jest.advanceTimersByTimeAsync(50000);
|
||||
|
||||
// t=90s: eight failures in total, five of them in a row. A
|
||||
// cumulative counter has long since fired; a consecutive one has not.
|
||||
await jest.advanceTimersByTimeAsync(90000);
|
||||
// Five polls in: three threw, two answered null, and the answered
|
||||
// ones are all before the deadline. Still waiting.
|
||||
expect(state.currentView).toBe("wait-tx");
|
||||
expect(visible("wait-tx")).toBe(true);
|
||||
expect(jest.getTimerCount()).toBeGreaterThan(0);
|
||||
|
||||
// t=100s: the sixth in a row.
|
||||
await jest.advanceTimersByTimeAsync(10000);
|
||||
// Past the deadline the first lookup that answers "no receipt"
|
||||
// still times out, with the timeout copy rather than the RPC copy.
|
||||
await jest.advanceTimersByTimeAsync(70000);
|
||||
expect(state.currentView).toBe("error-tx");
|
||||
expect(state.viewData.message).toMatch(/could not be reached/i);
|
||||
// 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);
|
||||
expect(state.viewData.message).toMatch(/not confirmed within/);
|
||||
});
|
||||
|
||||
test("a resumed wait against a dead RPC also terminates", async () => {
|
||||
|
||||
Reference in New Issue
Block a user