Skip to content

Commit

Permalink
organize test util code
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Jan 3, 2022
1 parent ee2f397 commit 5d2dc60
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/block/test/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Common, { Chain } from '@ethereumjs/common'
import Common, { Chain, Hardfork } from '@ethereumjs/common'
import { BN, rlp, keccak256 } from 'ethereumjs-util'
import { Block, BlockHeader } from '../src'

Expand All @@ -21,10 +21,13 @@ function createBlock(
throw new Error('extra data graffiti must be 32 bytes or less')
}

const londonHfBlock = common.hardforkBlockBN('london')
const number = parentBlock.header.number.addn(1)
const timestamp = parentBlock.header.timestamp.addn(1)

const londonHfBlock = common.hardforkBlockBN(Hardfork.London)
const baseFeePerGas =
londonHfBlock && number.gt(londonHfBlock) ? parentBlock.header.calcNextBaseFee() : undefined

return Block.fromBlockData(
{
header: {
Expand All @@ -34,10 +37,7 @@ function createBlock(
gasLimit: new BN(5000),
extraData: Buffer.from(extraData),
uncleHash: keccak256(rlp.encode(uncles.map((uh) => uh.raw()))),
baseFeePerGas:
londonHfBlock && number.gt(londonHfBlock)
? parentBlock.header.calcNextBaseFee()
: undefined,
baseFeePerGas,
},
uncleHeaders: uncles,
},
Expand Down

0 comments on commit 5d2dc60

Please sign in to comment.