Commit a5b3c78
authored
test(e2e): extract p2p gossip scenario skeleton and add category README (#24500)
PR 8 of 9 of the e2e round-2 consolidation. Scope:
`end-to-end/src/p2p/**` only. Dedup + docs; no timing/config value
changes.
## DATA_DIR centralization
- Every p2p file previously repeated `DATA_DIR = fs.mkdtempSync(...)` at
module scope plus a per-node `fs.rmSync` cleanup loop in `afterEach`.
That boilerplate now lives on `P2PNetworkTest`: `setup()` creates one
root temp dir (`this.dataDir`), `dataDirFor(label)` hands out a nested
per-role path (multi-node `createNodes` appends `-<index>`; single-node
factories use it verbatim), and `teardown()` removes the whole tree in
one recursive delete.
- Adopted in all files (the 6 test files + `reqresp/utils.ts`); deleted
the per-file `fs`/`os`/`path` imports, `mkdtempSync`, and cleanup loops.
This also fixes a small pre-existing leak: the old `mkdtempSync` root
dir was never removed (node data went into sibling `-N` dirs), whereas
nodes now live under the root that teardown deletes.
## Gossip scenario skeleton (`shared.ts`)
- `runGossipScenario(opts): Promise<AztecNodeService[]>` — the shared
bootstrap→createNodes→mesh→account→(submit)→verify flow. Varying parts
are options/callbacks: `numValidators`, `bootNodePort`, `txsPerNode` (0
skips submission), `submitSequentially`, `mesh` (topic/peer-count
overrides), `checkpointSource` (`'first-tx'` | `'first-published'`),
`beforeCreateNodes`, `createExtraNodes`, `beforeSubmit`, `afterVerify`.
Returns the validator nodes for teardown tracking.
- Extracted the repeated building blocks it uses:
`verifyAttestationSigners(t, nodes, checkpoint)` (recovers signers,
asserts each ∈ validator set, returns signers),
`getPublishedCheckpointForTx(node, txHash)`,
`waitForFirstPublishedCheckpoint(t, nodes)`, `waitForNodesToSync(t,
nodes)`, and `maybeCheckQosAlerts(logger)` (the `CHECK_ALERTS` Grafana
block that was copy-pasted in 4 files).
## Merge: `gossip_network_no_cheat.test.ts` → `gossip_network.test.ts`
The two files shared the skeleton but genuinely differ in network
bootstrap (cheat MultiAdder registration vs. on-chain `addL1Validator`
CLI flow) and config, so they became two `describe`s in one file, each
with its own `beforeEach` — the mesh is not re-spun per `it`.
- `describe('cheat-registered validators')` — was
`gossip_network.test.ts`. Effective node config unchanged: 4 validators,
`startProverNode:false`, `SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES` +
`aztecSlotDuration:24, aztecEpochDuration:4, blockDurationMs:10000,
slashingRoundSizeInEpochs:2, slashingQuorum:5, listenAddress:127.0.0.1,
inboxLag:2`; plus a p2p-only prover node and a re-execution monitoring
node; proven-block assertion preserved.
- `describe('on-chain-registered validators (no cheats)')` — was
`gossip_network_no_cheat.test.ts`. Effective node config unchanged: 4
validators, `SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES` +
`aztecSlotDuration:24, blockDurationMs:10000, minTxsPerBlock:0,
listenAddress:127.0.0.1, inboxLag:2`; full-mesh wait on the
proposal/checkpoint topics; all on-chain registration assertions
preserved. `BOOT_NODE_UDP_PORT` default stays 4500 (now shared with the
cheat describe, which honored the `BOOT_NODE_UDP_PORT` env override —
the default is unchanged).
Both describes run sequentially in one CI container reusing port 4500
(teardown fully frees ports before the next `beforeEach`).
## `fee_asset_price_oracle_gossip.test.ts`
Kept as its own file, now on the shared skeleton with `txsPerNode: 0`
(it submits no txs — empty blocks carry the price) and
`checkpointSource: 'first-published'`. Effective node config unchanged:
4 validators, `startProverNode:false`,
`SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES` + `aztecSlotDuration:12,
aztecEpochDuration:4, slashingRoundSizeInEpochs:2, slashingQuorum:5,
listenAddress, inboxLag:2`, plus a prover node (`minTxsPerBlock:0`).
Both oracle-convergence rounds and final assertions preserved.
## Other files
- `preferred_gossip_network.test.ts` adopted `verifyAttestationSigners`
+ `maybeCheckQosAlerts` (its signer-check block was identical, keyed off
the `validators` array), plus the DATA_DIR change. Node config and the
`expect(signers.length).toEqual(validators.length)` assertion unchanged.
- `late_prover_tx_collection.test.ts`, `rediscovery.test.ts`,
`reqresp/reqresp.test.ts` + `reqresp/utils.ts`: DATA_DIR change only;
node config unchanged.
- Added `p2p/README.md` (the missing category README) matching the
`multi-node`/`single-node` structure: what belongs here (real-libp2p
subjects — discovery, req/resp, mesh, peer auth, transport), what does
not (consensus/slashing/sentinel → `multi-node`), the `P2PNetworkTest`
entrypoint, the shared skeleton/helpers, and the post-merge file
inventory.
## Behavior notes
- No dropped assertions.
- Two benign, non-asserting implementation changes, documented for
reviewers: (1) in the no-cheat describe `setupAccount()` now runs before
the first-checkpoint wait instead of after — both still precede tx
submission, and `setupAccount()` only registers the account in the PXE
(no on-chain effect), so the "checkpoint published before submit"
invariant is preserved; (2) the merged submit path uses
`waitForTxs(...)` for both describes rather than the no-cheat file's
per-tx `Promise.all(waitForTx)` — same asserted property (all txs
mined).
## Local runs (one file at a time; real-libp2p tests bind fixed ports)
All green:
| File / describe | wall |
|---|---|
| gossip_network — cheat-registered | 121s |
| gossip_network — on-chain (no cheats) | 172s |
| fee_asset_price_oracle_gossip | 120s |
| rediscovery | 69s |
| late_prover_tx_collection | 47s |
| reqresp/reqresp | 121s |
| preferred_gossip_network | 141s |
CI selection is glob/regex-based (`src/p2p/**/*.test.ts`,
`src/p2p/*.test.ts`, `.test_patterns.yml`'s `src/p2p/.*`), so deleting
the merged-away file needs no CI-config edits.1 parent 78594d7 commit a5b3c78
11 files changed
Lines changed: 725 additions & 768 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
0 commit comments