Commit 99abdfe
authored
fix(ethereum): deflake monitor timeout tests in l1_tx_utils (#24545)
## Problem
`l1_tx_utils.test.ts` flaked in CI
([log](http://ci.aztec-labs.com/390c881d64e094b6), seen on
[#24454](#24454 (comment)),
which is unrelated to the failure). The failing test was `monitors all
sent txs`:
```
● L1TxUtils › L1TxUtils with blobs › monitors all sent txs
TimeoutError: L1 transaction 0x82cf...aa3a timed out
at TestL1TxUtils.monitorTransaction (l1_tx_utils/l1_tx_utils.ts:601:11)
```
## Root cause
The test creates the monitor promise and only attaches its rejection
expectation after several intervening awaits:
```ts
const monitorPromise = gasUtils.monitorTransaction(state);
await sleep(100);
await cheatCodes.mineEmptyBlock();
await expect(monitorPromise).rejects.toThrow('timed out'); // handler attached here
```
Anvil timestamps have 1s granularity, so when the wall clock crosses a
second boundary between the send and the monitor's timeout check, the
monitor (with `txTimeoutMs: 200`, `checkIntervalMs: 100`) can observe
the L1 timestamp already 1s past `sentAt` and reject **before**
`mineEmptyBlock()` completes. In the failing run the timeout fired at
`16:41:20.355`, before the empty block was mined at `.356` and before
the `.rejects` handler attached at `.357`. Node emitted
`unhandledRejection` in that window and jest 30 reported it as the test
failure — which is why the failure stack has no test-file frame and the
test's own assertions all passed in the log.
The same file already uses the safe idiom in a dozen newer tests: attach
the handler synchronously with `.catch(err => err)` and assert via
`resolves.toBeInstanceOf(TimeoutError)`.
## Fix
Apply that established pattern to the three remaining tests that expect
a monitor timeout but attach the handler only after intervening awaits:
- `stops trying after timeout once block is mined`
- `attempts to cancel timed out transactions`
- `monitors all sent txs` (the observed flake)
Test-only change; no product code touched. `TimeoutError` is exactly
what `monitorTransaction` throws on timeout, so the assertions are
equivalent-or-stricter than the previous message matching.
Evidence: CI log http://ci.aztec-labs.com/390c881d64e094b6 (search for
`monitors all sent txs`).
---
*Created by
[claudebox](https://claudebox.work/v2/sessions/0959caa9f03f59fa) ·
group: `slackbot`*1 parent 5e0e53f commit 99abdfe
1 file changed
Lines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1040 | 1040 | | |
1041 | 1041 | | |
1042 | 1042 | | |
1043 | | - | |
| 1043 | + | |
| 1044 | + | |
1044 | 1045 | | |
1045 | 1046 | | |
1046 | 1047 | | |
1047 | 1048 | | |
1048 | 1049 | | |
1049 | | - | |
| 1050 | + | |
1050 | 1051 | | |
1051 | 1052 | | |
1052 | 1053 | | |
| |||
1073 | 1074 | | |
1074 | 1075 | | |
1075 | 1076 | | |
1076 | | - | |
| 1077 | + | |
| 1078 | + | |
1077 | 1079 | | |
1078 | 1080 | | |
1079 | 1081 | | |
1080 | 1082 | | |
1081 | 1083 | | |
1082 | 1084 | | |
1083 | | - | |
| 1085 | + | |
1084 | 1086 | | |
1085 | 1087 | | |
1086 | 1088 | | |
| |||
1173 | 1175 | | |
1174 | 1176 | | |
1175 | 1177 | | |
1176 | | - | |
| 1178 | + | |
| 1179 | + | |
1177 | 1180 | | |
1178 | 1181 | | |
1179 | 1182 | | |
1180 | 1183 | | |
1181 | | - | |
| 1184 | + | |
1182 | 1185 | | |
1183 | 1186 | | |
1184 | 1187 | | |
| |||
0 commit comments