Skip to content

Commit

Permalink
increase spec coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed May 21, 2023
1 parent 255790e commit aa399e3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/block/test/from-beacon-payload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tape('[fromExecutionPayloadJson]: 4844 devnet 5', async function (t) {
for (const payload of [payload87335, payload87475]) {
try {
const block = await Block.fromBeaconPayloadJson(payload, { common })
block.validateBlobTransactions({ excessDataGas: BigInt(0), _common: common } as any)
st.pass(`successfully constructed block=${block.header.number}`)
} catch (e) {
st.fail(`failed to construct block, error: ${e}`)
Expand All @@ -30,6 +31,7 @@ tape('[fromExecutionPayloadJson]: 4844 devnet 5', async function (t) {

t.test('should validate block hash', async function (st) {
try {
// construct a payload with differing block hash
await Block.fromBeaconPayloadJson(
{ ...payload87335, block_hash: payload87475.block_hash },
{ common }
Expand All @@ -40,4 +42,23 @@ tape('[fromExecutionPayloadJson]: 4844 devnet 5', async function (t) {
st.ok(`${e}`.includes('Invalid blockHash'), 'failed with correct error')
}
})

t.test('should validate excess data gas', async function (st) {
try {
// construct a payload with a different excess data gas but matching hash
const block = await Block.fromBeaconPayloadJson(
{
...payload87475,
excess_data_gas: payload87335.excess_data_gas,
block_hash: '0x506ff15910ef7c5a713b21f225b3ffb4bfb4aeea4ea4891e3a71c0ad7bf6a8e0',
},
{ common }
)
block.validateBlobTransactions({ excessDataGas: BigInt(0), _common: common } as any)
st.fail(`should have failed constructing the block`)
} catch (e) {
st.pass(`correctly failed constructing block, error: ${e}`)
st.ok(`${e}`.includes('block excessDataGas mismatch'), 'failed with correct error')
}
})
})

0 comments on commit aa399e3

Please sign in to comment.