Skip to content

Commit f21d975

Browse files
committed
compress mstore and args_size into calldata
1 parent bf94904 commit f21d975

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

tests/frontier/opcodes/test_calldataload.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,31 @@
44

55
from ethereum_test_forks import Byzantium, Fork
66
from ethereum_test_tools import Account, Alloc, Bytecode, StateTestFiller, Transaction
7+
from ethereum_test_tools import Macros as Om
78
from ethereum_test_tools.vm.opcode import Opcodes as Op
89

910

1011
@pytest.mark.parametrize(
11-
"mstore,args_size,calldata_offset,tx_data,address_a_storage",
12+
"calldata,calldata_offset,tx_data,address_a_storage",
1213
[
1314
(
14-
(Op.MSTORE8(offset=0x0, value=0x25) + Op.MSTORE8(offset=0x1, value=0x60)),
15-
0x2,
15+
b"\x25\x60",
1616
0x0,
1717
b"\x00",
1818
Account(
1919
storage={0x00: 0x2560000000000000000000000000000000000000000000000000000000000000}
2020
),
2121
),
2222
(
23-
(
24-
Op.MSTORE(
25-
offset=0x0,
26-
value=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,
27-
)
28-
+ Op.MSTORE8(offset=0x20, value=0x23)
29-
),
30-
0x21,
23+
b"\xff" * 32 + b"\x23",
3124
0x1,
3225
b"\x01",
3326
Account(
3427
storage={0x00: 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF23}
3528
),
3629
),
3730
(
38-
(
39-
Op.MSTORE(
40-
offset=0x0,
41-
value=0x123456789ABCDEF0000000000000000000000000000000000000000000000000,
42-
)
43-
+ Op.MSTORE8(offset=0x20, value=0x0)
44-
+ Op.MSTORE8(offset=0x21, value=0x24)
45-
),
46-
0x22,
31+
bytes.fromhex("123456789ABCDEF00000000000000000000000000000000000000000000000000024"),
4732
0x5,
4833
b"\x02",
4934
Account(
@@ -59,8 +44,7 @@
5944
)
6045
def test_calldataload(
6146
state_test: StateTestFiller,
62-
mstore: Bytecode,
63-
args_size: int,
47+
calldata: bytes,
6448
calldata_offset: int,
6549
fork: Fork,
6650
tx_data: bytes,
@@ -77,13 +61,13 @@ def test_calldataload(
7761
)
7862

7963
address_b = pre.deploy_contract(
80-
mstore
64+
Om.MSTORE(calldata, 0x0)
8165
+ Op.CALL(
8266
gas=Op.SUB(Op.GAS(), 0x100),
8367
address=address_a,
8468
value=0x0,
8569
args_offset=0x0,
86-
args_size=args_size,
70+
args_size=len(calldata),
8771
ret_offset=0x0,
8872
ret_size=0x0,
8973
)

0 commit comments

Comments
 (0)