|
3 | 3 | import rlp
|
4 | 4 |
|
5 | 5 | from eth_utils import (
|
| 6 | + to_tuple, |
6 | 7 | ValidationError,
|
7 | 8 | )
|
8 | 9 |
|
|
34 | 35 | BASE_FIXTURE_PATH = os.path.join(ROOT_PROJECT_DIR, 'fixtures', 'BlockchainTests')
|
35 | 36 |
|
36 | 37 |
|
| 38 | +# These are the slowest 50 tests from the full statetest run. This list should |
| 39 | +# be regenerated occasionally using `--durations 50`. |
| 40 | +SLOWEST_TESTS = { |
| 41 | + ('stStaticCall/static_Call50000_sha256.json', 'static_Call50000_sha256'), |
| 42 | + ('stStaticCall/static_Call50000_rip160.json', 'static_Call50000_rip160'), |
| 43 | + ('stStaticCall/static_Call50000_sha256.json', 'static_Call50000_sha256'), |
| 44 | + ('stStaticCall/static_Call50000.json', 'static_Call50000'), |
| 45 | + ('stStaticCall/static_Call50000_ecrec.json', 'static_Call50000_ecrec'), |
| 46 | + ('stStaticCall/static_Call50000_rip160.json', 'static_Call50000_rip160'), |
| 47 | + ('stStaticCall/static_LoopCallsThenRevert.json', 'static_LoopCallsThenRevert'), |
| 48 | + ('stStaticCall/static_Call50000_identity2.json', 'static_Call50000_identity2'), |
| 49 | + ('stStaticCall/static_Call50000_identity.json', 'static_Call50000_identity'), |
| 50 | + ('stStaticCall/static_Return50000_2.json', 'static_Return50000_2'), |
| 51 | + ('stCallCreateCallCodeTest/Call1024PreCalls.json', 'Call1024PreCalls'), |
| 52 | + ('stChangedEIP150/Call1024PreCalls.json', 'Call1024PreCalls'), |
| 53 | + ('stDelegatecallTestHomestead/Call1024PreCalls.json', 'Call1024PreCalls'), |
| 54 | + ('stStaticCall/static_Call50000.json', 'static_Call50000'), |
| 55 | + ('stStaticCall/static_Call50000_ecrec.json', 'static_Call50000_ecrec'), |
| 56 | + ('stStaticCall/static_Call1024PreCalls2.json', 'static_Call1024PreCalls2'), |
| 57 | + ('stStaticCall/static_Call50000_identity.json', 'static_Call50000_identity'), |
| 58 | + ('stStaticCall/static_Call50000_identity2.json', 'static_Call50000_identity2'), |
| 59 | + ('stStaticCall/static_LoopCallsThenRevert.json', 'static_LoopCallsThenRevert'), |
| 60 | + ('stCallCreateCallCodeTest/Call1024BalanceTooLow.json', 'Call1024BalanceTooLow'), # noqa: E501 |
| 61 | + ('stChangedEIP150/Call1024BalanceTooLow.json', 'Call1024BalanceTooLow'), |
| 62 | + ('stCallCreateCallCodeTest/Callcode1024BalanceTooLow.json', 'Callcode1024BalanceTooLow'), # noqa: E501 |
| 63 | + ('stChangedEIP150/Callcode1024BalanceTooLow.json', 'Callcode1024BalanceTooLow'), # noqa: E501 |
| 64 | + ('stSystemOperationsTest/CallRecursiveBomb0_OOG_atMaxCallDepth.json', 'CallRecursiveBomb0_OOG_atMaxCallDepth'), # noqa: E501 |
| 65 | + ('stRevertTest/LoopCallsDepthThenRevert2.json', 'LoopCallsDepthThenRevert2'), |
| 66 | + ('stRevertTest/LoopCallsDepthThenRevert3.json', 'LoopCallsDepthThenRevert3'), |
| 67 | + ('stDelegatecallTestHomestead/CallRecursiveBombPreCall.json', 'CallRecursiveBombPreCall'), # noqa: E501 |
| 68 | + ('stRevertTest/LoopCallsThenRevert.json', 'LoopCallsThenRevert'), |
| 69 | + ('stCallCreateCallCodeTest/CallRecursiveBombPreCall.json', 'CallRecursiveBombPreCall'), # noqa: E501 |
| 70 | + ('stStaticCall/static_Call50000bytesContract50_1.json', 'static_Call50000bytesContract50_1'), # noqa: E501 |
| 71 | + ('stStaticCall/static_Call1024PreCalls.json', 'static_Call1024PreCalls'), |
| 72 | + ('stDelegatecallTestHomestead/Call1024BalanceTooLow.json', 'Call1024BalanceTooLow'), # noqa: E501 |
| 73 | + ('stDelegatecallTestHomestead/Delegatecall1024.json', 'Delegatecall1024'), |
| 74 | + ('stRevertTest/LoopCallsThenRevert.json', 'LoopCallsThenRevert'), |
| 75 | + ('stStaticCall/static_Call50000bytesContract50_2.json', 'static_Call50000bytesContract50_2'), # noqa: E501 |
| 76 | + ('stStaticCall/static_Call1024PreCalls2.json', 'static_Call1024PreCalls2'), |
| 77 | + ('stRandom/randomStatetest636.json', 'randomStatetest636'), |
| 78 | + ('stStaticCall/static_Call1024PreCalls3.json', 'static_Call1024PreCalls3'), |
| 79 | + ('stRandom/randomStatetest467.json', 'randomStatetest467'), |
| 80 | + ('stRandom/randomStatetest458.json', 'randomStatetest458'), |
| 81 | + ('stRandom/randomStatetest150.json', 'randomStatetest150'), |
| 82 | + ('stRandom/randomStatetest639.json', 'randomStatetest639'), |
| 83 | + ('stStaticCall/static_LoopCallsDepthThenRevert2.json', 'static_LoopCallsDepthThenRevert2'), # noqa: E501 |
| 84 | + ('stRandom/randomStatetest154.json', 'randomStatetest154'), |
| 85 | + ('stRecursiveCreate/recursiveCreateReturnValue.json', 'recursiveCreateReturnValue'), # noqa: E501 |
| 86 | + ('stStaticCall/static_LoopCallsDepthThenRevert3.json', 'static_LoopCallsDepthThenRevert3'), # noqa: E501 |
| 87 | + ('stSystemOperationsTest/ABAcalls1.json', 'ABAcalls1'), |
| 88 | + ('stSpecialTest/failed_tx_xcf416c53.json', 'failed_tx_xcf416c53'), |
| 89 | + ('stRandom/randomStatetest159.json', 'randomStatetest159'), |
| 90 | + ('stRandom/randomStatetest554.json', 'randomStatetest554'), |
| 91 | +} |
| 92 | + |
| 93 | + |
37 | 94 | # These are tests that are thought to be incorrect or buggy upstream,
|
38 | 95 | # at the commit currently checked out in submodule `fixtures`.
|
39 | 96 | # Ideally, this list should be empty.
|
|
48 | 105 | }
|
49 | 106 |
|
50 | 107 |
|
51 |
| -def blockchain_fixture_mark_fn(fixture_path, fixture_name): |
| 108 | +def blockchain_fixture_mark_fn(fixture_path, fixture_name, fixture_fork): |
| 109 | + fixture_id = (fixture_path, fixture_name) |
| 110 | + |
52 | 111 | if fixture_path.startswith('bcExploitTest'):
|
53 | 112 | return pytest.mark.skip("Exploit tests are slow")
|
54 | 113 | elif fixture_path == 'bcWalletTest/walletReorganizeOwners.json':
|
55 | 114 | return pytest.mark.skip("Wallet owner reorganization tests are slow")
|
56 |
| - elif (fixture_path, fixture_name) in INCORRECT_UPSTREAM_TESTS: |
| 115 | + elif fixture_id in INCORRECT_UPSTREAM_TESTS: |
57 | 116 | return pytest.mark.xfail(reason="Listed in INCORRECT_UPSTREAM_TESTS.")
|
| 117 | + elif 'stTransactionTest/zeroSigTransa' in fixture_path: |
| 118 | + return pytest.mark.skip("EIP-86 not supported.") |
| 119 | + elif fixture_id in SLOWEST_TESTS: |
| 120 | + if should_run_slow_tests(): |
| 121 | + return |
| 122 | + else: |
| 123 | + return pytest.mark.skip("Skipping slow test") |
| 124 | + elif 'stQuadraticComplexityTest' in fixture_path: |
| 125 | + return pytest.mark.skip("Skipping slow test") |
| 126 | + |
| 127 | + |
| 128 | +def generate_ignore_fn_for_fork(passed_fork): |
| 129 | + if passed_fork: |
| 130 | + passed_fork = passed_fork.lower() |
| 131 | + |
| 132 | + def ignore_fn(fixture_path, fixture_key, fixture_fork): |
| 133 | + return fixture_fork.lower() != passed_fork |
| 134 | + |
| 135 | + return ignore_fn |
58 | 136 |
|
59 | 137 |
|
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 |
| 138 | +@to_tuple |
| 139 | +def expand_fixtures_forks(all_fixtures): |
| 140 | + for fixture_path, fixture_key in all_fixtures: |
| 141 | + fixture = load_fixture(fixture_path, fixture_key) |
| 142 | + yield fixture_path, fixture_key, fixture['network'] |
65 | 143 |
|
66 | 144 |
|
67 | 145 | def pytest_generate_tests(metafunc):
|
| 146 | + fork = metafunc.config.getoption('fork') |
68 | 147 | generate_fixture_tests(
|
69 | 148 | metafunc=metafunc,
|
70 | 149 | base_fixture_path=BASE_FIXTURE_PATH,
|
| 150 | + preprocess_fn=expand_fixtures_forks, |
71 | 151 | filter_fn=filter_fixtures(
|
72 | 152 | fixtures_base_dir=BASE_FIXTURE_PATH,
|
73 | 153 | mark_fn=blockchain_fixture_mark_fn,
|
74 |
| - ignore_fn=blockchain_fixture_ignore_fn, |
| 154 | + ignore_fn=generate_ignore_fn_for_fork(fork) |
75 | 155 | ),
|
76 | 156 | )
|
77 | 157 |
|
78 | 158 |
|
79 | 159 | @pytest.fixture
|
80 | 160 | def fixture(fixture_data):
|
81 |
| - fixture_path, fixture_key = fixture_data |
| 161 | + fixture_path, fixture_key, fixture_fork = fixture_data |
82 | 162 | fixture = load_fixture(
|
83 | 163 | fixture_path,
|
84 | 164 | fixture_key,
|
|
0 commit comments