Skip to content

Commit

Permalink
added create and non-create tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drortirosh committed Apr 8, 2024
1 parent bb17878 commit 8e62d8b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
28 changes: 24 additions & 4 deletions gascalc/7-zerodev-kernel-lite.gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BigNumberish } from 'ethers'
import { defaultAbiCoder, Interface } from 'ethers/lib/utils'
import { log } from 'console'
// TODO: NOTE: Must be executed separately as otherwise test will reuse SimpleAccount
context.only('simple account', function () {
context('kernel account', function () {
this.timeout(60000)
const g = new GasChecker()

Expand Down Expand Up @@ -62,9 +62,29 @@ context.only('simple account', function () {
await ethers.provider.getSigner().sendTransaction({ to: zkLite1, value: 1e18.toString() })
})

it('simple 1', async function () {
it('kernel-lite-create', async function () {
await g.addTestRow({
title: 'zd-kernel-lite',
title: 'zd-lite-create',
count: 1,
factoryInfo,
execInfo,
skipAccountCreation: false,
appendZerodevMode: true,
diffLastGas: false
})
await g.addTestRow({
title: 'zd-lite-create - diff',
count: 2,
factoryInfo,
execInfo,
skipAccountCreation: false,
appendZerodevMode: true,
diffLastGas: true
})
})
it('kernel-lite-no-create', async function () {
await g.addTestRow({
title: 'zd-lite',
count: 1,
factoryInfo,
execInfo,
Expand All @@ -73,7 +93,7 @@ context.only('simple account', function () {
diffLastGas: false
})
await g.addTestRow({
title: 'zd-kernel-lite - diff from previous',
title: 'zd-lite - diff',
count: 2,
factoryInfo,
execInfo,
Expand Down
9 changes: 7 additions & 2 deletions gascalc/GasChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,15 @@ export class GasChecker {
const ret = await provider.call({ to: f.factory, data: f.factoryData })
account = defaultAbiCoder.decode(['address'], ret)[0]
// if ((await getBalance(account)).eq(0)) {
console.log('replenish initcode account', account)
console.log('replenish new account', account)
await ethersSigner.sendTransaction({ to: account, value: parseEther('1') })
// }
initCode = hexConcat([f.factory, f.factoryData])
if (params.skipAccountCreation ?? false) {
// pre-create the account
await ethersSigner.sendTransaction({ to: f.factory, data: f.factoryData })
} else {
initCode = hexConcat([f.factory, f.factoryData])
}
}
const paymaster = info.paymaster

Expand Down

0 comments on commit 8e62d8b

Please sign in to comment.