Skip to content

test_block_full_of_ether_transfers()

Documentation for tests/benchmark/test_worst_blocks.py::test_block_full_of_ether_transfers@0f7c73a7.

Generate fixtures for these test cases for Prague with:

fill -v tests/benchmark/test_worst_blocks.py::test_block_full_of_ether_transfers --fork Prague

Single test for ether transfer scenarios.

Scenarios: - a_to_a: one sender → one sender - a_to_b: one sender → one receiver - diff_acc_to_b: multiple senders → one receiver - a_to_diff_acc: one sender → multiple receivers - diff_acc_to_diff_acc: multiple senders → multiple receivers

Source code in tests/benchmark/test_worst_blocks.py
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
@pytest.mark.valid_from("Cancun")
@pytest.mark.parametrize(
    "case_id",
    ["a_to_a", "a_to_b", "diff_acc_to_b", "a_to_diff_acc", "diff_acc_to_diff_acc"],
)
def test_block_full_of_ether_transfers(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    case_id: str,
    ether_transfer_case,
    iteration_count: int,
    transfer_amount: int,
    intrinsic_cost: int,
):
    """
    Single test for ether transfer scenarios.

    Scenarios:
    - a_to_a: one sender → one sender
    - a_to_b: one sender → one receiver
    - diff_acc_to_b: multiple senders → one receiver
    - a_to_diff_acc: one sender → multiple receivers
    - diff_acc_to_diff_acc: multiple senders → multiple receivers
    """
    senders, receivers = ether_transfer_case

    # Create a single block with all transactions
    txs = []
    balances: dict[Address, int] = {}
    for _ in range(iteration_count):
        receiver = next(receivers)
        balances[receiver] = balances.get(receiver, 0) + transfer_amount
        txs.append(
            Transaction(
                to=receiver,
                value=transfer_amount,
                gas_limit=intrinsic_cost,
                sender=next(senders),
            )
        )

    # Only include post state for non a_to_a cases
    post_state = (
        {}
        if case_id == "a_to_a"
        else {receiver: Account(balance=balance) for receiver, balance in balances.items()}
    )

    blockchain_test(
        genesis_environment=Environment(),
        pre=pre,
        post=post_state,
        blocks=[Block(txs=txs)],
        exclude_full_post_state_in_output=True,
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) case_id
...fork_Cancun-blockchain_test-case_id_a_to_a a_to_a
...fork_Cancun-blockchain_test-case_id_a_to_b a_to_b
...fork_Cancun-blockchain_test-case_id_diff_acc_to_b diff_acc_to_b
...fork_Cancun-blockchain_test-case_id_a_to_diff_acc a_to_diff_acc
...fork_Cancun-blockchain_test-case_id_diff_acc_to_diff_acc diff_acc_to_diff_acc
...fork_Prague-blockchain_test-case_id_a_to_a a_to_a
...fork_Prague-blockchain_test-case_id_a_to_b a_to_b
...fork_Prague-blockchain_test-case_id_diff_acc_to_b diff_acc_to_b
...fork_Prague-blockchain_test-case_id_a_to_diff_acc a_to_diff_acc
...fork_Prague-blockchain_test-case_id_diff_acc_to_diff_acc diff_acc_to_diff_acc
...fork_Osaka-blockchain_test-case_id_a_to_a a_to_a
...fork_Osaka-blockchain_test-case_id_a_to_b a_to_b
...fork_Osaka-blockchain_test-case_id_diff_acc_to_b diff_acc_to_b
...fork_Osaka-blockchain_test-case_id_a_to_diff_acc a_to_diff_acc
...fork_Osaka-blockchain_test-case_id_diff_acc_to_diff_acc diff_acc_to_diff_acc