Skip to content

Commit 195aa3d

Browse files
authored
fix: Increase test timeouts (#10205)
Some world state tests can take a few seconds to run on a local machine. In CI, they can take much longer and this is causing flakes. As much as I dislike increasing test timeouts to fix flakes, this feels like the only option.
1 parent d7ae959 commit 195aa3d

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

yarn-project/world-state/src/native/native_world_state.test.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from '@aztec/circuits.js';
1717
import { makeContentCommitment, makeGlobalVariables } from '@aztec/circuits.js/testing';
1818

19+
import { jest } from '@jest/globals';
1920
import { mkdtemp, rm } from 'fs/promises';
2021
import { tmpdir } from 'os';
2122
import { join } from 'path';
@@ -26,6 +27,8 @@ import { type WorldStateStatusSummary } from './message.js';
2627
import { NativeWorldStateService, WORLD_STATE_VERSION_FILE } from './native_world_state.js';
2728
import { WorldStateVersion } from './world_state_version.js';
2829

30+
jest.setTimeout(60_000);
31+
2932
describe('NativeWorldState', () => {
3033
let dataDir: string;
3134
let rollupAddress: EthAddress;
@@ -52,7 +55,7 @@ describe('NativeWorldState', () => {
5255

5356
await ws.handleL2BlockAndMessages(block, messages);
5457
await ws.close();
55-
}, 30_000);
58+
});
5659

5760
it('correctly restores committed state', async () => {
5861
const ws = await NativeWorldStateService.new(rollupAddress, dataDir, defaultDBMapSize);
@@ -243,7 +246,7 @@ describe('NativeWorldState', () => {
243246

244247
const forkAtZero = await ws.fork(0);
245248
await compareChains(forkAtGenesis, forkAtZero);
246-
}, 30_000);
249+
});
247250
});
248251

249252
describe('Pending and Proven chain', () => {
@@ -278,7 +281,7 @@ describe('NativeWorldState', () => {
278281
expect(status.summary.finalisedBlockNumber).toBe(0n);
279282
}
280283
}
281-
}, 30_000);
284+
});
282285

283286
it('Can finalise multiple blocks', async () => {
284287
const fork = await ws.fork();
@@ -297,7 +300,7 @@ describe('NativeWorldState', () => {
297300
expect(status.unfinalisedBlockNumber).toBe(16n);
298301
expect(status.oldestHistoricalBlock).toBe(1n);
299302
expect(status.finalisedBlockNumber).toBe(8n);
300-
}, 30_000);
303+
});
301304

302305
it('Can prune historic blocks', async () => {
303306
const fork = await ws.fork();
@@ -348,7 +351,7 @@ describe('NativeWorldState', () => {
348351
'Unable to remove historical block, block not found',
349352
);
350353
}
351-
}, 30_000);
354+
});
352355

353356
it('Can re-org', async () => {
354357
const nonReorgState = await NativeWorldStateService.tmp();
@@ -448,7 +451,7 @@ describe('NativeWorldState', () => {
448451
}
449452

450453
await compareChains(ws.getCommitted(), nonReorgState.getCommitted());
451-
}, 30_000);
454+
});
452455

453456
it('Forks are deleted during a re-org', async () => {
454457
const fork = await ws.fork();
@@ -480,7 +483,7 @@ describe('NativeWorldState', () => {
480483
await expect(blockForks[i].getSiblingPath(MerkleTreeId.NULLIFIER_TREE, 0n)).rejects.toThrow('Fork not found');
481484
}
482485
}
483-
}, 30_000);
486+
});
484487
});
485488

486489
describe('status reporting', () => {
@@ -596,6 +599,6 @@ describe('NativeWorldState', () => {
596599
expect(statuses[0].dbStats.publicDataTreeStats.mapSize).toBe(mapSizeBytes);
597600

598601
await ws.close();
599-
}, 30_000);
602+
});
600603
});
601604
});

yarn-project/world-state/src/native/native_world_state_cmp.test.ts

+12-16
Original file line numberDiff line numberDiff line change
@@ -133,24 +133,20 @@ describe('NativeWorldState', () => {
133133
.fill(0)
134134
.map(() => new PublicDataTreeLeaf(Fr.random(), Fr.random()).toBuffer()),
135135
],
136-
])(
137-
'inserting real leaves into %s',
138-
async (_, treeId, leaves) => {
139-
const height = Math.ceil(Math.log2(leaves.length) | 0);
140-
const [native, js] = await Promise.all([
141-
nativeFork.batchInsert(treeId, leaves, height),
142-
legacyLatest.batchInsert(treeId, leaves, height),
143-
]);
136+
])('inserting real leaves into %s', async (_, treeId, leaves) => {
137+
const height = Math.ceil(Math.log2(leaves.length) | 0);
138+
const [native, js] = await Promise.all([
139+
nativeFork.batchInsert(treeId, leaves, height),
140+
legacyLatest.batchInsert(treeId, leaves, height),
141+
]);
144142

145-
expect(native.sortedNewLeaves.map(Fr.fromBuffer)).toEqual(js.sortedNewLeaves.map(Fr.fromBuffer));
146-
expect(native.sortedNewLeavesIndexes).toEqual(js.sortedNewLeavesIndexes);
147-
expect(native.newSubtreeSiblingPath.toFields()).toEqual(js.newSubtreeSiblingPath.toFields());
148-
expect(native.lowLeavesWitnessData).toEqual(js.lowLeavesWitnessData);
143+
expect(native.sortedNewLeaves.map(Fr.fromBuffer)).toEqual(js.sortedNewLeaves.map(Fr.fromBuffer));
144+
expect(native.sortedNewLeavesIndexes).toEqual(js.sortedNewLeavesIndexes);
145+
expect(native.newSubtreeSiblingPath.toFields()).toEqual(js.newSubtreeSiblingPath.toFields());
146+
expect(native.lowLeavesWitnessData).toEqual(js.lowLeavesWitnessData);
149147

150-
await assertSameTree(treeId, nativeFork, legacyLatest);
151-
},
152-
60_000,
153-
);
148+
await assertSameTree(treeId, nativeFork, legacyLatest);
149+
});
154150

155151
it.each<[string, FrTreeId, Fr[]]>([
156152
[MerkleTreeId[MerkleTreeId.NOTE_HASH_TREE], MerkleTreeId.NOTE_HASH_TREE, Array(64).fill(0).map(Fr.random)],

yarn-project/world-state/src/test/integration.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { createWorldState } from '../synchronizer/factory.js';
1414
import { ServerWorldStateSynchronizer } from '../synchronizer/server_world_state_synchronizer.js';
1515
import { mockBlocks } from './utils.js';
1616

17+
jest.setTimeout(60_000);
18+
1719
describe('world-state integration', () => {
1820
let rollupAddress: EthAddress;
1921
let archiver: MockPrefilledArchiver;
@@ -34,7 +36,7 @@ describe('world-state integration', () => {
3436
log.info(`Generating ${MAX_BLOCK_COUNT} mock blocks`);
3537
({ blocks, messages } = await mockBlocks(1, MAX_BLOCK_COUNT, 1, db));
3638
log.info(`Generated ${blocks.length} mock blocks`);
37-
}, 30_000);
39+
});
3840

3941
beforeEach(async () => {
4042
config = {

0 commit comments

Comments
 (0)