Rename transaction to operation in tests
This commit is contained in:
parent
77b0a4188b
commit
93540f9662
|
@ -22,31 +22,31 @@ def expected_deposit_count(state: BeaconState) -> int:
|
|||
)
|
||||
|
||||
|
||||
def process_transaction_type(state: BeaconState,
|
||||
transactions: List[Any],
|
||||
max_transactions: int,
|
||||
def process_operation_type(state: BeaconState,
|
||||
operations: List[Any],
|
||||
max_operations: int,
|
||||
tx_fn: Callable[[BeaconState, Any], None]) -> None:
|
||||
assert len(transactions) <= max_transactions
|
||||
for transaction in transactions:
|
||||
tx_fn(state, transaction)
|
||||
assert len(operations) <= max_operations
|
||||
for operation in operations:
|
||||
tx_fn(state, operation)
|
||||
|
||||
|
||||
def process_transactions(state: BeaconState, block: BeaconBlock) -> None:
|
||||
process_transaction_type(
|
||||
def process_operations(state: BeaconState, block: BeaconBlock) -> None:
|
||||
process_operation_type(
|
||||
state,
|
||||
block.body.proposer_slashings,
|
||||
spec.MAX_PROPOSER_SLASHINGS,
|
||||
spec.process_proposer_slashing,
|
||||
)
|
||||
|
||||
process_transaction_type(
|
||||
process_operation_type(
|
||||
state,
|
||||
block.body.attester_slashings,
|
||||
spec.MAX_ATTESTER_SLASHINGS,
|
||||
spec.process_attester_slashing,
|
||||
)
|
||||
|
||||
process_transaction_type(
|
||||
process_operation_type(
|
||||
state,
|
||||
block.body.attestations,
|
||||
spec.MAX_ATTESTATIONS,
|
||||
|
@ -54,14 +54,14 @@ def process_transactions(state: BeaconState, block: BeaconBlock) -> None:
|
|||
)
|
||||
|
||||
assert len(block.body.deposits) == expected_deposit_count(state)
|
||||
process_transaction_type(
|
||||
process_operation_type(
|
||||
state,
|
||||
block.body.deposits,
|
||||
spec.MAX_DEPOSITS,
|
||||
spec.process_deposit,
|
||||
)
|
||||
|
||||
process_transaction_type(
|
||||
process_operation_type(
|
||||
state,
|
||||
block.body.voluntary_exits,
|
||||
spec.MAX_VOLUNTARY_EXITS,
|
||||
|
@ -69,7 +69,7 @@ def process_transactions(state: BeaconState, block: BeaconBlock) -> None:
|
|||
)
|
||||
|
||||
assert len(block.body.transfers) == len(set(block.body.transfers))
|
||||
process_transaction_type(
|
||||
process_operation_type(
|
||||
state,
|
||||
block.body.transfers,
|
||||
spec.MAX_TRANSFERS,
|
||||
|
@ -84,7 +84,7 @@ def process_block(state: BeaconState,
|
|||
spec.process_randao(state, block)
|
||||
spec.process_eth1_data(state, block)
|
||||
|
||||
process_transactions(state, block)
|
||||
process_operations(state, block)
|
||||
if verify_state_root:
|
||||
spec.verify_block_state_root(state, block)
|
||||
|
||||
|
|
Loading…
Reference in New Issue