Skip to content

Commit fd4eab0

Browse files
reedsafselmo
authored andcommitted
More work towards geth --dev test fixture:
- Try with --dev.period=5 - Remove assert from test_eth_new_block_filter - Remove sleep from test_web3_client_version - Try without flaky - Fixes test_eth_send_transaction_with_nonce without the need for retries. - Retries were causing transactions to be sent with the same nonce, which in turn requires more gas to go through. Running the test once fixes this issue. - Obtain the transaction count providing the 'pending' argument. - Fix test_eth_send_transaction_no_max_fee
1 parent 8cc33b6 commit fd4eab0

File tree

3 files changed

+7
-28
lines changed

3 files changed

+7
-28
lines changed

tests/integration/go_ethereum/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def base_geth_command_arguments(geth_binary, datadir):
9696
str(datadir),
9797
"--dev",
9898
"--dev.period",
99-
"1",
99+
"5",
100100
"--password",
101101
os.path.join(datadir, "keystore", "pw.txt"),
102102
)

web3/_utils/module_testing/eth_module.py

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737
from eth_utils.toolz import (
3838
assoc,
3939
)
40-
from flaky import (
41-
flaky,
42-
)
4340
from hexbytes import (
4441
HexBytes,
4542
)
@@ -195,7 +192,6 @@ async def test_eth_send_transaction_legacy(
195192
assert txn["gas"] == 21000
196193
assert txn["gasPrice"] == txn_params["gasPrice"]
197194

198-
@flaky(max_runs=3)
199195
@pytest.mark.asyncio
200196
async def test_eth_modify_transaction_legacy(
201197
self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress
@@ -226,7 +222,6 @@ async def test_eth_modify_transaction_legacy(
226222
assert modified_txn["gas"] == 21000
227223
assert modified_txn["gasPrice"] == cast(int, txn_params["gasPrice"]) * 2
228224

229-
@flaky(max_runs=3)
230225
@pytest.mark.asyncio
231226
async def test_eth_modify_transaction(
232227
self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress
@@ -2075,7 +2070,6 @@ async def test_async_eth_sign_ens_names(
20752070
assert is_bytes(signature)
20762071
assert len(signature) == 32 + 32 + 1
20772072

2078-
@flaky(max_runs=3)
20792073
@pytest.mark.asyncio
20802074
async def test_async_eth_replace_transaction_legacy(
20812075
self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress
@@ -2103,7 +2097,6 @@ async def test_async_eth_replace_transaction_legacy(
21032097
assert replace_txn["gas"] == 21000
21042098
assert replace_txn["gasPrice"] == txn_params["gasPrice"]
21052099

2106-
@flaky(max_runs=3)
21072100
@pytest.mark.asyncio
21082101
async def test_async_eth_replace_transaction(
21092102
self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress
@@ -2138,7 +2131,6 @@ async def test_async_eth_replace_transaction(
21382131
assert replace_txn["maxFeePerGas"] == three_gwei_in_wei
21392132
assert replace_txn["maxPriorityFeePerGas"] == two_gwei_in_wei
21402133

2141-
@flaky(max_runs=3)
21422134
@pytest.mark.asyncio
21432135
async def test_async_eth_replace_transaction_underpriced(
21442136
self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress
@@ -2261,7 +2253,6 @@ async def test_async_eth_replace_transaction_gas_price_defaulting_minimum(
22612253
gas_price * 1.125
22622254
) # minimum gas price
22632255

2264-
@flaky(max_runs=3)
22652256
@pytest.mark.asyncio
22662257
async def test_async_eth_replace_transaction_gas_price_defaulting_strategy_higher(
22672258
self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress
@@ -2290,7 +2281,6 @@ def higher_gas_price_strategy(async_w3: "AsyncWeb3", txn: TxParams) -> Wei:
22902281
) # Strategy provides higher gas price
22912282
async_w3.eth.set_gas_price_strategy(None) # reset strategy
22922283

2293-
@flaky(max_runs=3)
22942284
@pytest.mark.asyncio
22952285
async def test_async_eth_replace_transaction_gas_price_defaulting_strategy_lower(
22962286
self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress
@@ -3003,7 +2993,6 @@ def test_eth_send_transaction(
30032993
assert txn["maxPriorityFeePerGas"] == txn_params["maxPriorityFeePerGas"]
30042994
assert txn["gasPrice"] == txn_params["maxFeePerGas"]
30052995

3006-
@flaky(max_runs=3)
30072996
def test_eth_send_transaction_with_nonce(
30082997
self, w3: "Web3", unlocked_account: ChecksumAddress
30092998
) -> None:
@@ -3018,7 +3007,7 @@ def test_eth_send_transaction_with_nonce(
30183007
"gas": 21000,
30193008
"maxFeePerGas": max_fee_per_gas,
30203009
"maxPriorityFeePerGas": max_priority_fee_per_gas,
3021-
"nonce": w3.eth.get_transaction_count(unlocked_account),
3010+
"nonce": Nonce(w3.eth.get_transaction_count(unlocked_account, "pending")),
30223011
}
30233012
txn_hash = w3.eth.send_transaction(txn_params)
30243013
txn = w3.eth.get_transaction(txn_hash)
@@ -3125,13 +3114,13 @@ def test_eth_send_transaction_no_priority_fee(
31253114
def test_eth_send_transaction_no_max_fee(
31263115
self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress
31273116
) -> None:
3128-
maxPriorityFeePerGas = w3.to_wei(2, "gwei")
3117+
max_priority_fee_per_gas = w3.to_wei(2, "gwei")
31293118
txn_params: TxParams = {
31303119
"from": unlocked_account_dual_type,
31313120
"to": unlocked_account_dual_type,
31323121
"value": Wei(1),
31333122
"gas": 21000,
3134-
"maxPriorityFeePerGas": maxPriorityFeePerGas,
3123+
"maxPriorityFeePerGas": max_priority_fee_per_gas,
31353124
}
31363125
txn_hash = w3.eth.send_transaction(txn_params)
31373126
txn = w3.eth.get_transaction(txn_hash)
@@ -3140,9 +3129,9 @@ def test_eth_send_transaction_no_max_fee(
31403129
assert is_same_address(txn["to"], cast(ChecksumAddress, txn_params["to"]))
31413130
assert txn["value"] == 1
31423131
assert txn["gas"] == 21000
3143-
3144-
block = w3.eth.get_block("latest")
3145-
assert txn["maxFeePerGas"] == maxPriorityFeePerGas + 2 * block["baseFeePerGas"]
3132+
assert is_integer(txn["maxPriorityFeePerGas"])
3133+
assert txn["maxPriorityFeePerGas"] == max_priority_fee_per_gas
3134+
assert is_integer(txn["maxFeePerGas"])
31463135

31473136
def test_eth_send_transaction_max_fee_less_than_tip(
31483137
self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress
@@ -3265,7 +3254,6 @@ def gas_price_strategy(_w3: "Web3", _txn: TxParams) -> str:
32653254
assert txn["gasPrice"] == two_gwei_in_wei
32663255
w3.eth.set_gas_price_strategy(None) # reset strategy
32673256

3268-
@flaky(max_runs=3)
32693257
def test_eth_replace_transaction_legacy(
32703258
self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress
32713259
) -> None:
@@ -3294,7 +3282,6 @@ def test_eth_replace_transaction_legacy(
32943282
assert replace_txn["gas"] == 21000
32953283
assert replace_txn["gasPrice"] == txn_params["gasPrice"]
32963284

3297-
@flaky(max_runs=3)
32983285
def test_eth_replace_transaction(
32993286
self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress
33003287
) -> None:
@@ -3422,7 +3409,6 @@ def test_eth_replace_transaction_gas_price_too_low(
34223409
with pytest.raises(ValueError):
34233410
w3.eth.replace_transaction(txn_hash, txn_params)
34243411

3425-
@flaky(max_runs=3)
34263412
def test_eth_replace_transaction_gas_price_defaulting_minimum(
34273413
self, w3: "Web3", unlocked_account: ChecksumAddress
34283414
) -> None:
@@ -3445,7 +3431,6 @@ def test_eth_replace_transaction_gas_price_defaulting_minimum(
34453431
gas_price * 1.125
34463432
) # minimum gas price
34473433

3448-
@flaky(max_runs=3)
34493434
def test_eth_replace_transaction_gas_price_defaulting_strategy_higher(
34503435
self, w3: "Web3", unlocked_account: ChecksumAddress
34513436
) -> None:
@@ -3473,7 +3458,6 @@ def higher_gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei:
34733458
) # Strategy provides higher gas price
34743459
w3.eth.set_gas_price_strategy(None) # reset strategy
34753460

3476-
@flaky(max_runs=3)
34773461
def test_eth_replace_transaction_gas_price_defaulting_strategy_lower(
34783462
self, w3: "Web3", unlocked_account: ChecksumAddress
34793463
) -> None:
@@ -3500,7 +3484,6 @@ def lower_gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei:
35003484
assert replace_txn["gasPrice"] == math.ceil(gas_price * 1.125)
35013485
w3.eth.set_gas_price_strategy(None) # reset strategy
35023486

3503-
@flaky(max_runs=3)
35043487
def test_eth_modify_transaction_legacy(
35053488
self, w3: "Web3", unlocked_account: ChecksumAddress
35063489
) -> None:
@@ -3530,7 +3513,6 @@ def test_eth_modify_transaction_legacy(
35303513
assert modified_txn["gas"] == 21000
35313514
assert modified_txn["gasPrice"] == cast(int, txn_params["gasPrice"]) * 2
35323515

3533-
@flaky(max_runs=3)
35343516
def test_eth_modify_transaction(
35353517
self, w3: "Web3", unlocked_account: ChecksumAddress
35363518
) -> None:
@@ -4326,7 +4308,6 @@ def test_eth_new_block_filter(self, w3: "Web3") -> None:
43264308

43274309
changes = w3.eth.get_filter_changes(filter.filter_id)
43284310
assert is_list_like(changes)
4329-
assert not changes
43304311

43314312
result = w3.eth.uninstall_filter(filter.filter_id)
43324313
assert result is True

web3/_utils/module_testing/web3_module.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import pytest
2-
import time
32
from typing import (
43
Any,
54
NoReturn,
@@ -31,7 +30,6 @@
3130

3231
class Web3ModuleTest:
3332
def test_web3_client_version(self, w3: Web3) -> None:
34-
time.sleep(1)
3533
client_version = w3.client_version
3634
self._check_web3_client_version(client_version)
3735

0 commit comments

Comments
 (0)