File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -1706,3 +1706,54 @@ def test_worst_calldataload(
1706
1706
post = {},
1707
1707
tx = tx ,
1708
1708
)
1709
+
1710
+
1711
+ @pytest .mark .parametrize (
1712
+ "opcode" ,
1713
+ [
1714
+ Op .SWAP1 ,
1715
+ Op .SWAP2 ,
1716
+ Op .SWAP3 ,
1717
+ Op .SWAP4 ,
1718
+ Op .SWAP5 ,
1719
+ Op .SWAP6 ,
1720
+ Op .SWAP7 ,
1721
+ Op .SWAP8 ,
1722
+ Op .SWAP9 ,
1723
+ Op .SWAP10 ,
1724
+ Op .SWAP11 ,
1725
+ Op .SWAP12 ,
1726
+ Op .SWAP13 ,
1727
+ Op .SWAP14 ,
1728
+ Op .SWAP15 ,
1729
+ Op .SWAP16 ,
1730
+ ],
1731
+ )
1732
+ def test_worst_swap (
1733
+ state_test : StateTestFiller ,
1734
+ pre : Alloc ,
1735
+ fork : Fork ,
1736
+ opcode : Opcode ,
1737
+ ):
1738
+ """Test running a block with as many SWAP as possible."""
1739
+ env = Environment ()
1740
+ max_code_size = fork .max_code_size ()
1741
+
1742
+ code_prefix = Op .JUMPDEST + Op .PUSH0 * opcode .min_stack_height
1743
+ code_suffix = Op .PUSH0 + Op .JUMP
1744
+ opcode_sequence = opcode * (max_code_size - len (code_prefix ) - len (code_suffix ))
1745
+ code = code_prefix + opcode_sequence + code_suffix
1746
+ assert len (code ) <= max_code_size
1747
+
1748
+ tx = Transaction (
1749
+ to = pre .deploy_contract (code = code ),
1750
+ gas_limit = env .gas_limit ,
1751
+ sender = pre .fund_eoa (),
1752
+ )
1753
+
1754
+ state_test (
1755
+ env = env ,
1756
+ pre = pre ,
1757
+ post = {},
1758
+ tx = tx ,
1759
+ )
You can’t perform that action at this time.
0 commit comments