Skip to content

test_basic_tload_transaction_begin()

Documentation for tests/cancun/eip1153_tstore/test_basic_tload.py::test_basic_tload_transaction_begin@f6ab9733.

Generate fixtures for these test cases for Cancun with:

Cancun only:

fill -v tests/cancun/eip1153_tstore/test_basic_tload.py::test_basic_tload_transaction_begin --fork=Cancun --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Cancun:

fill -v tests/cancun/eip1153_tstore/test_basic_tload.py::test_basic_tload_transaction_begin --until=Cancun

Ported .json vectors:

(01_tloadBeginningTxnFiller.yml) load arbitrary value is 0 at beginning of transaction

Source code in tests/cancun/eip1153_tstore/test_basic_tload.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@pytest.mark.valid_from("Cancun")
def test_basic_tload_transaction_begin(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """
    Ported .json vectors:

    (01_tloadBeginningTxnFiller.yml)
    load arbitrary value is 0 at beginning of transaction
    """
    slot_tload_at_transaction_begin_result = 1
    slot_code_worked = 2

    address_to = pre.deploy_contract(
        code=Op.JUMPDEST()
        # 01 test
        + Op.SSTORE(slot_tload_at_transaction_begin_result, Op.TLOAD(0))
        + Op.SSTORE(slot_code_worked, 1),
        storage={
            slot_tload_at_transaction_begin_result: 0xFF,
        },
    )

    post = {
        address_to: Account(
            storage={
                slot_tload_at_transaction_begin_result: 0x00,
                slot_code_worked: 0x01,
            }
        )
    }

    tx = Transaction(
        sender=pre.fund_eoa(7_000_000_000_000_000_000),
        to=address_to,
        gas_price=10,
        data=b"",
        gas_limit=5000000,
        value=0,
    )

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