Skip to content

Commit eacc6aa

Browse files
committed
Update test fixture to use Sol v0.8.25; Update geth:
- Remove pending block reliance; set dev period to 1 second - Use the latest geth 1.14.5 for integration; re-generate fixture - Tweaks to the fixture generation based on geth updates - re-compile test contracts with Solidity v0.8.25 - Remove support for non-existent client properties: - ``eth_coinbase`` - ``eth_mining`` - ``eth_hashrate`` - ``eth_submitHashrate`` - ``eth_submitWork`` - ``eth_getWork`` - Update py-geth to use the newly released beta - quick lint fixes - Fix remaining tests that rely on mining: - newsfragment for #3307
1 parent a721a41 commit eacc6aa

File tree

64 files changed

+259
-703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+259
-703
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ version: 2.1
55
parameters:
66
geth_version:
77
# update default value when updating geth integration test fixture
8-
default: "v1.13.14"
8+
default: "v1.14.5"
99
type: string
1010
pygeth_version:
1111
# update default value when updating geth integration test fixture
12-
default: "4.3.0"
12+
default: "5.0.0b1"
1313
type: string
1414
go_version:
15-
default: "1.20.2"
15+
default: "1.22.4"
1616
type: string
1717

1818
common: &common

conftest.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ def _skip_if_testrpc(w3):
3939
return _skip_if_testrpc
4040

4141

42-
@pytest.fixture()
43-
def wait_for_miner_start():
44-
def _wait_for_miner_start(w3, timeout=60):
45-
poll_delay_counter = PollDelayCounter()
46-
with Timeout(timeout) as timeout:
47-
while not w3.eth.mining or not w3.eth.hashrate:
48-
time.sleep(poll_delay_counter())
49-
timeout.check()
50-
51-
return _wait_for_miner_start
52-
53-
5442
@pytest.fixture(scope="module")
5543
def wait_for_block():
5644
def _wait_for_block(w3, block_number=1, timeout=None):

docs/contributing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,13 @@ Geth Fixtures
373373

374374
.. code:: sh
375375
376-
$ python -m geth.install v1.13.14
376+
$ python -m geth.install v1.14.5
377377
378378
2. Specify the Geth binary and run the fixture creation script (from within the web3.py directory):
379379

380380
.. code:: sh
381381
382-
$ GETH_BINARY=~/.py-geth/geth-v1.13.14/bin/geth python ./tests/integration/generate_fixtures/go_ethereum.py ./tests/integration/geth-1.13.14-fixture
382+
$ GETH_BINARY=~/.py-geth/geth-v1.14.5/bin/geth python ./tests/integration/generate_fixtures/go_ethereum.py ./tests/integration/geth-1.14.5-fixture
383383
384384
3. The output of this script is your fixture, a zip file, which is now stored in ``/tests/integration/``.
385385
Update the ``/tests/integration/go_ethereum/conftest.py`` and

docs/middleware.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ middleware is:
346346
347347
# confirm that the connection succeeded
348348
>>> w3.client_version
349-
'Geth/v1.13.14-stable-4bb3c89d/linux-amd64/go1.20.2'
349+
'Geth/v1.14.5-stable-4bb3c89d/linux-amd64/go1.22.4'
350350
351351
This example connects to a local ``geth --dev`` instance on Linux with a
352352
unique IPC location and loads the middleware:

docs/web3.contract.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Each Contract Factory exposes the following methods.
234234

235235
.. code-block:: python
236236
237-
>>> deploy_txn = token_contract.constructor(web3.eth.coinbase, 12345).transact()
237+
>>> deploy_txn = token_contract.constructor(web3.eth.accounts[0], 12345).transact()
238238
>>> txn_receipt = web3.eth.get_transaction_receipt(deploy_txn)
239239
>>> txn_receipt['contractAddress']
240240
'0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318'
@@ -259,7 +259,7 @@ Each Contract Factory exposes the following methods.
259259

