|
| 1 | +import pytest |
| 2 | + |
| 3 | +from eth_utils import ( |
| 4 | + to_canonical_address, |
| 5 | +) |
| 6 | + |
| 7 | +from eth.vm.message import ( |
| 8 | + Message, |
| 9 | +) |
| 10 | + |
| 11 | +from eth.vm.forks.spurious_dragon.computation import ( |
| 12 | + SpuriousDragonComputation, |
| 13 | +) |
| 14 | + |
| 15 | +from eth.vm.transaction_context import ( |
| 16 | + BaseTransactionContext, |
| 17 | +) |
| 18 | + |
| 19 | + |
| 20 | +NORMALIZED_ADDRESS_A = "0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" |
| 21 | +NORMALIZED_ADDRESS_B = "0xcd1722f3947def4cf144679da39c4c32bdc35681" |
| 22 | +CANONICAL_ADDRESS_A = to_canonical_address("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6") |
| 23 | +CANONICAL_ADDRESS_B = to_canonical_address("0xcd1722f3947def4cf144679da39c4c32bdc35681") |
| 24 | +CONTRACT_CODE_A = b"" |
| 25 | +CONTRACT_CODE_B = b"" |
| 26 | +CONTRACT_CODE_C = b"" |
| 27 | + |
| 28 | + |
| 29 | +@pytest.fixture |
| 30 | +def state(chain_without_block_validation): |
| 31 | + state = chain_without_block_validation.get_vm().state |
| 32 | + state.account_db.set_balance(CANONICAL_ADDRESS_A, 1000) |
| 33 | + return state |
| 34 | + |
| 35 | + |
| 36 | +@pytest.fixture |
| 37 | +def transaction_context(): |
| 38 | + tx_context = BaseTransactionContext( |
| 39 | + gas_price=1, |
| 40 | + origin=CANONICAL_ADDRESS_B, |
| 41 | + ) |
| 42 | + return tx_context |
| 43 | + |
| 44 | + |
| 45 | +@pytest.fixture |
| 46 | +def message(): |
| 47 | + message = Message( |
| 48 | + to=CANONICAL_ADDRESS_A, |
| 49 | + sender=CANONICAL_ADDRESS_B, |
| 50 | + value=100, |
| 51 | + data=b'', |
| 52 | + code=CONTRACT_CODE_A, # TODO: Test EIP170_CODE_SIZE_LIMIT here |
| 53 | + gas=100, |
| 54 | + ) |
| 55 | + return message |
| 56 | + |
| 57 | + |
| 58 | +@pytest.fixture |
| 59 | +def computation(message, transaction_context, state): |
| 60 | + computation = SpuriousDragonComputation( |
| 61 | + state=state, |
| 62 | + message=message, |
| 63 | + transaction_context=transaction_context, |
| 64 | + ) |
| 65 | + return computation |
| 66 | + |
| 67 | + |
| 68 | +def test_code_size_limit(computation): |
| 69 | + """ |
| 70 | + TODO: CONTRACT_CODE_A size is greater than EIP170_CODE_SIZE_LIMIT |
| 71 | + """ |
| 72 | + |
| 73 | + """ |
| 74 | + TODO: CONTRACT_CODE_B size is equal to EIP170_CODE_SIZE_LIMIT |
| 75 | + """ |
| 76 | + |
| 77 | + """ |
| 78 | + TODO: CONTRACT_CODE_C size is lower than EIP170_CODE_SIZE_LIMIT |
| 79 | + """ |
| 80 | + return |
0 commit comments