Skip to content

test_beacon_root_selfdestruct()

Documentation for tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_beacon_root_selfdestruct@008e492e.

Generate fixtures for these test cases for Prague with:

fill -v tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_beacon_root_selfdestruct --fork Prague

Tests that self destructing the beacon root address transfers actors balance correctly.

Source code in tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
@pytest.mark.parametrize("timestamp", [12])
@pytest.mark.valid_from("Cancun")
def test_beacon_root_selfdestruct(
    blockchain_test: BlockchainTestFiller,
    beacon_root: bytes,
    timestamp: int,
    pre: Alloc,
    tx: Transaction,
    post: Dict,
):
    """Tests that self destructing the beacon root address transfers actors balance correctly."""
    # self destruct actor
    self_destruct_actor_address = pre.deploy_contract(
        Op.SELFDESTRUCT(Spec.BEACON_ROOTS_ADDRESS),
        balance=0xBA1,
    )
    # self destruct caller
    self_destruct_caller_address = pre.deploy_contract(
        Op.CALL(gas=100_000, address=self_destruct_actor_address)
        + Op.SSTORE(0, Op.BALANCE(Spec.BEACON_ROOTS_ADDRESS))
    )
    post = {
        self_destruct_caller_address: Account(
            storage=Storage({0: 0xBA1}),  # type: ignore
        )
    }
    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=[
                    Transaction(
                        sender=pre.fund_eoa(),
                        to=self_destruct_caller_address,
                        gas_limit=100_000,
                    )
                ]
            )
        ],
        post=post,
    )

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated) timestamp
...fork_Cancun-blockchain_test-timestamp_12 12
...fork_Prague-blockchain_test-timestamp_12 12
...fork_Osaka-blockchain_test-timestamp_12 12