260260
.. code-block:: python
261261
262-
>>> token_contract.constructor(web3.eth.coinbase, 12345).estimate_gas()
262+
>>> token_contract.constructor(web3.eth.accounts[0], 12345).estimate_gas()
263263
12563
264264
265265
.. py:classmethod:: Contract.constructor(*args, **kwargs).build_transaction(transaction=None)
@@ -281,7 +281,7 @@ Each Contract Factory exposes the following methods.
281281
'gasPrice': w3.eth.gas_price,
282282
'chainId': None
283283
}
284-
>>> contract_data = token_contract.constructor(web3.eth.coinbase, 12345).build_transaction(transaction)
284+
>>> contract_data = token_contract.constructor(web3.eth.accounts[0], 12345).build_transaction(transaction)
285285
>>> web3.eth.send_transaction(contract_data)
286286
287287
.. _contract_create_filter:
@@ -777,8 +777,8 @@ Methods
777777
778778
>>> my_contract.functions.multiply7(3).call()
779779
21
780-
>>> token_contract.functions.myBalance().call({'from': web3.eth.coinbase})
781-
12345 # the token balance for `web3.eth.coinbase`
780+
>>> token_contract.functions.myBalance().call({'from': web3.eth.accounts[0]})
781+
12345 # the token balance for `web3.eth.accounts[0]`
782782
>>> token_contract.functions.myBalance().call({'from': web3.eth.accounts[1]})
783783
54321 # the token balance for the account `web3.eth.accounts[1]`
784784

docs/web3.eth.rst

