Skip to content

test_beacon_root_selfdestruct()

Documentation for tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_beacon_root_selfdestruct@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

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

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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
@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,
) -> None:
    """
    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