Skip to content

Commit 5192fb3

Browse files
committed
Add @flaky to tests that expect mining at certain times
- This isn't ideal. Perhaps we can increase the ``dev.period`` (mining interval) to make these tests a bit more reliable and hopefully the other tests are unaffected.
1 parent daa9a4c commit 5192fb3

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

web3/_utils/module_testing/eth_module.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ async def test_eth_send_transaction_legacy(
195195
assert txn["gas"] == 21000
196196
assert txn["gasPrice"] == txn_params["gasPrice"]
197197

198+
@flaky(max_runs=3)
198199
@pytest.mark.asyncio
199200
async def test_eth_modify_transaction_legacy(
200201
self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress
@@ -225,6 +226,7 @@ async def test_eth_modify_transaction_legacy(
225226
assert modified_txn["gas"] == 21000
226227
assert modified_txn["gasPrice"] == cast(int, txn_params["gasPrice"]) * 2
227228

229+
@flaky(max_runs=3)
228230
@pytest.mark.asyncio
229231
async def test_eth_modify_transaction(
230232
self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress
@@ -2073,6 +2075,7 @@ async def test_async_eth_sign_ens_names(
20732075
assert is_bytes(signature)
20742076
assert len(signature) == 32 + 32 + 1
20752077

2078+
@flaky(max_runs=3)
20762079
@pytest.mark.asyncio
20772080
async def test_async_eth_replace_transaction_legacy(
20782081
self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress
@@ -2082,9 +2085,7 @@ async def test_async_eth_replace_transaction_legacy(
20822085
"to": async_unlocked_account_dual_type,
20832086
"value": Wei(1),
20842087
"gas": 21000,
2085-
"gasPrice": async_w3.to_wei(
2086-
1, "gwei"
2087-
), # must be greater than base_fee post London
2088+
"gasPrice": async_w3.to_wei(1, "gwei"),
20882089
}
20892090
txn_hash = await async_w3.eth.send_transaction(txn_params)
20902091

@@ -2102,6 +2103,7 @@ async def test_async_eth_replace_transaction_legacy(
21022103
assert replace_txn["gas"] == 21000
21032104
assert replace_txn["gasPrice"] == txn_params["gasPrice"]
21042105

2106+
@flaky(max_runs=3)
21052107
@pytest.mark.asyncio
21062108
async def test_async_eth_replace_transaction(
21072109
self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress
@@ -2136,6 +2138,7 @@ async def test_async_eth_replace_transaction(
21362138
assert replace_txn["maxFeePerGas"] == three_gwei_in_wei
21372139
assert replace_txn["maxPriorityFeePerGas"] == two_gwei_in_wei
21382140

2141+
@flaky(max_runs=3)
21392142
@pytest.mark.asyncio
21402143
async def test_async_eth_replace_transaction_underpriced(
21412144
self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress
@@ -2258,6 +2261,7 @@ async def test_async_eth_replace_transaction_gas_price_defaulting_minimum(
22582261
gas_price * 1.125
22592262
) # minimum gas price
22602263

2264+
@flaky(max_runs=3)
22612265
@pytest.mark.asyncio
22622266
async def test_async_eth_replace_transaction_gas_price_defaulting_strategy_higher(
22632267
self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress
@@ -2286,6 +2290,7 @@ def higher_gas_price_strategy(async_w3: "AsyncWeb3", txn: TxParams) -> Wei:
22862290
) # Strategy provides higher gas price
22872291
async_w3.eth.set_gas_price_strategy(None) # reset strategy
22882292

2293+
@flaky(max_runs=3)
22892294
@pytest.mark.asyncio
22902295
async def test_async_eth_replace_transaction_gas_price_defaulting_strategy_lower(
22912296
self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress
@@ -2335,7 +2340,6 @@ async def test_async_eth_new_block_filter(self, async_w3: "AsyncWeb3") -> None:
23352340

23362341
changes = await async_w3.eth.get_filter_changes(filter.filter_id)
23372342
assert is_list_like(changes)
2338-
assert not changes
23392343

23402344
result = await async_w3.eth.uninstall_filter(filter.filter_id)
23412345
assert result is True
@@ -2999,6 +3003,7 @@ def test_eth_send_transaction(
29993003
assert txn["maxPriorityFeePerGas"] == txn_params["maxPriorityFeePerGas"]
30003004
assert txn["gasPrice"] == txn_params["maxFeePerGas"]
30013005

3006+
@flaky(max_runs=3)
30023007
def test_eth_send_transaction_with_nonce(
30033008
self, w3: "Web3", unlocked_account: ChecksumAddress
30043009
) -> None:
@@ -3260,6 +3265,7 @@ def gas_price_strategy(_w3: "Web3", _txn: TxParams) -> str:
32603265
assert txn["gasPrice"] == two_gwei_in_wei
32613266
w3.eth.set_gas_price_strategy(None) # reset strategy
32623267

3268+
@flaky(max_runs=3)
32633269
def test_eth_replace_transaction_legacy(
32643270
self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress
32653271
) -> None:
@@ -3288,7 +3294,7 @@ def test_eth_replace_transaction_legacy(
32883294
assert replace_txn["gas"] == 21000
32893295
assert replace_txn["gasPrice"] == txn_params["gasPrice"]
32903296

3291-
@flaky(max_runs=5)
3297+
@flaky(max_runs=3)
32923298
def test_eth_replace_transaction(
32933299
self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress
32943300
) -> None:
@@ -3416,6 +3422,7 @@ def test_eth_replace_transaction_gas_price_too_low(
34163422
with pytest.raises(ValueError):
34173423
w3.eth.replace_transaction(txn_hash, txn_params)
34183424

3425+
@flaky(max_runs=3)
34193426
def test_eth_replace_transaction_gas_price_defaulting_minimum(
34203427
self, w3: "Web3", unlocked_account: ChecksumAddress
34213428
) -> None:
@@ -3438,6 +3445,7 @@ def test_eth_replace_transaction_gas_price_defaulting_minimum(
34383445
gas_price * 1.125
34393446
) # minimum gas price
34403447

3448+
@flaky(max_runs=3)
34413449
def test_eth_replace_transaction_gas_price_defaulting_strategy_higher(
34423450
self, w3: "Web3", unlocked_account: ChecksumAddress
34433451
) -> None:
@@ -3465,6 +3473,7 @@ def higher_gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei:
34653473
) # Strategy provides higher gas price
34663474
w3.eth.set_gas_price_strategy(None) # reset strategy
34673475

3476+
@flaky(max_runs=3)
34683477
def test_eth_replace_transaction_gas_price_defaulting_strategy_lower(
34693478
self, w3: "Web3", unlocked_account: ChecksumAddress
34703479
) -> None:
@@ -3491,6 +3500,7 @@ def lower_gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei:
34913500
assert replace_txn["gasPrice"] == math.ceil(gas_price * 1.125)
34923501
w3.eth.set_gas_price_strategy(None) # reset strategy
34933502

3503+
@flaky(max_runs=3)
34943504
def test_eth_modify_transaction_legacy(
34953505
self, w3: "Web3", unlocked_account: ChecksumAddress
34963506
) -> None:
@@ -3520,6 +3530,7 @@ def test_eth_modify_transaction_legacy(
35203530
assert modified_txn["gas"] == 21000
35213531
assert modified_txn["gasPrice"] == cast(int, txn_params["gasPrice"]) * 2
35223532

3533+
@flaky(max_runs=3)
35233534
def test_eth_modify_transaction(
35243535
self, w3: "Web3", unlocked_account: ChecksumAddress
35253536
) -> None:

0 commit comments

Comments
 (0)