Lines changed: 8 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -79,42 +79,6 @@ The following properties are available on the ``web3.eth`` namespace.
7979
})
8080
8181
82-
.. py:attribute:: Eth.coinbase
83-
84-
* Delegates to ``eth_coinbase`` RPC Method
85-
86-
Returns the current *Coinbase* address.
87-
88-
.. code-block:: python
89-
90-
>>> web3.eth.coinbase
91-
'0xC014BA5EC014ba5ec014Ba5EC014ba5Ec014bA5E'
92-
93-
94-
.. py:attribute:: Eth.mining
95-
96-
* Delegates to ``eth_mining`` RPC Method
97-
98-
Returns boolean as to whether the node is currently mining.
99-
100-
.. code-block:: python
101-
102-
>>> web3.eth.mining
103-
False
104-
105-
106-
.. py:attribute:: Eth.hashrate
107-
108-
* Delegates to ``eth_hashrate`` RPC Method
109-
110-
Returns the current number of hashes per second the node is mining with.
111-
112-
.. code-block:: python
113-
114-
>>> web3.eth.hashrate
115-
906
116-
117-
11882
.. py:attribute:: Eth.max_priority_fee
11983
12084
* Delegates to ``eth_maxPriorityFeePerGas`` RPC Method
@@ -720,15 +684,15 @@ The following methods are available on the ``web3.eth`` namespace.
720684
# simple example (web3.py and / or client determines gas and fees, typically defaults to a dynamic fee transaction post London fork)
721685
>>> web3.eth.send_transaction({
722686
'to': '0x582AC4D8929f58c217d4a52aDD361AE470a8a4cD',
723-
'from': web3.eth.coinbase,
687+
'from': web3.eth.accounts[0],
724688
'value': 12345
725689
})
726690
727691
# Dynamic fee transaction, introduced by EIP-1559:
728692
HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331')
729693
>>> web3.eth.send_transaction({
730694
'to': '0x582AC4D8929f58c217d4a52aDD361AE470a8a4cD',
731-
'from': web3.eth.coinbase,
695+
'from': web3.eth.accounts[0],
732696
'value': 12345,
733697
'gas': 21000,
734698
'maxFeePerGas': web3.to_wei(250, 'gwei'),
@@ -740,7 +704,7 @@ The following methods are available on the ``web3.eth`` namespace.
740704
HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331')
741705
>>> web3.eth.send_transaction({
742706
'to': '0x582AC4D8929f58c217d4a52aDD361AE470a8a4cD',
743-
'from': web3.eth.coinbase,
707+
'from': web3.eth.accounts[0],
744708
'value': 12345,
745709
'gas': 21000,
746710
'gasPrice': web3.to_wei(50, 'gwei'),
@@ -758,7 +722,7 @@ The following methods are available on the ``web3.eth`` namespace.
758722
.. code-block:: python
759723
760724
>>> signed_txn = w3.eth.sign_transaction(dict(
761-
nonce=w3.eth.get_transaction_count(w3.eth.coinbase),
725+
nonce=w3.eth.get_transaction_count(w3.eth.accounts[0]),
762726
maxFeePerGas=2000000000,
763727
maxPriorityFeePerGas=1000000000,
764728
gas=100000,
@@ -839,13 +803,13 @@ The following methods are available on the ``web3.eth`` namespace.
839803
840804
>>> tx = web3.eth.send_transaction({
841805
'to': '0x582AC4D8929f58c217d4a52aDD361AE470a8a4cD',
842-
'from': web3.eth.coinbase,
806+
'from': web3.eth.accounts[0],
843807
'value': 1000
844808
})
845809
HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331')
846810
>>> web3.eth.replace_transaction('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331', {
847811
'to': '0x582AC4D8929f58c217d4a52aDD361AE470a8a4cD',
848-
'from': web3.eth.coinbase,
812+
'from': web3.eth.accounts[0],
849813
'value': 2000
850814
})
851815
HexBytes('0x4177e670ec6431606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1528989')
@@ -870,7 +834,7 @@ The following methods are available on the ``web3.eth`` namespace.
870834
871835
>>> tx = web3.eth.send_transaction({
872836
'to': '0x582AC4D8929f58c217d4a52aDD361AE470a8a4cD',
873-
'from': web3.eth.coinbase,
837+
'from': web3.eth.accounts[0],
874838
'value': 1000
875839
})
876840
HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331')
@@ -1072,7 +1036,7 @@ The following methods are available on the ``web3.eth`` namespace.
10721036

10731037
.. code-block:: python
10741038
1075-
>>> web3.eth.estimate_gas({'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'from':web3.eth.coinbase, 'value': 12345})
1039+
>>> web3.eth.estimate_gas({'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'from':web3.eth.accounts[0], 'value': 12345})
10761040
21000
10771041
10781042
@@ -1279,30 +1243,6 @@ with the filtering API.
12791243
filter, running :meth:`~Eth.get_filter_logs`, and then uninstalling the filter. See
12801244
:meth:`~Eth.filter` for details on allowed filter parameters.
12811245

1282-
.. py:method:: Eth.submit_hashrate(hashrate, nodeid)
1283-
1284-
* Delegates to ``eth_submitHashrate`` RPC Method
1285-
1286-
.. code-block:: python
1287-
1288-
>>> node_id = '59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c'
1289-
>>> web3.eth.submit_hashrate(5000, node_id)
1290-
True
1291-
1292-
1293-
.. py:method:: Eth.submit_work(nonce, pow_hash, mix_digest)
1294-
1295-
* Delegates to ``eth_submitWork`` RPC Method.
1296-
1297-
.. code-block:: python
1298-
1299-
>>> web3.eth.submit_work(
1300-
1,
1301-
'0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
1302-
'0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000',
1303-
)
1304-
True
1305-
13061246

13071247
Contracts
13081248
---------

newsfragments/3307.internal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Re-compile test contracts with Solidity v0.8.25 to ensure compatibility.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
],
3232
"test": [
3333
"eth-tester[py-evm]>=0.11.0b1,<0.13.0b1",
34-
"py-geth>=4.1.0",
34+
"py-geth>=5.0.0b1",
3535
"pytest-asyncio>=0.18.1,<0.23",
3636
"pytest-mock>=1.10",
3737
"pytest-xdist>=2.4.0",

tests/core/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,15 @@ def __init__(self, a, b):
119119
@pytest_asyncio.fixture
120120
async def async_w3():
121121
w3 = AsyncWeb3(AsyncEthereumTesterProvider())
122-
w3.eth.default_account = await w3.eth.coinbase
122+
accounts = await w3.eth.accounts
123+
w3.eth.default_account = accounts[0]
123124
return w3
124125

125126

126127
@pytest_asyncio.fixture
127128
async def async_w3_non_strict_abi():
128129
w3 = AsyncWeb3(AsyncEthereumTesterProvider())
129130
w3.strict_bytes_type_checking = False
130-
w3.eth.default_account = await w3.eth.coinbase
131+
accounts = await w3.eth.accounts
132+
w3.eth.default_account = accounts[0]
131133
return w3

tests/core/contracts/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def event_contract(
231231

232232
event_contract_factory = w3.eth.contract(**EVENT_CONTRACT_DATA)
233233
deploy_txn_hash = event_contract_factory.constructor().transact(
234-
{"from": w3.eth.coinbase, "gas": 1000000}
234+
{"from": w3.eth.accounts[0], "gas": 1000000}
235235
)
236236
deploy_receipt = wait_for_transaction(w3, deploy_txn_hash)
237237
contract_address = address_conversion_func(deploy_receipt["contractAddress"])
@@ -251,7 +251,7 @@ def indexed_event_contract(
251251

252252
indexed_event_contract_factory = w3.eth.contract(**INDEXED_EVENT_CONTRACT_DATA)
253253
deploy_txn_hash = indexed_event_contract_factory.constructor().transact(
254-
{"from": w3.eth.coinbase, "gas": 1000000}
254+
{"from": w3.eth.accounts[0], "gas": 1000000}
255255
)
256256
deploy_receipt = wait_for_transaction(w3, deploy_txn_hash)
257257
contract_address = address_conversion_func(deploy_receipt["contractAddress"])

0 commit comments

Comments
 (0)