Skip to content

test_beacon_root_selfdestruct()

Documentation for tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_beacon_root_selfdestruct@verkle@v0.0.6.

Generate fixtures for these test cases for Cancun with:

Cancun only:

fill -v tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_beacon_root_selfdestruct --fork=Cancun --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Cancun:

fill -v tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_beacon_root_selfdestruct --until=Cancun

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
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
294
295
296
297
298
299
@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

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

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID timestamp
timestamp_12 12