Skip to content

Commit b1bae17

Browse files
committed
Fix vm api tests
1 parent 676b93b commit b1bae17

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

packages/block/test/eip7685block.spec.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
22
import {
3+
CLRequestType,
34
KECCAK256_RLP,
45
SHA256_NULL,
56
bytesToBigInt,
6-
createDepositRequest,
7+
createCLRequest,
78
createWithdrawalRequest,
89
randomBytes,
910
} from '@ethereumjs/util'
10-
import { sha256 } from 'ethereum-cryptography/keccak.js'
11+
import { sha256 } from 'ethereum-cryptography/sha256.js'
1112
import { assert, describe, expect, it } from 'vitest'
1213

1314
import { genRequestsRoot } from '../src/helpers.js'
@@ -20,7 +21,7 @@ import {
2021
} from '../src/index.js'
2122

2223
import type { JSONRPCBlock } from '../src/index.js'
23-
import type { CLRequest, CLRequestType } from '@ethereumjs/util'
24+
import type { CLRequest } from '@ethereumjs/util'
2425

2526
function getRandomDepositRequest(): CLRequest<CLRequestType> {
2627
const depositRequestData = {
@@ -30,7 +31,17 @@ function getRandomDepositRequest(): CLRequest<CLRequestType> {
3031
signature: randomBytes(96),
3132
index: randomBytes(8),
3233
}
33-
return createDepositRequest(depositRequestData) as CLRequest<CLRequestType>
34+
// return createDepositRequest(depositRequestData) as CLRequest<CLRequestType>
35+
36+
// flatten request bytes as per EIP-7685
37+
const depositRequestBytes = new Uint8Array(
38+
Object.values(depositRequestData)
39+
.map((arr) => Array.from(arr)) // Convert Uint8Arrays to regular arrays
40+
.reduce((acc, curr) => acc.concat(curr), []), // Concatenate arrays
41+
)
42+
return createCLRequest(
43+
new Uint8Array([CLRequestType.Deposit, ...depositRequestBytes]),
44+
) as CLRequest<CLRequestType.Deposit>
3445
}
3546

3647
function getRandomWithdrawalRequest(): CLRequest<CLRequestType> {

packages/vm/test/api/EIPs/eip-2935-historical-block-hashes.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ describe('EIP 2935: historical block hashes', () => {
182182
timestamp: 1,
183183
})
184184
const genesis = (await vm.blockchain.getBlock(0)) as Block
185-
const block = await (
185+
const { block } = await (
186186
await buildBlock(vm, {
187187
parentBlock: genesis,
188188
blockOpts: {
@@ -220,7 +220,7 @@ describe('EIP 2935: historical block hashes', () => {
220220
await vm.stateManager.putCode(historyAddress, contract2935Code)
221221
let lastBlock = (await vm.blockchain.getBlock(0)) as Block
222222
for (let i = 1; i <= blocksToBuild; i++) {
223-
lastBlock = await (
223+
const buildResult = await (
224224
await buildBlock(vm, {
225225
parentBlock: lastBlock,
226226
blockOpts: {
@@ -232,6 +232,7 @@ describe('EIP 2935: historical block hashes', () => {
232232
},
233233
})
234234
).build()
235+
lastBlock = buildResult.block
235236
await vm.blockchain.putBlock(lastBlock)
236237
await runBlock(vm, {
237238
block: lastBlock,

packages/vm/test/api/EIPs/eip-4844-blobs.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('EIP4844 tests', () => {
8282

8383
await blockBuilder.addTransaction(signedTx)
8484

85-
const block = await blockBuilder.build()
85+
const { block } = await blockBuilder.build()
8686
assert.equal(block.transactions.length, 1, 'blob transaction should be included')
8787
assert.equal(
8888
bytesToHex(block.transactions[0].hash()),

packages/vm/test/api/EIPs/eip-4895-withdrawals.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ describe('EIP4895 tests', () => {
226226
},
227227
})
228228

229-
const block = await blockBuilder.build()
229+
const { block } = await blockBuilder.build()
230230

231231
assert.equal(
232232
bytesToHex(block.header.stateRoot),

0 commit comments

Comments
 (0)