Skip to content

Commit 3bf4104

Browse files
committed
Implement EELS integration tests (almost all passing); temporarily turn on EELS backend for core tests (all passing).
1 parent fcdf256 commit 3bf4104

File tree

14 files changed

+368
-239
lines changed

14 files changed

+368
-239
lines changed

Diff for: conftest.py

+8-2
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

Diff for: tests/core/conftest.py

+8-1
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

Diff for: tests/core/contracts/test_contract_build_transaction.py

+14-24
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

@@ -63,7 +63,7 @@ def test_build_transaction_with_contract_fallback_function(
6363
"value": 0,
6464
"maxFeePerGas": 2750000000,
6565
"maxPriorityFeePerGas": 10**9,
66-
"chainId": 131277322940537,
66+
"chainId": w3.eth.chain_id,
6767
}
6868

6969

@@ -81,7 +81,7 @@ def test_build_transaction_with_contract_class_method(
8181
"value": 0,
8282
"maxFeePerGas": 2750000000,
8383
"maxPriorityFeePerGas": 10**9,
84-
"chainId": 131277322940537,
84+
"chainId": w3.eth.chain_id,
8585
}
8686

8787

@@ -97,7 +97,7 @@ def test_build_transaction_with_contract_default_account_is_set(
9797
"value": 0,
9898
"maxFeePerGas": 2750000000,
9999
"maxPriorityFeePerGas": 10**9,
100-
"chainId": 131277322940537,
100+
"chainId": w3.eth.chain_id,
101101
}
102102

103103

@@ -116,7 +116,7 @@ def my_gas_price_strategy(w3, transaction_params):
116116
"data": "0x5b34b966",
117117
"value": 0,
118118
"gasPrice": 5,
119-
"chainId": 131277322940537,
119+
"chainId": w3.eth.chain_id,
120120
}
121121

122122

