Skip to content

Test CHAINID

Documentation for tests/istanbul/eip1344_chainid/test_chainid.py.

Generate fixtures for these test cases with:

fill -v tests/istanbul/eip1344_chainid/test_chainid.py

abstract: Tests EIP-1344: CHAINID opcode

Test cases for [EIP-1344: CHAINID opcode](https://eips.ethereum.org/EIPS/eip-1344).

test_chainid(state_test)

Test CHAINID opcode.

Source code in tests/istanbul/eip1344_chainid/test_chainid.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@pytest.mark.valid_from("Istanbul")
def test_chainid(state_test: StateTestFiller):
    """
    Test CHAINID opcode.
    """
    env = Environment(
        coinbase="0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
        difficulty=0x20000,
        gas_limit=10000000000,
        number=1,
        timestamp=1000,
    )

    pre = {
        to_address(0x100): Account(code=Op.SSTORE(1, Op.CHAINID) + Op.STOP),
        TestAddress: Account(balance=1000000000000000000000),
    }

    tx = Transaction(
        ty=0x0,
        chain_id=0x01,
        nonce=0,
        to=to_address(0x100),
        gas_limit=100000000,
        gas_price=10,
    )

    post = {
        to_address(0x100): Account(code="0x4660015500", storage={"0x01": "0x01"}),
    }

    state_test(env=env, pre=pre, post=post, txs=[tx])