1
1
import { Common , Hardfork , Mainnet , createCustomCommon } from '@ethereumjs/common'
2
2
import { RLP } from '@ethereumjs/rlp'
3
+ import {
4
+ goerliChainConfig ,
5
+ preLondonTestDataBlocks1 ,
6
+ preLondonTestDataBlocks2 ,
7
+ testnetMergeChainConfig ,
8
+ } from '@ethereumjs/testdata'
3
9
import { createLegacyTx } from '@ethereumjs/tx'
4
10
import { KECCAK256_RLP_ARRAY , bytesToHex , equalsBytes , hexToBytes , toBytes } from '@ethereumjs/util'
5
11
import { assert , describe , it } from 'vitest'
@@ -17,11 +23,7 @@ import {
17
23
} from '../src/index.ts'
18
24
19
25
import { genesisHashesTestData } from './testdata/genesisHashesTest.ts'
20
- import { Goerli } from './testdata/goerliCommon.ts'
21
26
import { testdataFromRPCGoerliData } from './testdata/testdata-from-rpc-goerli.ts'
22
- import { testdataPreLondon2Data } from './testdata/testdata_pre-london-2.ts'
23
- import { testdataPreLondonData } from './testdata/testdata_pre-london.ts'
24
- import { testnetMergeData } from './testdata/testnetMerge.ts'
25
27
26
28
import type { NestedUint8Array , PrefixedHexString } from '@ethereumjs/util'
27
29
@@ -83,7 +85,7 @@ describe('[Block]: block functions', () => {
83
85
} )
84
86
85
87
it ( 'initialization -> setHardfork option' , ( ) => {
86
- const common = createCustomCommon ( testnetMergeData , Mainnet )
88
+ const common = createCustomCommon ( testnetMergeChainConfig , Mainnet )
87
89
88
90
let block = createBlock (
89
91
{
@@ -135,7 +137,7 @@ describe('[Block]: block functions', () => {
135
137
136
138
it ( 'should test block validation on pow chain' , async ( ) => {
137
139
const common = new Common ( { chain : Mainnet , hardfork : Hardfork . Istanbul } )
138
- const blockRlp = hexToBytes ( testdataPreLondonData . blocks [ 0 ] . rlp as PrefixedHexString )
140
+ const blockRlp = hexToBytes ( preLondonTestDataBlocks1 . blocks [ 0 ] . rlp as PrefixedHexString )
139
141
try {
140
142
createBlockFromRLP ( blockRlp , { common } )
141
143
assert . isTrue ( true , 'should pass' )
@@ -145,7 +147,7 @@ describe('[Block]: block functions', () => {
145
147
} )
146
148
147
149
it ( 'should test block validation on poa chain' , async ( ) => {
148
- const common = new Common ( { chain : Goerli , hardfork : Hardfork . Chainstart } )
150
+ const common = new Common ( { chain : goerliChainConfig , hardfork : Hardfork . Chainstart } )
149
151
150
152
try {
151
153
createBlockFromRPC ( testdataFromRPCGoerliData , [ ] , { common } )
@@ -161,7 +163,7 @@ describe('[Block]: block functions', () => {
161
163
}
162
164
163
165
it ( 'should test transaction validation - invalid tx trie' , async ( ) => {
164
- const blockRlp = hexToBytes ( testdataPreLondonData . blocks [ 0 ] . rlp as PrefixedHexString )
166
+ const blockRlp = hexToBytes ( preLondonTestDataBlocks1 . blocks [ 0 ] . rlp as PrefixedHexString )
165
167
const common = new Common ( { chain : Mainnet , hardfork : Hardfork . London } )
166
168
const block = createBlockFromRLP ( blockRlp , { common, freeze : false } )
167
169
await testTransactionValidation ( block )
@@ -203,7 +205,7 @@ describe('[Block]: block functions', () => {
203
205
204
206
it ( 'should test transaction validation with legacy tx in london' , async ( ) => {
205
207
const common = new Common ( { chain : Mainnet , hardfork : Hardfork . London } )
206
- const blockRlp = hexToBytes ( testdataPreLondonData . blocks [ 0 ] . rlp as PrefixedHexString )
208
+ const blockRlp = hexToBytes ( preLondonTestDataBlocks1 . blocks [ 0 ] . rlp as PrefixedHexString )
207
209
const block = createBlockFromRLP ( blockRlp , { common, freeze : false } )
208
210
await testTransactionValidation ( block )
209
211
// @ts -expect-error -- Assigning to read-only property
@@ -217,7 +219,7 @@ describe('[Block]: block functions', () => {
217
219
218
220
it ( 'should test uncles hash validation' , async ( ) => {
219
221
const common = new Common ( { chain : Mainnet , hardfork : Hardfork . Istanbul } )
220
- const blockRlp = hexToBytes ( testdataPreLondon2Data . blocks [ 2 ] . rlp as PrefixedHexString )
222
+ const blockRlp = hexToBytes ( preLondonTestDataBlocks2 . blocks [ 2 ] . rlp as PrefixedHexString )
221
223
const block = createBlockFromRLP ( blockRlp , { common, freeze : false } )
222
224
assert . equal ( block . uncleHashIsValid ( ) , true )
223
225
// @ts -expect-error -- Assigning to read-only property
@@ -355,7 +357,7 @@ describe('[Block]: block functions', () => {
355
357
it ( 'should return the same block data from raw()' , ( ) => {
356
358
const common = new Common ( { chain : Mainnet , hardfork : Hardfork . Istanbul } )
357
359
const block = createBlockFromRLP (
358
- toBytes ( testdataPreLondon2Data . blocks [ 2 ] . rlp as PrefixedHexString ) ,
360
+ toBytes ( preLondonTestDataBlocks2 . blocks [ 2 ] . rlp as PrefixedHexString ) ,
359
361
{
360
362
common,
361
363
} ,
@@ -367,7 +369,7 @@ describe('[Block]: block functions', () => {
367
369
it ( 'should test toJSON' , ( ) => {
368
370
const common = new Common ( { chain : Mainnet , hardfork : Hardfork . Istanbul } )
369
371
const block = createBlockFromRLP (
370
- toBytes ( testdataPreLondon2Data . blocks [ 2 ] . rlp as PrefixedHexString ) ,
372
+ toBytes ( preLondonTestDataBlocks2 . blocks [ 2 ] . rlp as PrefixedHexString ) ,
371
373
{
372
374
common,
373
375
} ,
@@ -377,7 +379,7 @@ describe('[Block]: block functions', () => {
377
379
378
380
it ( 'DAO hardfork' , ( ) => {
379
381
const blockData = RLP . decode (
380
- testdataPreLondon2Data . blocks [ 0 ] . rlp as PrefixedHexString ,
382
+ preLondonTestDataBlocks2 . blocks [ 0 ] . rlp as PrefixedHexString ,
381
383
) as NestedUint8Array
382
384
// Set block number from test block to mainnet DAO fork block 1920000
383
385
blockData [ 0 ] [ 8 ] = hexToBytes ( '0x1D4C00' )
0 commit comments