Skip to content

Commit 4fb1de3

Browse files
committed
try fixes
1 parent 1eb4bb6 commit 4fb1de3

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

core/tests/highlevel-test-tools/tests/token-balance-migration-tester.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,31 @@ export class ChainHandler {
100100

101101
async stopServer() {
102102
await this.inner.mainNode.kill();
103-
// Need to wait for a bit before the server is killed completely
104-
await sleep(2000);
103+
// Wait until it's really stopped.
104+
const generalConfig = loadConfig({ pathToHome, chain: this.inner.chainName, config: 'general.yaml' });
105+
const l2NodeUrl = generalConfig.api.web3_json_rpc.http_url;
106+
let iter = 0;
107+
while (iter < 30) {
108+
try {
109+
console.log(l2NodeUrl);
110+
let provider = new zksync.Provider(l2NodeUrl);
111+
await provider.getBlockNumber();
112+
await sleep(1);
113+
iter += 1;
114+
} catch (_) {
115+
// When exception happens, we assume that server died.
116+
return;
117+
}
118+
}
119+
// It's going to panic anyway, since the server is a singleton entity, so better to exit early.
120+
throw new Error(`${this.inner.chainName} didn't stop after a kill request`);
105121
}
106122

107123
async startServer() {
108124
const newServerHandle = await startServer(this.inner.chainName);
109125
this.inner.mainNode = newServerHandle;
110126
// Need to wait for a bit before the server works fully
111-
await sleep(2000);
127+
await sleep(5000);
112128
}
113129

114130
async migrateToGateway() {
@@ -129,6 +145,7 @@ export class ChainHandler {
129145
'gateway_migration'
130146
);
131147
// Wait for all batches to be executed
148+
await utils.sleep(30);
132149
await waitForAllBatchesToBeExecuted(this.l1GettersContract);
133150
// We can now reliably migrate to gateway
134151
await this.stopServer();
@@ -163,6 +180,7 @@ export class ChainHandler {
163180
'gateway_migration'
164181
);
165182
// Wait for all batches to be executed
183+
await utils.sleep(30);
166184
await waitForAllBatchesToBeExecuted(this.gwGettersContract);
167185
// We can now reliably migrate from gateway
168186
await this.stopServer();
@@ -227,7 +245,7 @@ export class ChainHandler {
227245
// We need to kill the server first to set the gateway RPC URL in secrets.yaml
228246
await testChain.mainNode.kill();
229247
// Wait a bit for clean shutdown
230-
await sleep(2000);
248+
await sleep(5000);
231249

232250
// Set the gateway RPC URL before any migration operations
233251
const gatewayGeneralConfig = loadConfig({ pathToHome, chain: 'gateway', config: 'general.yaml' });
@@ -240,7 +258,7 @@ export class ChainHandler {
240258
const newServerHandle = await startServer(testChain.chainName);
241259
testChain.mainNode = newServerHandle;
242260
// Need to wait for a bit before the server works fully
243-
await sleep(2000);
261+
await sleep(5000);
244262
await initTestWallet(testChain.chainName);
245263

246264
return new ChainHandler(testChain, await generateChainRichWallet(testChain.chainName));

0 commit comments

Comments
 (0)