tornado-trees/test/pack.test.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-02-02 14:38:11 +03:00
/* global ethers */
2021-02-01 16:40:32 +03:00
2021-02-02 14:20:59 +03:00
const instances = [
'0xc6325fa78E0764993Bf2997116A3771bCbcb3fa9',
'0xb70738422D0f9d1225300eE0Fc67e7392095567d',
'0xA675B536203a123B0214cdf1EBb1298F440dA19A',
'0xFA1835cf197C3281Dc993a63bb160026dAC98bF3',
]
2021-02-01 16:40:32 +03:00
2021-02-02 14:20:59 +03:00
const hashes = [
'0x6f44cd7458bf24f65851fa8097712e3a8d9a6f3e387c501b285338308a74b8f3',
'0xafd3103939b7b0cd7a0ad1ddac57dd13af7f2825a21b47ae995b5bb0f767a106',
2021-02-02 14:27:58 +03:00
'0x57f7b90a3cb4ea6860e6dd5fa44ac4f53ebe6ae3948af577a01ef51738313246',
2021-02-02 14:20:59 +03:00
]
2021-02-01 16:40:32 +03:00
2021-02-26 12:14:43 +03:00
const CHUNK_TREE_HEIGHT = 8
2021-02-02 14:20:59 +03:00
describe.skip('Pack', () => {
it('should work', async () => {
2021-02-02 14:27:58 +03:00
const Pack = await ethers.getContractFactory('Pack')
2021-02-02 14:20:59 +03:00
const pack = await Pack.deploy()
2021-02-01 16:40:32 +03:00
2021-02-02 14:20:59 +03:00
const notes = []
2021-02-01 16:40:32 +03:00
for (let i = 0; i < 2 ** CHUNK_TREE_HEIGHT; i++) {
notes[i] = {
instance: instances[i % instances.length],
hash: hashes[i % hashes.length],
block: 1 + i,
}
}
2021-02-02 14:27:58 +03:00
const receipt = await pack.pack2(
notes.map((a) => a.hash),
notes.map((a) => a.instance),
notes.map((a) => a.block),
)
2021-02-02 14:20:59 +03:00
const receipt2 = await receipt.wait()
console.log(`total ${receipt2.gasUsed}`)
console.log(`batch size ${notes.length}`)
console.log(`events ${await pack.gas1()}`)
console.log(`hash ${await pack.gas2()}`)
console.log(`bytes ${await pack.gas3()}`)
console.log(`calldata ${receipt.gasLimit.sub(await pack.gas4())}`)
2021-02-01 16:40:32 +03:00
})
})