Skip to content

test_chainid()

Documentation for tests/istanbul/eip1344_chainid/test_chainid.py::test_chainid@verkle@v0.0.5.

Generate fixtures for these test cases for Istanbul with:

Istanbul only:

fill -v tests/istanbul/eip1344_chainid/test_chainid.py::test_chainid --fork=Istanbul --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Istanbul:

fill -v tests/istanbul/eip1344_chainid/test_chainid.py::test_chainid --until=Istanbul

Test CHAINID opcode.

Source code in tests/istanbul/eip1344_chainid/test_chainid.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@pytest.mark.valid_from("Istanbul")
def test_chainid(state_test: StateTestFiller, pre: Alloc):
    """
    Test CHAINID opcode.
    """
    env = Environment(
        fee_recipient="0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
        difficulty=0x20000,
        gas_limit=10000000000,
        number=1,
        timestamp=1000,
    )

    contract_address = pre.deploy_contract(Op.SSTORE(1, Op.CHAINID) + Op.STOP)
    sender = pre.fund_eoa()

    tx = Transaction(
        ty=0x0,
        chain_id=0x01,
        to=contract_address,
        gas_limit=100000000,
        gas_price=10,
        sender=sender,
    )

    post = {
        contract_address: Account(storage={"0x01": "0x01"}),
    }

    state_test(env=env, pre=pre, post=post, tx=tx)