Skip to content

Commit d7c0231

Browse files
committed
wait for all batches to be executed
1 parent 8e0a008 commit d7c0231

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

core/tests/gateway-migration-test/tests/migration.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ describe('Migration From/To gateway test', function () {
205205
// this area might be worth revisiting to wait for unconfirmed transactions on the server.
206206
await utils.sleep(30);
207207

208+
// Wait for all batches to be executed
209+
await waitForAllBatchesToBeExecuted();
210+
208211
if (direction == 'TO') {
209212
await utils.spawn(
210213
`zkstack chain gateway migrate-to-gateway --chain ${fileConfig.chain} --gateway-chain-name ${gatewayChain}`
@@ -316,6 +319,34 @@ describe('Migration From/To gateway test', function () {
316319
return await chainGatewayContract.getPriorityQueueSize();
317320
}
318321
}
322+
323+
async function waitForAllBatchesToBeExecuted() {
324+
let tryCount = 0;
325+
let totalBatchesCommitted = await getTotalBatchesCommitted();
326+
let totalBatchesExecuted = await getTotalBatchesExecuted();
327+
while (totalBatchesCommitted !== totalBatchesExecuted && tryCount < 100) {
328+
tryCount += 1;
329+
await utils.sleep(1);
330+
totalBatchesCommitted = await getTotalBatchesCommitted();
331+
totalBatchesExecuted = await getTotalBatchesExecuted();
332+
}
333+
}
334+
335+
async function getTotalBatchesCommitted() {
336+
if (direction == 'TO') {
337+
return await l1MainContract.getTotalBatchesCommitted();
338+
} else {
339+
return await chainGatewayContract.getTotalBatchesCommitted();
340+
}
341+
}
342+
343+
async function getTotalBatchesExecuted() {
344+
if (direction == 'TO') {
345+
return await l1MainContract.getTotalBatchesExecuted();
346+
} else {
347+
return await chainGatewayContract.getTotalBatchesExecuted();
348+
}
349+
}
319350
});
320351

321352
async function checkedRandomTransfer(sender: zksync.Wallet, amount: bigint): Promise<zksync.types.TransactionResponse> {

0 commit comments

Comments
 (0)