|
3 | 3 | import rlp
|
4 | 4 |
|
5 | 5 | from eth_utils import (
|
| 6 | + to_tuple, |
6 | 7 | ValidationError,
|
7 | 8 | )
|
8 | 9 |
|
|
24 | 25 | genesis_params_from_fixture,
|
25 | 26 | load_fixture,
|
26 | 27 | new_chain_from_fixture,
|
| 28 | + should_run_slow_tests, |
27 | 29 | verify_account_db,
|
28 | 30 | )
|
29 | 31 |
|
|
34 | 36 | BASE_FIXTURE_PATH = os.path.join(ROOT_PROJECT_DIR, 'fixtures', 'BlockchainTests')
|
35 | 37 |
|
36 | 38 |
|
| 39 | +# These are the slowest tests from the full blockchain test run. This list |
| 40 | +# should be regenerated occasionally using `--durations 100`. |
| 41 | +SLOWEST_TESTS = { |
| 42 | + ('GeneralStateTests/stStaticCall/static_Call50000_sha256_d0g0v0.json', 'static_Call50000_sha256_d0g0v0_Byzantium'), # noqa: E501 |
| 43 | + ('GeneralStateTests/stStaticCall/static_Call50000_sha256_d1g0v0.json', 'static_Call50000_sha256_d1g0v0_Byzantium'), # noqa: E501 |
| 44 | + ('GeneralStateTests/stStaticCall/static_Call50000_rip160_d0g0v0.json', 'static_Call50000_rip160_d0g0v0_Byzantium'), # noqa: E501 |
| 45 | + ('GeneralStateTests/stStaticCall/static_Call50000_d1g0v0.json', 'static_Call50000_d1g0v0_Byzantium'), # noqa: E501 |
| 46 | + ('GeneralStateTests/stStaticCall/static_Call50000_ecrec_d1g0v0.json', 'static_Call50000_ecrec_d1g0v0_Byzantium'), # noqa: E501 |
| 47 | + ('GeneralStateTests/stStaticCall/static_Call50000_rip160_d1g0v0.json', 'static_Call50000_rip160_d1g0v0_Byzantium'), # noqa: E501 |
| 48 | + ('GeneralStateTests/stStaticCall/static_Call50000_identity2_d1g0v0.json', 'static_Call50000_identity2_d1g0v0_Byzantium'), # noqa: E501 |
| 49 | + ('GeneralStateTests/stStaticCall/static_Call50000_identity_d1g0v0.json', 'static_Call50000_identity_d1g0v0_Byzantium'), # noqa: E501 |
| 50 | + ('GeneralStateTests/stStaticCall/static_Return50000_2_d0g0v0.json', 'static_Return50000_2_d0g0v0_Byzantium'), # noqa: E501 |
| 51 | + ('GeneralStateTests/stStaticCall/static_Call50000_d0g0v0.json', 'static_Call50000_d0g0v0_Byzantium'), # noqa: E501 |
| 52 | + ('GeneralStateTests/stStaticCall/static_Call50000bytesContract50_1_d1g0v0.json', 'static_Call50000bytesContract50_1_d1g0v0_Byzantium'), # noqa: E501 |
| 53 | + ('GeneralStateTests/stStaticCall/static_Call50000bytesContract50_2_d1g0v0.json', 'static_Call50000bytesContract50_2_d1g0v0_Byzantium'), # noqa: E501 |
| 54 | + ('GeneralStateTests/stChangedEIP150/Call1024PreCalls_d0g0v0.json', 'Call1024PreCalls_d0g0v0_Byzantium'), # noqa: E501 |
| 55 | + ('GeneralStateTests/stChangedEIP150/Call1024PreCalls_d0g0v0.json', 'Call1024PreCalls_d0g0v0_EIP150'), # noqa: E501 |
| 56 | + ('GeneralStateTests/stDelegatecallTestHomestead/Call1024PreCalls_d0g0v0.json', 'Call1024PreCalls_d0g0v0_Byzantium'), # noqa: E501 |
| 57 | + ('GeneralStateTests/stStaticCall/static_Call50000_ecrec_d0g0v0.json', 'static_Call50000_ecrec_d0g0v0_Byzantium'), # noqa: E501 |
| 58 | + ('GeneralStateTests/stAttackTest/ContractCreationSpam_d0g0v0.json', 'ContractCreationSpam_d0g0v0_Frontier'), # noqa: E501 |
| 59 | + ('GeneralStateTests/stAttackTest/ContractCreationSpam_d0g0v0.json', 'ContractCreationSpam_d0g0v0_Homestead'), # noqa: E501 |
| 60 | + ('GeneralStateTests/stCallCreateCallCodeTest/Call1024PreCalls_d0g0v0.json', 'Call1024PreCalls_d0g0v0_Byzantium'), # noqa: E501 |
| 61 | + ('GeneralStateTests/stStaticCall/static_Call1024PreCalls2_d0g0v0.json', 'static_Call1024PreCalls2_d0g0v0_Byzantium'), # noqa: E501 |
| 62 | + ('GeneralStateTests/stStaticCall/static_Call50000_identity2_d0g0v0.json', 'static_Call50000_identity2_d0g0v0_Byzantium'), # noqa: E501 |
| 63 | + ('GeneralStateTests/stStaticCall/static_Call50000_identity_d0g0v0.json', 'static_Call50000_identity_d0g0v0_Byzantium'), # noqa: E501 |
| 64 | + ('GeneralStateTests/stRecursiveCreate/recursiveCreateReturnValue_d0g0v0.json', 'recursiveCreateReturnValue_d0g0v0_Homestead'), # noqa: E501 |
| 65 | + ('GeneralStateTests/stStaticCall/static_LoopCallsThenRevert_d0g0v0.json', 'static_LoopCallsThenRevert_d0g0v0_Byzantium'), # noqa: E501 |
| 66 | + ('GeneralStateTests/stCallCreateCallCodeTest/Callcode1024OOG_d0g0v0.json', 'Callcode1024OOG_d0g0v0_Frontier'), # noqa: E501 |
| 67 | + ('GeneralStateTests/stStaticCall/static_LoopCallsThenRevert_d0g1v0.json', 'static_LoopCallsThenRevert_d0g1v0_Byzantium'), # noqa: E501 |
| 68 | + ('GeneralStateTests/stStaticCall/static_Call1024PreCalls3_d1g0v0.json', 'static_Call1024PreCalls3_d1g0v0_Byzantium'), # noqa: E501 |
| 69 | + ('GeneralStateTests/stStaticCall/static_Call1024PreCalls_d1g0v0.json', 'static_Call1024PreCalls_d1g0v0_Byzantium'), # noqa: E501 |
| 70 | + ('GeneralStateTests/stStaticCall/static_Call1024PreCalls2_d1g0v0.json', 'static_Call1024PreCalls2_d1g0v0_Byzantium'), # noqa: E501 |
| 71 | + ('GeneralStateTests/stDelegatecallTestHomestead/Delegatecall1024OOG_d0g0v0.json', 'Delegatecall1024OOG_d0g0v0_Homestead'), # noqa: E501 |
| 72 | + ('GeneralStateTests/stChangedEIP150/Call1024BalanceTooLow_d0g0v0.json', 'Call1024BalanceTooLow_d0g0v0_Byzantium'), # noqa: E501 |
| 73 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBombLog_d0g0v0.json', 'CallRecursiveBombLog_d0g0v0_Frontier'), # noqa: E501 |
| 74 | + ('GeneralStateTests/stChangedEIP150/Callcode1024BalanceTooLow_d0g0v0.json', 'Callcode1024BalanceTooLow_d0g0v0_Byzantium'), # noqa: E501 |
| 75 | + ('bcForkStressTest/ForkStressTest.json', 'ForkStressTest_Frontier'), # noqa: E501 |
| 76 | + ('bcForkStressTest/ForkStressTest.json', 'ForkStressTest_Byzantium'), # noqa: E501 |
| 77 | + ('GeneralStateTests/stCallCreateCallCodeTest/Call1024OOG_d0g0v0.json', 'Call1024OOG_d0g0v0_Frontier'), # noqa: E501 |
| 78 | + ('GeneralStateTests/stDelegatecallTestHomestead/Call1024OOG_d0g0v0.json', 'Call1024OOG_d0g0v0_Homestead'), # noqa: E501 |
| 79 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBomb0_OOG_atMaxCallDepth_d0g0v0.json', 'CallRecursiveBomb0_OOG_atMaxCallDepth_d0g0v0_Homestead'), # noqa: E501 |
| 80 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBombLog_d0g0v0.json', 'CallRecursiveBombLog_d0g0v0_Homestead'), # noqa: E501 |
| 81 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBomb1_d0g0v0.json', 'CallRecursiveBomb1_d0g0v0_Frontier'), # noqa: E501 |
| 82 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBombLog2_d0g0v0.json', 'CallRecursiveBombLog2_d0g0v0_Homestead'), # noqa: E501 |
| 83 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBomb0_OOG_atMaxCallDepth_d0g0v0.json', 'CallRecursiveBomb0_OOG_atMaxCallDepth_d0g0v0_Frontier'), # noqa: E501 |
| 84 | + ('GeneralStateTests/stCallCreateCallCodeTest/Call1024BalanceTooLow_d0g0v0.json', 'Call1024BalanceTooLow_d0g0v0_Byzantium'), # noqa: E501 |
| 85 | + ('GeneralStateTests/stChangedEIP150/Call1024BalanceTooLow_d0g0v0.json', 'Call1024BalanceTooLow_d0g0v0_EIP150'), # noqa: E501 |
| 86 | + ('bcForkStressTest/ForkStressTest.json', 'ForkStressTest_EIP150'), # noqa: E501 |
| 87 | + ('GeneralStateTests/stDelegatecallTestHomestead/CallRecursiveBombPreCall_d0g0v0.json', 'CallRecursiveBombPreCall_d0g0v0_Byzantium'), # noqa: E501 |
| 88 | + ('GeneralStateTests/stChangedEIP150/Callcode1024BalanceTooLow_d0g0v0.json', 'Callcode1024BalanceTooLow_d0g0v0_EIP150'), # noqa: E501 |
| 89 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBomb1_d0g0v0.json', 'CallRecursiveBomb1_d0g0v0_Homestead'), # noqa: E501 |
| 90 | + ('GeneralStateTests/stDelegatecallTestHomestead/CallRecursiveBombPreCall_d0g0v0.json', 'CallRecursiveBombPreCall_d0g0v0_Homestead'), # noqa: E501 |
| 91 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBomb2_d0g0v0.json', 'CallRecursiveBomb2_d0g0v0_Homestead'), # noqa: E501 |
| 92 | + ('GeneralStateTests/stCallCreateCallCodeTest/Callcode1024BalanceTooLow_d0g0v0.json', 'Callcode1024BalanceTooLow_d0g0v0_Byzantium'), # noqa: E501 |
| 93 | + ('GeneralStateTests/stSystemOperationsTest/ABAcalls2_d0g0v0.json', 'ABAcalls2_d0g0v0_Frontier'), # noqa: E501 |
| 94 | + ('GeneralStateTests/stDelegatecallTestHomestead/Delegatecall1024_d0g0v0.json', 'Delegatecall1024_d0g0v0_Byzantium'), # noqa: E501 |
| 95 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBombLog2_d0g0v0.json', 'CallRecursiveBombLog2_d0g0v0_Frontier'), # noqa: E501 |
| 96 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBomb2_d0g0v0.json', 'CallRecursiveBomb2_d0g0v0_Frontier'), # noqa: E501 |
| 97 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBomb0_OOG_atMaxCallDepth_d0g0v0.json', 'CallRecursiveBomb0_OOG_atMaxCallDepth_d0g0v0_EIP150'), # noqa: E501 |
| 98 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBomb0_d0g0v0.json', 'CallRecursiveBomb0_d0g0v0_Frontier'), # noqa: E501 |
| 99 | + ('GeneralStateTests/stDelegatecallTestHomestead/Call1024BalanceTooLow_d0g0v0.json', 'Call1024BalanceTooLow_d0g0v0_Byzantium'), # noqa: E501 |
| 100 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBomb0_d0g0v0.json', 'CallRecursiveBomb0_d0g0v0_Homestead'), # noqa: E501 |
| 101 | + ('GeneralStateTests/stStaticCall/static_Call50000bytesContract50_1_d0g0v0.json', 'static_Call50000bytesContract50_1_d0g0v0_Byzantium'), # noqa: E501 |
| 102 | + ('GeneralStateTests/stDelegatecallTestHomestead/Delegatecall1024_d0g0v0.json', 'Delegatecall1024_d0g0v0_EIP150'), # noqa: E501 |
| 103 | + ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBomb0_OOG_atMaxCallDepth_d0g0v0.json', 'CallRecursiveBomb0_OOG_atMaxCallDepth_d0g0v0_Byzantium'), # noqa: E501 |
| 104 | + ('GeneralStateTests/stCallCreateCallCodeTest/CallRecursiveBombPreCall_d0g0v0.json', 'CallRecursiveBombPreCall_d0g0v0_Byzantium'), # noqa: E501 |
| 105 | + ('GeneralStateTests/stSystemOperationsTest/ABAcalls1_d0g0v0.json', 'ABAcalls1_d0g0v0_Frontier'), # noqa: E501 |
| 106 | + ('GeneralStateTests/stCallCreateCallCodeTest/CallRecursiveBombPreCall_d0g0v0.json', 'CallRecursiveBombPreCall_d0g0v0_Frontier'), # noqa: E501 |
| 107 | + ('GeneralStateTests/stStaticCall/static_Call1MB1024Calldepth_d1g0v0.json', 'static_Call1MB1024Calldepth_d1g0v0_Byzantium'), # noqa: E501 |
| 108 | + ('GeneralStateTests/stRevertTest/LoopCallsDepthThenRevert2_d0g0v0.json', 'LoopCallsDepthThenRevert2_d0g0v0_Byzantium'), # noqa: E501 |
| 109 | + ('GeneralStateTests/stSystemOperationsTest/ABAcalls2_d0g0v0.json', 'ABAcalls2_d0g0v0_Homestead'), # noqa: E501 |
| 110 | + ('GeneralStateTests/stStaticCall/static_Call50000bytesContract50_2_d0g0v0.json', 'static_Call50000bytesContract50_2_d0g0v0_Byzantium'), # noqa: E501 |
| 111 | + ('GeneralStateTests/stRevertTest/LoopCallsDepthThenRevert2_d0g0v0.json', 'LoopCallsDepthThenRevert2_d0g0v0_EIP158'), # noqa: E501 |
| 112 | + ('GeneralStateTests/stRevertTest/LoopCallsDepthThenRevert3_d0g0v0.json', 'LoopCallsDepthThenRevert3_d0g0v0_EIP158'), # noqa: E501 |
| 113 | + ('GeneralStateTests/stRevertTest/LoopCallsDepthThenRevert3_d0g0v0.json', 'LoopCallsDepthThenRevert3_d0g0v0_Byzantium'), # noqa: E501 |
| 114 | +} |
| 115 | + |
| 116 | + |
37 | 117 | # These are tests that are thought to be incorrect or buggy upstream,
|
38 | 118 | # at the commit currently checked out in submodule `fixtures`.
|
39 | 119 | # Ideally, this list should be empty.
|
|
48 | 128 | }
|
49 | 129 |
|
50 | 130 |
|
51 |
| -def blockchain_fixture_mark_fn(fixture_path, fixture_name): |
| 131 | +def blockchain_fixture_mark_fn(fixture_path, fixture_name, fixture_fork): |
| 132 | + fixture_id = (fixture_path, fixture_name) |
| 133 | + |
52 | 134 | if fixture_path.startswith('bcExploitTest'):
|
53 | 135 | return pytest.mark.skip("Exploit tests are slow")
|
54 | 136 | elif fixture_path == 'bcWalletTest/walletReorganizeOwners.json':
|
55 | 137 | return pytest.mark.skip("Wallet owner reorganization tests are slow")
|
56 |
| - elif (fixture_path, fixture_name) in INCORRECT_UPSTREAM_TESTS: |
| 138 | + elif fixture_id in INCORRECT_UPSTREAM_TESTS: |
57 | 139 | return pytest.mark.xfail(reason="Listed in INCORRECT_UPSTREAM_TESTS.")
|
| 140 | + elif 'stTransactionTest/zeroSigTransa' in fixture_path: |
| 141 | + return pytest.mark.skip("EIP-86 not supported.") |
| 142 | + elif fixture_id in SLOWEST_TESTS: |
| 143 | + if should_run_slow_tests(): |
| 144 | + return |
| 145 | + else: |
| 146 | + return pytest.mark.skip("Skipping slow test") |
| 147 | + elif 'stQuadraticComplexityTest' in fixture_path: |
| 148 | + return pytest.mark.skip("Skipping slow test") |
| 149 | + |
| 150 | + |
| 151 | +def generate_ignore_fn_for_fork(passed_fork): |
| 152 | + if passed_fork: |
| 153 | + passed_fork = passed_fork.lower() |
| 154 | + |
| 155 | + def ignore_fn(fixture_path, fixture_key, fixture_fork): |
| 156 | + return fixture_fork.lower() != passed_fork |
| 157 | + |
| 158 | + return ignore_fn |
58 | 159 |
|
59 | 160 |
|
60 |
| -def blockchain_fixture_ignore_fn(fixture_path, fixture_name): |
61 |
| - if fixture_path.startswith('GeneralStateTests'): |
62 |
| - # General state tests are also exported as blockchain tests. We |
63 |
| - # skip them here so we don't run them twice |
64 |
| - return True |
| 161 | +@to_tuple |
| 162 | +def expand_fixtures_forks(all_fixtures): |
| 163 | + for fixture_path, fixture_key in all_fixtures: |
| 164 | + fixture = load_fixture(fixture_path, fixture_key) |
| 165 | + yield fixture_path, fixture_key, fixture['network'] |
65 | 166 |
|
66 | 167 |
|
67 | 168 | def pytest_generate_tests(metafunc):
|
| 169 | + fork = metafunc.config.getoption('fork') |
68 | 170 | generate_fixture_tests(
|
69 | 171 | metafunc=metafunc,
|
70 | 172 | base_fixture_path=BASE_FIXTURE_PATH,
|
| 173 | + preprocess_fn=expand_fixtures_forks, |
71 | 174 | filter_fn=filter_fixtures(
|
72 | 175 | fixtures_base_dir=BASE_FIXTURE_PATH,
|
73 | 176 | mark_fn=blockchain_fixture_mark_fn,
|
74 |
| - ignore_fn=blockchain_fixture_ignore_fn, |
| 177 | + ignore_fn=generate_ignore_fn_for_fork(fork) |
75 | 178 | ),
|
76 | 179 | )
|
77 | 180 |
|
78 | 181 |
|
79 | 182 | @pytest.fixture
|
80 | 183 | def fixture(fixture_data):
|
81 |
| - fixture_path, fixture_key = fixture_data |
| 184 | + fixture_path, fixture_key, fixture_fork = fixture_data |
82 | 185 | fixture = load_fixture(
|
83 | 186 | fixture_path,
|
84 | 187 | fixture_key,
|
|
0 commit comments