Skip to content

Commit

Permalink
fix: flakey e2e_pruned_blocks test (#11431)
Browse files Browse the repository at this point in the history
We were not accounting for archiver's own polling time, which had an
inconvenient default causing for errors if the planets aligned. We now
also use `retryUntil` to not have to wait for the full duration.
  • Loading branch information
nventuro authored Jan 22, 2025
1 parent 02e6529 commit 887b8ff
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions yarn-project/end-to-end/src/e2e_pruned_blocks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type Logger,
MerkleTreeId,
type Wallet,
sleep,
retryUntil,
} from '@aztec/aztec.js';
import { type CheatCodes } from '@aztec/aztec.js/utils';
import { TokenContract } from '@aztec/noir-contracts.js/Token';
Expand Down Expand Up @@ -37,11 +37,13 @@ describe('e2e_pruned_blocks', () => {
// Don't make this value too high since we need to mine this number of empty blocks, which is relatively slow.
const WORLD_STATE_BLOCK_HISTORY = 2;
const WORLD_STATE_CHECK_INTERVAL_MS = 300;
const ARCHIVER_POLLING_INTERVAL_MS = 300;

beforeAll(async () => {
({ aztecNode, cheatCodes, logger, teardown, wallets } = await setup(3, {
worldStateBlockHistory: WORLD_STATE_BLOCK_HISTORY,
worldStateBlockCheckIntervalMS: WORLD_STATE_CHECK_INTERVAL_MS,
archiverPollingIntervalMS: ARCHIVER_POLLING_INTERVAL_MS,
}));

[adminWallet, senderWallet] = wallets;
Expand Down Expand Up @@ -90,12 +92,22 @@ describe('e2e_pruned_blocks', () => {
// blocks (notably the one with the minted note) being pruned.
await mineBlocks(WORLD_STATE_BLOCK_HISTORY);
await cheatCodes.rollup.markAsProven();
await sleep(WORLD_STATE_CHECK_INTERVAL_MS * 2);

// The same historical query we performed before should now fail since this block is not available anymore.
await expect(
aztecNode.findLeavesIndexes(firstMintReceipt.blockNumber!, MerkleTreeId.NOTE_HASH_TREE, [mintedNote!]),
).rejects.toThrow('Unable to find leaf');
// The same historical query we performed before should now fail since this block is not available anymore. We poll
// the node for a bit until it processes the blocks we marked as proven, causing the historical query to fail.
await retryUntil(
async () => {
try {
await aztecNode.findLeavesIndexes(firstMintReceipt.blockNumber!, MerkleTreeId.NOTE_HASH_TREE, [mintedNote!]);
return false;
} catch (error) {
return (error as Error).message.includes('Unable to find leaf');
}
},
'waiting for pruning',
(WORLD_STATE_CHECK_INTERVAL_MS + ARCHIVER_POLLING_INTERVAL_MS) * 5,
0.2,
);

// We've completed the setup we were interested in, and can now simply mint the second half of the amount, transfer
// the full amount to the recipient (which will require the sender to discover and prove both the old and new notes)
Expand Down

0 comments on commit 887b8ff

Please sign in to comment.