mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-01 12:24:57 -05:00
Add multiple txs cases
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user