Skip to content

Commit

Permalink
fix verkle tests
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 committed Jul 29, 2024
1 parent 6ca851a commit 7f59280
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ describe('StatelessVerkleStateManager: Kaustinen Verkle Block', () => {
chain: 'customChain',
eips: [2935, 4895, 6800],
})

const decodedTxs = verkleBlockJSON.default.transactions.map((tx) =>
createTxFromSerializedData(hexToBytes(tx as PrefixedHexString)),
createTxFromSerializedData(hexToBytes(tx as PrefixedHexString), { common }),
)
const block = createBlockFromBlockData(
{ ...verkleBlockJSON, transactions: decodedTxs } as BlockData,
Expand Down
4 changes: 2 additions & 2 deletions packages/vm/test/api/EIPs/eip-6800-verkle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const common = createCustomCommon(customChainParams, Mainnet, {
hardfork: Hardfork.Cancun,
eips: [2935, 4895, 6800],
})
const decodedTxs = verkleBlockJSON.transactions.map((tx) =>
createTxFromSerializedData(hexToBytes(tx as PrefixedHexString)),
const decodedTxs = verkleBlockJSON.default.transactions.map((tx) =>
createTxFromSerializedData(hexToBytes(tx as PrefixedHexString), { common }),
)

const parentStateRoot = hexToBytes(
Expand Down
12 changes: 7 additions & 5 deletions packages/vm/test/api/customChain.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createBlockFromBlockData } from '@ethereumjs/block'
import { createBlockchain } from '@ethereumjs/blockchain'
import { Common, Hardfork, Mainnet, createCustomCommon } from '@ethereumjs/common'
import { Hardfork, Mainnet, createCustomCommon } from '@ethereumjs/common'
import { createTxFromTxData } from '@ethereumjs/tx'
import {
bytesToHex,
Expand All @@ -17,7 +17,6 @@ import { VM } from '../../src/vm.js'
import * as testChain from './testdata/testnet.json'
import * as testnetMerge from './testdata/testnetMerge.json'

import type { ChainConfig } from '@ethereumjs/common'
import type { AccountState, GenesisState, PrefixedHexString } from '@ethereumjs/util'

const storage: Array<[PrefixedHexString, PrefixedHexString]> = [
Expand Down Expand Up @@ -52,7 +51,7 @@ const genesisState: GenesisState = {

// @ts-ignore PrefixedHesString type is too strict
const common = createCustomCommon(testChain.default, Mainnet, {
chain: 'testnet',
name: 'testnet',
hardfork: Hardfork.Chainstart,
})
const block = createBlockFromBlockData(
Expand Down Expand Up @@ -118,8 +117,11 @@ describe('VM initialized with custom state', () => {
})

it('setHardfork', async () => {
const customChains = [testnetMerge] as ChainConfig[]
const common = new Common({ chain: 'testnetMerge', hardfork: Hardfork.Istanbul, customChains })
// @ts-ignore PrefixedHexString type is too strict
const common = createCustomCommon(testnetMerge.default, Mainnet, {
name: 'testnetMerge',
hardfork: Hardfork.Istanbul,
})

let vm = await VM.create({ common, setHardfork: true })
assert.equal((vm as any)._setHardfork, true, 'should set setHardfork option')
Expand Down
2 changes: 1 addition & 1 deletion packages/vm/test/api/tester/tester.config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { assert, describe, it } from 'vitest'

import { getCommon } from '../../tester/config.js'

describe('bloom', () => {
describe('test runner config tests', () => {
it('should initialize common with the right hardfork', () => {
const common = getCommon('byzantium')
assert.ok(common.hardfork() === Hardfork.Byzantium)
Expand Down
4 changes: 2 additions & 2 deletions packages/vm/test/tester/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Common, Hardfork, Mainnet, createCustomCommon } from '@ethereumjs/common'
import { type Kzg, intToHex } from '@ethereumjs/util'
import * as path from 'path'

import type { HardforkTransitionConfig } from '@ethereumjs/common'
import type { Kzg } from '@ethereumjs/util'

/**
* Default tests path (git submodule: ethereum-tests)
Expand Down Expand Up @@ -254,7 +254,7 @@ function setupCommonWithNetworks(network: string, ttd?: number, timestamp?: numb
testHardforks.push({
name: hf.name,
block: null,
ttd: BigInt(ttd),
ttd: intToHex(ttd),
})
}
if (timestamp !== undefined && hf.name !== Hardfork.Dao) {
Expand Down

0 comments on commit 7f59280

Please sign in to comment.