Skip to content

Commit

Permalink
add more e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laisolizq committed Aug 8, 2024
1 parent 061c37a commit 730c3da
Show file tree
Hide file tree
Showing 9 changed files with 16,044 additions and 1,354 deletions.
25 changes: 25 additions & 0 deletions tools/build-genesis-recursive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Flow to build recursive test
1. Copy from `zkevm-testvectors-server/tools-inputs/data/calldata/input-recursive-prover.json` to `testvecotr-gen-recursive`
2. `npm run build:input-recursive`

## Information

- Genesis:
- Contracts:
- PresComp
- UniswapV2Factory
- 2 * ERC20 Token

- Flow:
- Mint ERC20
- Create Pair
- send ERC20 to Pair
- mint LP tokens
- send ERC20
- perform Swap
- Tx Modexp
- Tx sha256
- Tx ecAdd
- Tx ecMul
- Tx ecPairing
- Tx ecrecover
7,299 changes: 6,572 additions & 727 deletions tools/build-genesis-recursive/aggregate-batches.json

Large diffs are not rendered by default.

56 changes: 51 additions & 5 deletions tools/build-genesis-recursive/build_genesis_recursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
} = require('@0xpolygonhermez/zkevm-commonjs');

// paths files
const pathTestVector = path.join(__dirname, './testvector-gen-recursive.json');
const pathInput = path.join(__dirname, './input_gen_recursive.json');
const pathOutput = path.join(__dirname, './aggregate-batches.json');

Expand All @@ -16,18 +17,63 @@ async function main() {

// read generate input
// eslint-disable-next-line global-require, import/no-dynamic-require
const testVectorData = require(pathTestVector)[0];
const generateData = require(pathInput);

// get from test-vector, input_gen_recursive
generateData.genesis = testVectorData.genesis;

const tx0 = {
"type": 11,
"deltaTimestamp": "1",
"l1Info": {
"globalExitRoot": "0x16994edfddddb9480667b64174fc00d3b6da7290d37b8db3a16571b4ddf0789f",
"blockHash": "0x24a5871d68723340d9eadc674aa8ad75f3e33b61d5a9db7db92af856a19270bb",
"timestamp": "42"
},
"indexL1InfoTree": 0
}

const txsTestVector = testVectorData.txs;
const batches = [];

for(let i = 1 ; i < txsTestVector.length; i++) {
const numTxsPerBatch = txsTestVector.length / 4;

let numBatch;
if (i < numTxsPerBatch) {
numBatch = 0;
} else if ( i < numTxsPerBatch * 2) {
numBatch = 1;
} else if (i < numTxsPerBatch * 3) {
numBatch = 2;
} else {
numBatch = 3;
}

if(!batches[numBatch]) {
batches[numBatch] = generateData.batches[numBatch];
batches[numBatch].txs = [
tx0
]
}
batches[numBatch].txs.push(txsTestVector[i]);
}

generateData.batches = batches;

// mapping wallets
const walletMap = {};

for (let i = 0; i < generateData.genesis.length; i++) {
const {
address, pvtKey,
address, pvtKey, bytecode
} = generateData.genesis[i];

const newWallet = new ethers.Wallet(pvtKey);
walletMap[address] = newWallet;
if(!bytecode) {
const newWallet = new ethers.Wallet(pvtKey);
walletMap[address] = newWallet;
}
}

// create a zkEVMDB and build a batch
Expand Down Expand Up @@ -73,14 +119,14 @@ async function main() {
// build tx
const tx = {
to: genTx.to,
nonce: genTx.nonce,
nonce: Number(genTx.nonce),
value: ethers.utils.parseUnits(genTx.value, 'wei'),
gasLimit: genTx.gasLimit,
gasPrice: ethers.utils.parseUnits(genTx.gasPrice, 'wei'),
chainId: genTx.chainId,
data: genTx.data || '0x',
};

const rawTxEthers = await walletMap[genTx.from].signTransaction(tx);
const customRawTx = processorUtils.rawTxToCustomRawTx(rawTxEthers);

Expand Down
1,176 changes: 1,157 additions & 19 deletions tools/build-genesis-recursive/input_executor_0.json

Large diffs are not rendered by default.

1,485 changes: 1,344 additions & 141 deletions tools/build-genesis-recursive/input_executor_1.json

Large diffs are not rendered by default.

1,800 changes: 1,603 additions & 197 deletions tools/build-genesis-recursive/input_executor_2.json

Large diffs are not rendered by default.

2,560 changes: 2,329 additions & 231 deletions tools/build-genesis-recursive/input_executor_3.json

Large diffs are not rendered by default.

1,489 changes: 1,455 additions & 34 deletions tools/build-genesis-recursive/input_gen_recursive.json

Large diffs are not rendered by default.

1,508 changes: 1,508 additions & 0 deletions tools/build-genesis-recursive/testvector-gen-recursive.json

Large diffs are not rendered by default.

0 comments on commit 730c3da

Please sign in to comment.