@@ -154,7 +154,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
154154
"value": 0,
155155
"maxFeePerGas": 2750000000,
156156
"maxPriorityFeePerGas": 1000000000,
157-
"chainId": 131277322940537,
158157
},
159158
False,
160159
),
@@ -167,7 +166,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
167166
"value": 0,
168167
"maxFeePerGas": 2750000000,
169168
"maxPriorityFeePerGas": 1000000000,
170-
"chainId": 131277322940537,
171169
},
172170
False,
173171
),
@@ -179,7 +177,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
179177
"data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501
180178
"value": 0,
181179
"gasPrice": 22 * 10**8,
182-
"chainId": 131277322940537,
183180
},
184181
False,
185182
),
@@ -192,7 +189,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
192189
"value": 0,
193190
"maxFeePerGas": 22 * 10**8,
194191
"maxPriorityFeePerGas": 22 * 10**8,
195-
"chainId": 131277322940537,
196192
},
197193
False,
198194
),
@@ -206,7 +202,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
206202
"maxFeePerGas": 2750000000,
207203
"maxPriorityFeePerGas": 1000000000,
208204
"nonce": 7,
209-
"chainId": 131277322940537,
210205
},
211206
True,
212207
),
@@ -219,7 +214,6 @@ def test_build_transaction_with_contract_to_address_supplied_errors(
219214
"value": 20000,
220215
"maxFeePerGas": 2750000000,
221216
"maxPriorityFeePerGas": 1000000000,
222-
"chainId": 131277322940537,
223217
},
224218
False,
225219
),
@@ -247,6 +241,7 @@ def test_build_transaction_with_contract_arguments(
247241
if skip_testrpc:
248242
skip_if_testrpc(w3)
249243

244+
expected["chainId"] = w3.eth.chain_id
250245
txn = build_transaction(
251246
contract=math_contract,
252247
contract_function="incrementCounter",
@@ -276,7 +271,7 @@ async def test_async_build_transaction_not_paying_to_nonpayable_function(
276271
"value": 0,
277272
"maxFeePerGas": 2750000000,
278273
"maxPriorityFeePerGas": 10**9,
279-
"chainId": 131277322940537,
274+
"chainId": await async_w3.eth.chain_id,
280275
}
281276

282277

@@ -305,7 +300,7 @@ async def test_async_build_transaction_with_contract_no_arguments(
305300
"value": 0,
306301
"maxFeePerGas": 2750000000,
307302
"maxPriorityFeePerGas": 10**9,
308-
"chainId": 131277322940537,
303+
"chainId": await async_w3.eth.chain_id,
309304
}
310305

311306

@@ -320,7 +315,7 @@ async def test_async_build_transaction_with_contract_fallback_function(
320315
"value": 0,
321316
"maxFeePerGas": 2750000000,
322317
"maxPriorityFeePerGas": 10**9,
323-
"chainId": 131277322940537,
318+
"chainId": await async_w3.eth.chain_id,
324319
}
325320

326321

@@ -342,7 +337,7 @@ async def test_async_build_transaction_with_contract_class_method(
342337
"value": 0,
343338
"maxFeePerGas": 2750000000,
344339
"maxPriorityFeePerGas": 10**9,
345-
"chainId": 131277322940537,
340+
"chainId": await async_w3.eth.chain_id,
346341
}
347342

348343

@@ -359,7 +354,7 @@ async def test_async_build_transaction_with_contract_default_account_is_set(
359354
"value": 0,
360355
"maxFeePerGas": 2750000000,
361356
"maxPriorityFeePerGas": 10**9,
362-
"chainId": 131277322940537,
357+
"chainId": await async_w3.eth.chain_id,
363358
}
364359

365360

@@ -379,7 +374,7 @@ def my_gas_price_strategy(async_w3, transaction_params):
379374
"data": "0x5b34b966",
380375
"value": 0,
381376
"gasPrice": 5,
382-
"chainId": 131277322940537,
377+
"chainId": await async_w3.eth.chain_id,
383378
}
384379

385380

@@ -420,7 +415,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
420415
"value": 0,
421416
"maxFeePerGas": 2750000000,
422417
"maxPriorityFeePerGas": 1000000000,
423-
"chainId": 131277322940537,
424418
},
425419
False,
426420
),
@@ -433,7 +427,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
433427
"value": 0,
434428
"maxFeePerGas": 2750000000,
435429
"maxPriorityFeePerGas": 1000000000,
436-
"chainId": 131277322940537,
437430
},
438431
False,
439432
),
@@ -445,7 +438,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
445438
"data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501
446439
"value": 0,
447440
"gasPrice": 22 * 10**8,
448-
"chainId": 131277322940537,
449441
},
450442
False,
451443
),
@@ -458,7 +450,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
458450
"value": 0,
459451
"maxFeePerGas": 22 * 10**8,
460452
"maxPriorityFeePerGas": 22 * 10**8,
461-
"chainId": 131277322940537,
462453
},
463454
False,
464455
),
@@ -472,7 +463,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
472463
"maxFeePerGas": 2750000000,
473464
"maxPriorityFeePerGas": 1000000000,
474465
"nonce": 7,
475-
"chainId": 131277322940537,
476466
},
477467
True,
478468
),
@@ -485,7 +475,6 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors(
485475
"value": 20000,
486476
"maxFeePerGas": 2750000000,
487477
"maxPriorityFeePerGas": 1000000000,
488-
"chainId": 131277322940537,
489478
},
490479
False,
491480
),
@@ -513,6 +502,7 @@ async def test_async_build_transaction_with_contract_with_arguments(
513502
if skip_testrpc:
514503
async_skip_if_testrpc(async_w3)
515504

505+
expected["chainId"] = await async_w3.eth.chain_id
516506
txn = await async_build_transaction(
517507
contract=async_math_contract,
518508
contract_function="incrementCounter",

Diff for: tests/core/eth-module/test_eth_properties.py

+2-4
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

Diff for: tests/core/module-class/test_module.py

+3-2
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

Diff for: tests/core/web3-module/test_web3_inheritance.py

+1-1
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

Diff for: tests/integration/ethereum_tester/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)