Skip to content

Commit 852993c

Browse files
committed
Implement EELS integration tests (almost all passing); temporarily turn on EELS backend for core tests (all passing).
1 parent 43fe421 commit 852993c

File tree

14 files changed

+368
-239
lines changed

14 files changed

+368
-239
lines changed

conftest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import time
33
import warnings
44

5+
from eth_tester import (
6+
EELSBackend,
7+
EthereumTester,
8+
)
59
import pytest_asyncio
610

711
from tests.utils import (
@@ -72,14 +76,16 @@ def _wait_for_transaction(w3, txn_hash, timeout=120):
7276

7377
@pytest.fixture
7478
def w3():
75-
w3 = Web3(EthereumTesterProvider())
79+
t = EthereumTester(backend=EELSBackend("cancun"))
80+
w3 = Web3(EthereumTesterProvider(t))
7681
w3.eth.default_account = w3.eth.accounts[0]
7782
return w3
7883

7984

8085
@pytest.fixture(scope="module")
8186
def w3_non_strict_abi():
82-
w3 = Web3(EthereumTesterProvider())
87+
t = EthereumTester(backend=EELSBackend("cancun"))
88+
w3 = Web3(EthereumTesterProvider(t))
8389
w3.eth.default_account = w3.eth.accounts[0]
8490
w3.strict_bytes_type_checking = False
8591
return w3

tests/core/conftest.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import pytest
22

3+
from eth_tester import (
4+
EELSBackend,
5+
EthereumTester,
6+
)
37
import pytest_asyncio
48

59
from web3 import (
@@ -118,7 +122,10 @@ def __init__(self, a, b):
118122

119123
@pytest_asyncio.fixture
120124
async def async_w3():
121-
w3 = AsyncWeb3(AsyncEthereumTesterProvider())
125+
t = EthereumTester(backend=EELSBackend("cancun"))
126+
provider = AsyncEthereumTesterProvider()
127+
provider.ethereum_tester = t
128+
w3 = AsyncWeb3(provider)
122129
accounts = await w3.eth.accounts
123130
w3.eth.default_account = accounts[0]
124131
return w3

tests/core/contracts/test_contract_build_transaction.py

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_build_transaction_not_paying_to_nonpayable_function(
2222
"value": 0,
2323
"maxFeePerGas": 2750000000,
2424
"maxPriorityFeePerGas": 10**9,
25-
"chainId": 131277322940537,
25+
"chainId": w3.eth.chain_id,
2626
}
2727

2828

@@ -49,7 +49,7 @@ def test_build_transaction_with_contract_no_arguments(
4949
"value": 0,
5050
"maxFeePerGas": 2750000000,
5151
"maxPriorityFeePerGas": 10**9,
52-
"chainId": 131277322940537,
52+
"chainId": w3.eth.chain_id,
5353
}
5454

5555

@@ -77,7 +77,7 @@ def test_build_transaction_with_contract_fallback_function(
7777
"value": 0,
7878
"maxFeePerGas": 2750000000,
7979
"maxPriorityFeePerGas": 10**9,
80-
"chainId": 131277322940537,
80+
"chainId": w3.eth.chain_id,
8181
}
8282

8383

@@ -95,7 +95,7 @@ def test_build_transaction_with_contract_class_method(
9595
"value": 0,
9696
"maxFeePerGas": 2750000000,
9797
"maxPriorityFeePerGas": 10**9,
98-
"chainId": 131277322940537,
98+
"chainId": w3.eth.chain_id,
9999
}
100100

101101

@@ -111,7 +111,7 @@ def test_build_transaction_with_contract_default_account_is_set(
111111
"value": 0,
112112
"maxFeePerGas": 2750000000,
113113
"maxPriorityFeePerGas": 10**9,
114-
"chainId": 131277322940537,
114+
"chainId": w3.eth.chain_id,
115115
}
116116

117117

@@ -130,7 +130,7 @@ def my_gas_price_strategy(w3, transaction_params):
130130
"data": "0x5b34b966",
131131
"value": 0,
132132
"gasPrice": 5,
133-
"chainId": 131277322940537,
133+
"chainId": w3.eth.chain_id,
134134
}
135135

136136

@@ -168,7 +168,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
168168
"value": 0,
169169
"maxFeePerGas": 2750000000,
170170
"maxPriorityFeePerGas": 1000000000,
171-
"chainId": 131277322940537,
172171
},
173172
False,
174173
),
@@ -181,7 +180,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
181180
"value": 0,
182181
"maxFeePerGas": 2750000000,
183182
"maxPriorityFeePerGas": 1000000000,
184-
"chainId": 131277322940537,
185183
},
186184
False,
187185
),
@@ -193,7 +191,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
193191
"data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501
194192
"value": 0,
195193
"gasPrice": 22 * 10**8,
196-
"chainId": 131277322940537,
197194
},
198195
False,
199196
),
@@ -206,7 +203,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
206203
"value": 0,
207204
"maxFeePerGas": 22 * 10**8,
208205
"maxPriorityFeePerGas": 22 * 10**8,
209-
"chainId": 131277322940537,
210206
},
211207
False,
212208
),
@@ -220,7 +216,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
220216
"maxFeePerGas": 2750000000,
221217
"maxPriorityFeePerGas": 1000000000,
222218
"nonce": 7,
223-
"chainId": 131277322940537,
224219
},
225220
True,
226221
),
@@ -233,7 +228,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
233228
"value": 20000,
234229
"maxFeePerGas": 2750000000,
235230
"maxPriorityFeePerGas": 1000000000,
236-
"chainId": 131277322940537,
237231
},
238232
False,
239233
),
@@ -261,6 +255,7 @@ def test_build_transaction_with_contract_arguments(
261255
if skip_testrpc:
262256
skip_if_testrpc(w3)
263257

258+
expected["chainId"] = w3.eth.chain_id
264259
txn = build_transaction(
265260
contract=math_contract,
266261
contract_function="incrementCounter",
@@ -290,7 +285,7 @@ async def test_async_build_transaction_not_paying_to_nonpayable_function(
290285
"value": 0,
291286
"maxFeePerGas": 2750000000,
292287
"maxPriorityFeePerGas": 10**9,
293-
"chainId": 131277322940537,
288+
"chainId": await async_w3.eth.chain_id,
294289
}
295290

296291

@@ -319,7 +314,7 @@ async def test_async_build_transaction_with_contract_no_arguments(
319314
"value": 0,
320315
"maxFeePerGas": 2750000000,
321316
"maxPriorityFeePerGas": 10**9,
322-
"chainId": 131277322940537,
317+
"chainId": await async_w3.eth.chain_id,
323318
}
324319

325320

@@ -349,7 +344,7 @@ async def test_async_build_transaction_with_contract_fallback_function(
349344
"value": 0,
350345
"maxFeePerGas": 2750000000,
351346
"maxPriorityFeePerGas": 10**9,
352-
"chainId": 131277322940537,
347+
"chainId": await async_w3.eth.chain_id,
353348
}
354349

355350

@@ -371,7 +366,7 @@ async def test_async_build_transaction_with_contract_class_method(
371366
"value": 0,
372367
"maxFeePerGas": 2750000000,
373368
"maxPriorityFeePerGas": 10**9,
374-
"chainId": 131277322940537,
369+
"chainId": await async_w3.eth.chain_id,
375370
}
376371

377372

@@ -388,7 +383,7 @@ async def test_async_build_transaction_with_contract_default_account_is_set(
388383
"value": 0,
389384
"maxFeePerGas": 2750000000,
390385
"maxPriorityFeePerGas": 10**9,
391-
"chainId": 131277322940537,
386+
"chainId": await async_w3.eth.chain_id,
392387
}
393388

394389

@@ -408,7 +403,7 @@ def my_gas_price_strategy(async_w3, transaction_params):
408403
"data": "0x5b34b966",
409404
"value": 0,
410405
"gasPrice": 5,
411-
"chainId": 131277322940537,
406+
"chainId": await async_w3.eth.chain_id,
412407
}
413408

414409

@@ -449,7 +444,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
449444
"value": 0,
450445
"maxFeePerGas": 2750000000,
451446
"maxPriorityFeePerGas": 1000000000,
452-
"chainId": 131277322940537,
453447
},
454448
False,
455449
),
@@ -462,7 +456,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
462456
"value": 0,
463457
"maxFeePerGas": 2750000000,
464458
"maxPriorityFeePerGas": 1000000000,
465-
"chainId": 131277322940537,
466459
},
467460
False,
468461
),
@@ -474,7 +467,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
474467
"data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501
475468
"value": 0,
476469
"gasPrice": 22 * 10**8,
477-
"chainId": 131277322940537,
478470
},
479471
False,
480472
),
@@ -487,7 +479,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
487479
"value": 0,
488480
"maxFeePerGas": 22 * 10**8,
489481
"maxPriorityFeePerGas": 22 * 10**8,
490-
"chainId": 131277322940537,
491482
},
492483
False,
493484
),
@@ -501,7 +492,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
501492
"maxFeePerGas": 2750000000,
502493
"maxPriorityFeePerGas": 1000000000,
503494
"nonce": 7,
504-
"chainId": 131277322940537,
505495
},
506496
True,
507497
),
@@ -514,7 +504,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
514504
"value": 20000,
515505
"maxFeePerGas": 2750000000,
516506
"maxPriorityFeePerGas": 1000000000,
517-
"chainId": 131277322940537,
518507
},
519508
False,
520509
),
@@ -542,6 +531,7 @@ async def test_async_build_transaction_with_contract_with_arguments(
542531
if skip_testrpc:
543532
async_skip_if_testrpc(async_w3)
544533

534+
expected["chainId"] = await async_w3.eth.chain_id
545535
txn = await async_build_transaction(
546536
contract=async_math_contract,
547537
contract_function="incrementCounter",

tests/core/eth-module/test_eth_properties.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ def async_w3():
1616

1717

1818
def test_eth_chain_id(w3):
19-
assert w3.eth.chain_id == 131277322940537 # from fixture generation file
19+
assert w3.eth.chain_id == w3.provider.eth_tester.chain_id
2020

2121

2222
@pytest.mark.asyncio
2323
async def test_async_eth_chain_id(async_w3):
24-
assert (
25-
await async_w3.eth.chain_id == 131277322940537
26-
) # from fixture generation file
24+
assert await async_w3.eth.chain_id == async_w3.provider.eth_tester.chain_id

tests/core/module-class/test_module.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ def test_attach_methods_to_module(web3_with_external_modules):
3737
}
3838
)
3939

40-
assert w3.eth.chain_id == 131277322940537
41-
assert w3.module1.property1 == 131277322940537
40+
configured_chain_id = w3.provider.eth_tester.chain_id
41+
assert w3.eth.chain_id == configured_chain_id
42+
assert w3.module1.property1 == configured_chain_id
4243

4344
account = w3.eth.accounts[0]
4445
assert w3.eth.get_balance(account, "latest") == 1000000000000000000000000

tests/core/web3-module/test_web3_inheritance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class InheritsFromWeb3(Web3):
99
pass
1010

1111
inherited_w3 = InheritsFromWeb3(EthereumTesterProvider())
12-
assert inherited_w3.eth.chain_id == 131277322940537
12+
assert inherited_w3.eth.chain_id == inherited_w3.provider.eth_tester.chain_id

tests/integration/ethereum_tester/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)