Skip to content

Commit

Permalink
e2e test for withdrawals L2-initiate -> forking -> L1-finalize (#143)
Browse files Browse the repository at this point in the history
This test simulates the withdrawal process after a fork
At chainstart the genesis is similar to the output of the genesis script form this repo
In the next block a test account makes a deposit of 10 native tokens (forkonomic tokens)
on L2 into the bridge. The transaction was created with the script despoitForkonomicTokenIntoBridgeInL2.js.
Then this state advancement with the deposit is verified with a snark proof and submitted. See this PR for the actual state advancement:
preparing proof inputs for withdrawal e2e test zkevm-commonjs#2
After that the fork is initiated and executed. We then test the withdrawal process.
  • Loading branch information
josojo authored Jan 3, 2024
1 parent 602a291 commit ad52d54
Show file tree
Hide file tree
Showing 17 changed files with 46,691 additions and 31,145 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/testhardhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Main CI

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]


jobs:
lint-and-test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: ./package-lock.json
- run: npm install
- run: npx hardhat test
4 changes: 2 additions & 2 deletions contracts/ForkableBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ contract ForkableBridge is
}

/**
* @dev Allows the forkmanager to take out the forkonomic tokens
* @dev Allows aynone to take out their forkonomic tokens
* and send them to the children-bridge contracts
* Notice that forkonomic tokens are special, as they their main contract
* is on L1, but they are still forkable tokens as all the tokens from
Expand All @@ -185,7 +185,7 @@ contract ForkableBridge is
uint256 amount,
bool useFirstChild,
bool useChildTokenAllowance
) public onlyForkManger onlyAfterForking {
) public onlyAfterForking {
BridgeAssetOperations.sendForkonomicTokensToChild(
gasTokenAddress,
amount,
Expand Down
11 changes: 2 additions & 9 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,9 @@ require('@nomiclabs/hardhat-etherscan');
require('@openzeppelin/hardhat-upgrades');
require('hardhat-dependency-compiler');
require('hardhat-preprocessor');
const fs = require('fs');

const DEFAULT_MNEMONIC = 'test test test test test test test test test test test junk';

function getRemappings() {
return fs
.readFileSync('remappings.txt', 'utf8')
.split('\n')
.filter(Boolean) // remove empty lines
.map((line) => line.trim().split('='));
}

/*
* You need to export an object to set up your config
* Go to https://hardhat.org/config/ to learn more
Expand All @@ -40,6 +31,8 @@ module.exports = {
'@RealityETH/zkevm-contracts/contracts/mocks/PolygonZkEVMMock.sol',
'@RealityETH/zkevm-contracts/contracts/verifiers/FflonkVerifier.sol',
'@RealityETH/zkevm-contracts/contracts/PolygonZkEVMBridgeWrapper.sol',
'test/testcontract/ForkableExitMock.sol',
'test/testcontract/ForkableZkEVMMock.sol',
],
keep: true,
},
Expand Down
Loading

0 comments on commit ad52d54

Please sign in to comment.