From 7661558989c005a8fafe9bf88dfc405b1ad8bd9d Mon Sep 17 00:00:00 2001 From: perekopskiy <53865202+perekopskiy@users.noreply.github.com> Date: Wed, 20 Dec 2023 18:23:25 +0200 Subject: [PATCH] chore(tests): restore revert test (#714) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Restores revert test ## Why ❔ Restores revert test ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. - [x] Spellcheck has been run via `cargo spellcheck --cfg=./spellcheck/era.cfg --code 1`. --- .github/workflows/ci-core-reusable.yml | 46 +++++++++---------- .../tests/revert-and-restart.test.ts | 21 +++++++-- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci-core-reusable.yml b/.github/workflows/ci-core-reusable.yml index 6aa88a409aa..6af10525855 100644 --- a/.github/workflows/ci-core-reusable.yml +++ b/.github/workflows/ci-core-reusable.yml @@ -186,11 +186,11 @@ jobs: - name: Fee projection tests run: ci_run zk test i fees -# - name: Run revert test -# run: | -# ci_run pkill zksync_server || true -# ci_run sleep 2 -# ci_run zk test i revert + - name: Run revert test + run: | + ci_run pkill zksync_server || true + ci_run sleep 2 + ci_run zk test i revert # This test should be the last one as soon as it # finished bootloader will be different @@ -205,7 +205,7 @@ jobs: run: | ci_run cat server.log ci_run cat contract_verifier.log - # ci_run cat core/tests/revert-test/revert.log + ci_run cat core/tests/revert-test/revert.log ci_run cat core/tests/upgrade-test/upgrade.log ci_run sccache --show-stats ci_run cat /tmp/sccache_log.txt @@ -285,22 +285,22 @@ jobs: - name: Run Cross EN Checker run: ci_run zk run cross-en-checker -# - name: Run revert test -# run: | -# ci_run zk env -# ci_run zk env docker -# ci_run pkill zksync_server || true -# ci_run sleep 2 -# ci_run zk env -# ci_run zk test i revert -# # Check that the rollback was performed on the EN -# ci_run sleep 20 -# ci_run grep -q 'Rollback successfully completed' ext-node.log -# # Restart the EN -# ci_run zk server &>>server.log & -# ci_run sleep 30 -# ZKSYNC_ENV=ext-node-docker ci_run zk external-node &>>ext-node.log & -# ci_run sleep 30 + - name: Run revert test + run: | + ci_run zk env + ci_run zk env docker + ci_run pkill zksync_server || true + ci_run sleep 2 + ci_run zk env + ci_run zk test i revert + # Check that the rollback was performed on the EN + ci_run sleep 20 + ci_run grep -q 'Rollback successfully completed' ext-node.log + # Restart the EN + ci_run zk server &>>server.log & + ci_run sleep 30 + ZKSYNC_ENV=ext-node-docker ci_run zk external-node &>>ext-node.log & + ci_run sleep 30 - name: Run upgrade test run: | @@ -312,7 +312,7 @@ jobs: run: | ci_run cat server.log ci_run cat ext-node.log - # ci_run cat core/tests/revert-test/revert.log + ci_run cat core/tests/revert-test/revert.log ci_run cat core/tests/upgrade-test/upgrade.log ci_run sccache --show-stats ci_run cat /tmp/sccache_log.txt diff --git a/core/tests/revert-test/tests/revert-and-restart.test.ts b/core/tests/revert-test/tests/revert-and-restart.test.ts index e8a36bc19b7..bbbd5136859 100644 --- a/core/tests/revert-test/tests/revert-and-restart.test.ts +++ b/core/tests/revert-test/tests/revert-and-restart.test.ts @@ -184,9 +184,16 @@ describe('Block reverting test', function () { amount: depositAmount, to: alice.address }); - console.log('here1'); - let receipt = await depositHandle.waitFinalize(); - console.log('here2'); + const l1TxResponse = await alice._providerL1().getTransaction(depositHandle.hash); + // ethers doesn't work well with block reversions, so wait for the receipt before calling `.waitFinalize()`. + const l2Tx = await alice._providerL2().getL2TransactionFromPriorityOp(l1TxResponse); + let receipt = null; + do { + receipt = await tester.syncWallet.provider.getTransactionReceipt(l2Tx.hash); + await utils.sleep(1); + } while (receipt == null); + + await depositHandle.waitFinalize(); expect(receipt.status).to.be.eql(1); const balanceAfter = await alice.getBalance(); @@ -221,7 +228,13 @@ async function checkedRandomTransfer(sender: zkweb3.Wallet, amount: BigNumber) { to: receiver.address, value: amount }); - const txReceipt = await transferHandle.wait(); + + // ethers doesn't work well with block reversions, so we poll for the receipt manually. + let txReceipt = null; + do { + txReceipt = await sender.provider.getTransactionReceipt(transferHandle.hash); + await utils.sleep(1); + } while (txReceipt == null); const senderBalance = await sender.getBalance(); const receiverBalance = await receiver.getBalance();