From 51e60c19d694b429868d3f2f5113b7fb24242702 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Tue, 18 Jul 2023 19:22:31 +0800 Subject: [PATCH] Add multiple txs cases --- .../eth2spec/test/deneb/sanity/test_blocks.py | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/deneb/sanity/test_blocks.py b/tests/core/pyspec/eth2spec/test/deneb/sanity/test_blocks.py index c64efe747..eecd7ad46 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/sanity/test_blocks.py +++ b/tests/core/pyspec/eth2spec/test/deneb/sanity/test_blocks.py @@ -24,13 +24,19 @@ from eth2spec.test.helpers.sharding import ( ) -def run_block_with_blobs(spec, state, blob_count, data_gas_used=1, excess_data_gas=1, valid=True): +def run_block_with_blobs(spec, state, blob_count, data_gas_used=1, excess_data_gas=1, valid=True, tx_count=1): yield 'pre', state block = build_empty_block_for_next_slot(spec, state) - opaque_tx, _, blob_kzg_commitments, _ = get_sample_opaque_tx(spec, blob_count=blob_count) + txs = [] + blob_kzg_commitments = [] + for _ in range(tx_count): + opaque_tx, _, commits, _ = get_sample_opaque_tx(spec, blob_count=blob_count) + txs.append(opaque_tx) + blob_kzg_commitments += commits + block.body.blob_kzg_commitments = blob_kzg_commitments - block.body.execution_payload.transactions = [opaque_tx] + block.body.execution_payload.transactions = txs block.body.execution_payload.data_gas_used = data_gas_used block.body.execution_payload.excess_data_gas = excess_data_gas block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload) @@ -56,12 +62,36 @@ def test_one_blob(spec, state): yield from run_block_with_blobs(spec, state, blob_count=1) +@with_deneb_and_later +@spec_state_test +def test_one_blob_two_txs(spec, state): + yield from run_block_with_blobs(spec, state, blob_count=1, tx_count=2) + + +@with_deneb_and_later +@spec_state_test +def test_one_blob_max_txs(spec, state): + yield from run_block_with_blobs(spec, state, blob_count=1, tx_count=spec.MAX_BLOBS_PER_BLOCK) + + +@with_deneb_and_later +@spec_state_test +def test_invalid_one_blob_max_plus_one_txs(spec, state): + yield from run_block_with_blobs(spec, state, blob_count=1, tx_count=spec.MAX_BLOBS_PER_BLOCK + 1, valid=False) + + @with_deneb_and_later @spec_state_test def test_max_blobs_per_block(spec, state): yield from run_block_with_blobs(spec, state, blob_count=spec.MAX_BLOBS_PER_BLOCK) +@with_deneb_and_later +@spec_state_test +def test_invalid_max_blobs_per_block_two_txs(spec, state): + yield from run_block_with_blobs(spec, state, blob_count=spec.MAX_BLOBS_PER_BLOCK, tx_count=2, valid=False) + + @with_deneb_and_later @spec_state_test def test_invalid_exceed_max_blobs_per_block(spec, state):