Skip to content

Commit

Permalink
chore(tests): restore revert test (matter-labs#714)
Browse files Browse the repository at this point in the history
## What ❔

Restores revert test

## Why ❔

Restores revert test

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [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`.
  • Loading branch information
perekopskiy authored Dec 20, 2023
1 parent 87026a5 commit 7661558
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 27 deletions.
46 changes: 23 additions & 23 deletions .github/workflows/ci-core-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: |
Expand All @@ -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
21 changes: 17 additions & 4 deletions core/tests/revert-test/tests/revert-and-restart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7661558

Please sign in to comment.