Skip to content

Commit

Permalink
util: test data migration (#3685)
Browse files Browse the repository at this point in the history
Co-authored-by: Holger Drewes <[email protected]>
  • Loading branch information
gabrocheleau and holgerd77 authored Sep 19, 2024
1 parent 647a518 commit 6714f0d
Show file tree
Hide file tree
Showing 7 changed files with 962 additions and 930 deletions.
6 changes: 3 additions & 3 deletions packages/util/test/account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
utf8ToBytes,
} from '../src/index.js'

import eip1014Testdata from './testdata/eip1014Examples.json'
import { eip1404ExamplesData } from './testdata/eip1014Examples.js'

import type { AccountBodyBytes, AccountData, PrefixedHexString } from '../src/index.js'
import type { Input } from '@ethereumjs/rlp'
Expand Down Expand Up @@ -538,7 +538,7 @@ describe('Utility Functions', () => {
})

it('generateAddress2: EIP-1014 testdata examples', () => {
for (const testdata of eip1014Testdata) {
for (const testdata of eip1404ExamplesData) {
const { address, comment, result, salt, initCode } = testdata
const addr = generateAddress2(
hexToBytes(address as PrefixedHexString),
Expand All @@ -550,7 +550,7 @@ describe('Utility Functions', () => {
})

it('generateAddress2: non-buffer inputs', () => {
const { address, salt, initCode } = eip1014Testdata[0]
const { address, salt, initCode } = eip1404ExamplesData[0]

assert.throws(
function () {
Expand Down
4 changes: 2 additions & 2 deletions packages/util/test/address.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
toBytes,
} from '../src/index.js'

import eip1014Testdata from './testdata/eip1014Examples.json'
import { eip1404ExamplesData } from './testdata/eip1014Examples.js'

import type { PrefixedHexString } from '../src/index.js'

Expand Down Expand Up @@ -103,7 +103,7 @@ describe('Address', () => {
})

it('should generate address for CREATE2', () => {
for (const testdata of eip1014Testdata) {
for (const testdata of eip1404ExamplesData) {
const { address, salt, initCode, result } = testdata
const from = createAddressFromString(address)
const addr = createContractAddress2(
Expand Down
4 changes: 2 additions & 2 deletions packages/util/test/genesis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { assert, describe, it } from 'vitest'
import { parseGethGenesisState } from '../src/genesis.js'

// kiln genesis with deposit contract storage set
import gethGenesisKilnJSON from './testdata/geth-genesis-kiln.json'
import { gethGenesisKilnData } from './testdata/gethGenesisKiln.js'

describe('[Util/genesis]', () => {
it('should properly generate stateRoot from gethGenesis', () => {
const genesisState = parseGethGenesisState(gethGenesisKilnJSON)
const genesisState = parseGethGenesisState(gethGenesisKilnData)
// just check for deposit contract inclusion
assert.equal(
genesisState['0x4242424242424242424242424242424242424242'][1].includes(
Expand Down
58 changes: 0 additions & 58 deletions packages/util/test/testdata/eip1014Examples.json

This file was deleted.

59 changes: 59 additions & 0 deletions packages/util/test/testdata/eip1014Examples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export const eip1404ExamplesData = [
{
comment: 'Example 0',
address: '0x0000000000000000000000000000000000000000',
salt: '0x0000000000000000000000000000000000000000000000000000000000000000',
initCode: '0x00',
gas: '32006',
result: '0x4d1a2e2bb4f88f0250f26ffff098b0b30b26bf38',
},
{
comment: 'Example 1',
address: '0xdeadbeef00000000000000000000000000000000',
salt: '0x0000000000000000000000000000000000000000000000000000000000000000',
initCode: '0x00',
gas: '32006',
result: '0xb928f69bb1d91cd65274e3c79d8986362984fda3',
},
{
comment: 'Example 2',
address: '0xdeadbeef00000000000000000000000000000000',
salt: '0x000000000000000000000000feed000000000000000000000000000000000000',
initCode: '0x00',
gas: '32006',
result: '0xd04116cdd17bebe565eb2422f2497e06cc1c9833',
},
{
comment: 'Example 3',
address: '0x0000000000000000000000000000000000000000',
salt: '0x0000000000000000000000000000000000000000000000000000000000000000',
initCode: '0xdeadbeef',
gas: '32006',
result: '0x70f2b2914a2a4b783faefb75f459a580616fcb5e',
},
{
comment: 'Example 4',
address: '0x00000000000000000000000000000000deadbeef',
salt: '0x00000000000000000000000000000000000000000000000000000000cafebabe',
initCode: '0xdeadbeef',
gas: '32006',
result: '0x60f3f640a8508fc6a86d45df051962668e1e8ac7',
},
{
comment: 'Example 5',
address: '0x00000000000000000000000000000000deadbeef',
salt: '0x00000000000000000000000000000000000000000000000000000000cafebabe',
initCode:
'0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
gas: '32012',
result: '0x1d8bfdc5d46dc4f61d6b6115972536ebe6a8854c',
},
{
comment: 'Example 6',
address: '0x0000000000000000000000000000000000000000',
salt: '0x0000000000000000000000000000000000000000000000000000000000000000',
initCode: '0x',
gas: '32000',
result: '0xe33c0c7f7df4809055c3eba6c09cfe4baf1bd9e0',
},
]
Loading

0 comments on commit 6714f0d

Please sign in to comment.