web3 7.0.0b3__py3-none-any.whl → 7.0.0b5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ens/_normalization.py +1 -3
- ens/async_ens.py +12 -9
- ens/contract_data.py +2 -2
- ens/ens.py +8 -5
- ens/exceptions.py +19 -27
- ens/specs/nf.json +1 -1
- ens/specs/normalization_spec.json +1 -1
- ens/utils.py +17 -10
- web3/__init__.py +2 -7
- web3/_utils/abi.py +30 -29
- web3/_utils/async_transactions.py +7 -4
- web3/_utils/blocks.py +6 -2
- web3/_utils/caching.py +7 -3
- web3/_utils/compat/__init__.py +0 -3
- web3/_utils/contract_sources/compile_contracts.py +1 -1
- web3/_utils/contracts.py +17 -17
- web3/_utils/datatypes.py +5 -1
- web3/_utils/decorators.py +6 -1
- web3/_utils/empty.py +1 -1
- web3/_utils/encoding.py +15 -10
- web3/_utils/error_formatters_utils.py +5 -3
- web3/_utils/events.py +38 -36
- web3/_utils/fee_utils.py +2 -4
- web3/_utils/filters.py +23 -18
- web3/_utils/formatters.py +2 -2
- web3/_utils/math.py +3 -2
- web3/_utils/method_formatters.py +24 -28
- web3/_utils/module.py +2 -1
- web3/_utils/module_testing/__init__.py +0 -3
- web3/_utils/module_testing/eth_module.py +494 -432
- web3/_utils/module_testing/module_testing_utils.py +1 -3
- web3/_utils/module_testing/utils.py +14 -7
- web3/_utils/normalizers.py +3 -3
- web3/_utils/request.py +4 -4
- web3/_utils/rpc_abi.py +5 -19
- web3/_utils/threads.py +8 -7
- web3/_utils/transactions.py +14 -12
- web3/_utils/type_conversion.py +5 -1
- web3/_utils/validation.py +12 -10
- web3/contract/async_contract.py +23 -18
- web3/contract/base_contract.py +69 -74
- web3/contract/contract.py +25 -19
- web3/contract/utils.py +11 -6
- web3/datastructures.py +22 -12
- web3/eth/async_eth.py +38 -32
- web3/eth/base_eth.py +7 -3
- web3/eth/eth.py +20 -15
- web3/exceptions.py +83 -78
- web3/gas_strategies/time_based.py +2 -4
- web3/geth.py +1 -191
- web3/main.py +6 -6
- web3/manager.py +128 -68
- web3/method.py +13 -5
- web3/middleware/base.py +4 -2
- web3/middleware/filter.py +45 -23
- web3/middleware/formatting.py +6 -3
- web3/middleware/names.py +4 -1
- web3/middleware/signing.py +8 -4
- web3/middleware/stalecheck.py +2 -1
- web3/providers/eth_tester/defaults.py +1 -49
- web3/providers/eth_tester/main.py +41 -15
- web3/providers/eth_tester/middleware.py +13 -9
- web3/providers/ipc.py +7 -3
- web3/providers/persistent/async_ipc.py +6 -7
- web3/providers/persistent/persistent.py +11 -1
- web3/providers/persistent/request_processor.py +7 -7
- web3/providers/persistent/websocket.py +3 -3
- web3/providers/rpc/async_rpc.py +24 -7
- web3/providers/rpc/rpc.py +30 -17
- web3/providers/rpc/utils.py +1 -10
- web3/testing.py +4 -4
- web3/tools/benchmark/main.py +13 -9
- web3/tools/benchmark/node.py +2 -8
- web3/tools/benchmark/utils.py +1 -1
- web3/tracing.py +9 -5
- web3/types.py +20 -23
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/METADATA +13 -28
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/RECORD +81 -82
- web3/_utils/module_testing/go_ethereum_personal_module.py +0 -300
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/LICENSE +0 -0
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/WHEEL +0 -0
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/top_level.txt +0 -0
|
@@ -5,6 +5,7 @@ from random import (
|
|
|
5
5
|
randint,
|
|
6
6
|
)
|
|
7
7
|
import re
|
|
8
|
+
import time
|
|
8
9
|
from typing import (
|
|
9
10
|
TYPE_CHECKING,
|
|
10
11
|
Any,
|
|
@@ -82,7 +83,9 @@ from web3.exceptions import (
|
|
|
82
83
|
TooManyRequests,
|
|
83
84
|
TransactionNotFound,
|
|
84
85
|
TransactionTypeMismatch,
|
|
86
|
+
Web3RPCError,
|
|
85
87
|
Web3ValidationError,
|
|
88
|
+
Web3ValueError,
|
|
86
89
|
)
|
|
87
90
|
from web3.middleware import (
|
|
88
91
|
ExtraDataToPOAMiddleware,
|
|
@@ -139,7 +142,10 @@ RPC_ACCESS_LIST = [
|
|
|
139
142
|
if TYPE_CHECKING:
|
|
140
143
|
from _pytest.monkeypatch import MonkeyPatch # noqa: F401
|
|
141
144
|
|
|
142
|
-
from web3.contract import
|
|
145
|
+
from web3.contract import ( # noqa: F401
|
|
146
|
+
AsyncContract,
|
|
147
|
+
Contract,
|
|
148
|
+
)
|
|
143
149
|
from web3.main import ( # noqa: F401
|
|
144
150
|
AsyncWeb3,
|
|
145
151
|
Web3,
|
|
@@ -147,7 +153,8 @@ if TYPE_CHECKING:
|
|
|
147
153
|
|
|
148
154
|
|
|
149
155
|
def abi_encoded_offchain_lookup_contract_address(
|
|
150
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
156
|
+
w3: Union["Web3", "AsyncWeb3"],
|
|
157
|
+
offchain_lookup_contract: Union["Contract", "AsyncContract"],
|
|
151
158
|
) -> HexAddress:
|
|
152
159
|
return HexAddress(
|
|
153
160
|
remove_0x_prefix(
|
|
@@ -175,11 +182,13 @@ class AsyncEthModuleTest:
|
|
|
175
182
|
|
|
176
183
|
@pytest.mark.asyncio
|
|
177
184
|
async def test_eth_send_transaction_legacy(
|
|
178
|
-
self,
|
|
185
|
+
self,
|
|
186
|
+
async_w3: "AsyncWeb3",
|
|
187
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
179
188
|
) -> None:
|
|
180
189
|
txn_params: TxParams = {
|
|
181
|
-
"from":
|
|
182
|
-
"to":
|
|
190
|
+
"from": async_keyfile_account_address_dual_type,
|
|
191
|
+
"to": async_keyfile_account_address_dual_type,
|
|
183
192
|
"value": Wei(1),
|
|
184
193
|
"gas": 21000,
|
|
185
194
|
"gasPrice": await async_w3.eth.gas_price,
|
|
@@ -195,11 +204,13 @@ class AsyncEthModuleTest:
|
|
|
195
204
|
|
|
196
205
|
@pytest.mark.asyncio
|
|
197
206
|
async def test_eth_modify_transaction_legacy(
|
|
198
|
-
self,
|
|
207
|
+
self,
|
|
208
|
+
async_w3: "AsyncWeb3",
|
|
209
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
199
210
|
) -> None:
|
|
200
211
|
txn_params: TxParams = {
|
|
201
|
-
"from":
|
|
202
|
-
"to":
|
|
212
|
+
"from": async_keyfile_account_address_dual_type,
|
|
213
|
+
"to": async_keyfile_account_address_dual_type,
|
|
203
214
|
"value": Wei(1),
|
|
204
215
|
"gas": 21000,
|
|
205
216
|
"gasPrice": async_w3.to_wei(
|
|
@@ -225,11 +236,13 @@ class AsyncEthModuleTest:
|
|
|
225
236
|
|
|
226
237
|
@pytest.mark.asyncio
|
|
227
238
|
async def test_eth_modify_transaction(
|
|
228
|
-
self,
|
|
239
|
+
self,
|
|
240
|
+
async_w3: "AsyncWeb3",
|
|
241
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
229
242
|
) -> None:
|
|
230
243
|
txn_params: TxParams = {
|
|
231
|
-
"from":
|
|
232
|
-
"to":
|
|
244
|
+
"from": async_keyfile_account_address_dual_type,
|
|
245
|
+
"to": async_keyfile_account_address_dual_type,
|
|
233
246
|
"value": Wei(1),
|
|
234
247
|
"gas": 21000,
|
|
235
248
|
"maxPriorityFeePerGas": async_w3.to_wei(1, "gwei"),
|
|
@@ -261,11 +274,13 @@ class AsyncEthModuleTest:
|
|
|
261
274
|
|
|
262
275
|
@pytest.mark.asyncio
|
|
263
276
|
async def test_async_eth_sign_transaction(
|
|
264
|
-
self,
|
|
277
|
+
self,
|
|
278
|
+
async_w3: "AsyncWeb3",
|
|
279
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
265
280
|
) -> None:
|
|
266
281
|
txn_params: TxParams = {
|
|
267
|
-
"from":
|
|
268
|
-
"to":
|
|
282
|
+
"from": async_keyfile_account_address_dual_type,
|
|
283
|
+
"to": async_keyfile_account_address_dual_type,
|
|
269
284
|
"value": Wei(1),
|
|
270
285
|
"gas": 21000,
|
|
271
286
|
"maxFeePerGas": async_w3.to_wei(2, "gwei"),
|
|
@@ -274,7 +289,7 @@ class AsyncEthModuleTest:
|
|
|
274
289
|
}
|
|
275
290
|
result = await async_w3.eth.sign_transaction(txn_params)
|
|
276
291
|
signatory_account = async_w3.eth.account.recover_transaction(result["raw"])
|
|
277
|
-
assert
|
|
292
|
+
assert async_keyfile_account_address_dual_type == signatory_account
|
|
278
293
|
assert result["tx"]["to"] == txn_params["to"]
|
|
279
294
|
assert result["tx"]["value"] == txn_params["value"]
|
|
280
295
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -288,7 +303,7 @@ class AsyncEthModuleTest:
|
|
|
288
303
|
async def test_eth_sign_typed_data(
|
|
289
304
|
self,
|
|
290
305
|
async_w3: "AsyncWeb3",
|
|
291
|
-
|
|
306
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
292
307
|
async_skip_if_testrpc: Callable[["AsyncWeb3"], None],
|
|
293
308
|
) -> None:
|
|
294
309
|
validJSONMessage = """
|
|
@@ -333,7 +348,7 @@ class AsyncEthModuleTest:
|
|
|
333
348
|
async_skip_if_testrpc(async_w3)
|
|
334
349
|
signature = HexBytes(
|
|
335
350
|
await async_w3.eth.sign_typed_data(
|
|
336
|
-
|
|
351
|
+
async_keyfile_account_address_dual_type, json.loads(validJSONMessage)
|
|
337
352
|
)
|
|
338
353
|
)
|
|
339
354
|
assert len(signature) == 32 + 32 + 1
|
|
@@ -342,7 +357,7 @@ class AsyncEthModuleTest:
|
|
|
342
357
|
async def test_invalid_eth_sign_typed_data(
|
|
343
358
|
self,
|
|
344
359
|
async_w3: "AsyncWeb3",
|
|
345
|
-
|
|
360
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
346
361
|
async_skip_if_testrpc: Callable[["AsyncWeb3"], None],
|
|
347
362
|
) -> None:
|
|
348
363
|
async_skip_if_testrpc(async_w3)
|
|
@@ -386,20 +401,21 @@ class AsyncEthModuleTest:
|
|
|
386
401
|
}
|
|
387
402
|
"""
|
|
388
403
|
with pytest.raises(
|
|
389
|
-
|
|
404
|
+
Web3ValueError,
|
|
390
405
|
match=r".*Expected 2 items for array type Person\[2\], got 1 items.*",
|
|
391
406
|
):
|
|
392
407
|
await async_w3.eth.sign_typed_data(
|
|
393
|
-
|
|
408
|
+
async_keyfile_account_address_dual_type,
|
|
409
|
+
json.loads(invalid_typed_message),
|
|
394
410
|
)
|
|
395
411
|
|
|
396
412
|
@pytest.mark.asyncio
|
|
397
413
|
async def test_async_eth_sign_transaction_legacy(
|
|
398
|
-
self, async_w3: "AsyncWeb3",
|
|
414
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
399
415
|
) -> None:
|
|
400
416
|
txn_params: TxParams = {
|
|
401
|
-
"from":
|
|
402
|
-
"to":
|
|
417
|
+
"from": async_keyfile_account_address,
|
|
418
|
+
"to": async_keyfile_account_address,
|
|
403
419
|
"value": Wei(1),
|
|
404
420
|
"gas": 21000,
|
|
405
421
|
"gasPrice": await async_w3.eth.gas_price,
|
|
@@ -407,7 +423,7 @@ class AsyncEthModuleTest:
|
|
|
407
423
|
}
|
|
408
424
|
result = await async_w3.eth.sign_transaction(txn_params)
|
|
409
425
|
signatory_account = async_w3.eth.account.recover_transaction(result["raw"])
|
|
410
|
-
assert
|
|
426
|
+
assert async_keyfile_account_address == signatory_account
|
|
411
427
|
assert result["tx"]["to"] == txn_params["to"]
|
|
412
428
|
assert result["tx"]["value"] == txn_params["value"]
|
|
413
429
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -416,11 +432,11 @@ class AsyncEthModuleTest:
|
|
|
416
432
|
|
|
417
433
|
@pytest.mark.asyncio
|
|
418
434
|
async def test_async_eth_sign_transaction_hex_fees(
|
|
419
|
-
self, async_w3: "AsyncWeb3",
|
|
435
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
420
436
|
) -> None:
|
|
421
437
|
txn_params: TxParams = {
|
|
422
|
-
"from":
|
|
423
|
-
"to":
|
|
438
|
+
"from": async_keyfile_account_address,
|
|
439
|
+
"to": async_keyfile_account_address,
|
|
424
440
|
"value": Wei(1),
|
|
425
441
|
"gas": 21000,
|
|
426
442
|
"maxFeePerGas": hex(async_w3.to_wei(2, "gwei")),
|
|
@@ -429,7 +445,7 @@ class AsyncEthModuleTest:
|
|
|
429
445
|
}
|
|
430
446
|
result = await async_w3.eth.sign_transaction(txn_params)
|
|
431
447
|
signatory_account = async_w3.eth.account.recover_transaction(result["raw"])
|
|
432
|
-
assert
|
|
448
|
+
assert async_keyfile_account_address == signatory_account
|
|
433
449
|
assert result["tx"]["to"] == txn_params["to"]
|
|
434
450
|
assert result["tx"]["value"] == txn_params["value"]
|
|
435
451
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -444,9 +460,11 @@ class AsyncEthModuleTest:
|
|
|
444
460
|
reason="async name_to_address_middleware has not been implemented yet"
|
|
445
461
|
)
|
|
446
462
|
async def test_async_eth_sign_transaction_ens_names(
|
|
447
|
-
self, async_w3: "AsyncWeb3",
|
|
463
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
448
464
|
) -> None:
|
|
449
|
-
with ens_addresses(
|
|
465
|
+
with ens_addresses(
|
|
466
|
+
async_w3, {"unlocked-account.eth": async_keyfile_account_address}
|
|
467
|
+
):
|
|
450
468
|
txn_params: TxParams = {
|
|
451
469
|
"from": "unlocked-account.eth",
|
|
452
470
|
"to": "unlocked-account.eth",
|
|
@@ -458,8 +476,8 @@ class AsyncEthModuleTest:
|
|
|
458
476
|
}
|
|
459
477
|
result = await async_w3.eth.sign_transaction(txn_params)
|
|
460
478
|
signatory_account = async_w3.eth.account.recover_transaction(result["raw"])
|
|
461
|
-
assert
|
|
462
|
-
assert result["tx"]["to"] ==
|
|
479
|
+
assert async_keyfile_account_address == signatory_account
|
|
480
|
+
assert result["tx"]["to"] == async_keyfile_account_address
|
|
463
481
|
assert result["tx"]["value"] == txn_params["value"]
|
|
464
482
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
465
483
|
assert result["tx"]["maxFeePerGas"] == txn_params["maxFeePerGas"]
|
|
@@ -471,11 +489,13 @@ class AsyncEthModuleTest:
|
|
|
471
489
|
|
|
472
490
|
@pytest.mark.asyncio
|
|
473
491
|
async def test_eth_send_transaction(
|
|
474
|
-
self,
|
|
492
|
+
self,
|
|
493
|
+
async_w3: "AsyncWeb3",
|
|
494
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
475
495
|
) -> None:
|
|
476
496
|
txn_params: TxParams = {
|
|
477
|
-
"from":
|
|
478
|
-
"to":
|
|
497
|
+
"from": async_keyfile_account_address_dual_type,
|
|
498
|
+
"to": async_keyfile_account_address_dual_type,
|
|
479
499
|
"value": Wei(1),
|
|
480
500
|
"gas": 21000,
|
|
481
501
|
"maxFeePerGas": async_w3.to_wei(3, "gwei"),
|
|
@@ -494,11 +514,13 @@ class AsyncEthModuleTest:
|
|
|
494
514
|
|
|
495
515
|
@pytest.mark.asyncio
|
|
496
516
|
async def test_eth_send_transaction_default_fees(
|
|
497
|
-
self,
|
|
517
|
+
self,
|
|
518
|
+
async_w3: "AsyncWeb3",
|
|
519
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
498
520
|
) -> None:
|
|
499
521
|
txn_params: TxParams = {
|
|
500
|
-
"from":
|
|
501
|
-
"to":
|
|
522
|
+
"from": async_keyfile_account_address_dual_type,
|
|
523
|
+
"to": async_keyfile_account_address_dual_type,
|
|
502
524
|
"value": Wei(1),
|
|
503
525
|
"gas": 21000,
|
|
504
526
|
}
|
|
@@ -515,11 +537,13 @@ class AsyncEthModuleTest:
|
|
|
515
537
|
|
|
516
538
|
@pytest.mark.asyncio
|
|
517
539
|
async def test_eth_send_transaction_hex_fees(
|
|
518
|
-
self,
|
|
540
|
+
self,
|
|
541
|
+
async_w3: "AsyncWeb3",
|
|
542
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
519
543
|
) -> None:
|
|
520
544
|
txn_params: TxParams = {
|
|
521
|
-
"from":
|
|
522
|
-
"to":
|
|
545
|
+
"from": async_keyfile_account_address_dual_type,
|
|
546
|
+
"to": async_keyfile_account_address_dual_type,
|
|
523
547
|
"value": Wei(1),
|
|
524
548
|
"gas": 21000,
|
|
525
549
|
"maxFeePerGas": hex(250 * 10**9),
|
|
@@ -537,11 +561,13 @@ class AsyncEthModuleTest:
|
|
|
537
561
|
|
|
538
562
|
@pytest.mark.asyncio
|
|
539
563
|
async def test_eth_send_transaction_no_gas(
|
|
540
|
-
self,
|
|
564
|
+
self,
|
|
565
|
+
async_w3: "AsyncWeb3",
|
|
566
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
541
567
|
) -> None:
|
|
542
568
|
txn_params: TxParams = {
|
|
543
|
-
"from":
|
|
544
|
-
"to":
|
|
569
|
+
"from": async_keyfile_account_address_dual_type,
|
|
570
|
+
"to": async_keyfile_account_address_dual_type,
|
|
545
571
|
"value": Wei(1),
|
|
546
572
|
"maxFeePerGas": Wei(250 * 10**9),
|
|
547
573
|
"maxPriorityFeePerGas": Wei(2 * 10**9),
|
|
@@ -556,11 +582,13 @@ class AsyncEthModuleTest:
|
|
|
556
582
|
|
|
557
583
|
@pytest.mark.asyncio
|
|
558
584
|
async def test_eth_send_transaction_with_gas_price(
|
|
559
|
-
self,
|
|
585
|
+
self,
|
|
586
|
+
async_w3: "AsyncWeb3",
|
|
587
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
560
588
|
) -> None:
|
|
561
589
|
txn_params: TxParams = {
|
|
562
|
-
"from":
|
|
563
|
-
"to":
|
|
590
|
+
"from": async_keyfile_account_address_dual_type,
|
|
591
|
+
"to": async_keyfile_account_address_dual_type,
|
|
564
592
|
"value": Wei(1),
|
|
565
593
|
"gas": 21000,
|
|
566
594
|
"gasPrice": Wei(1),
|
|
@@ -572,11 +600,13 @@ class AsyncEthModuleTest:
|
|
|
572
600
|
|
|
573
601
|
@pytest.mark.asyncio
|
|
574
602
|
async def test_eth_send_transaction_no_priority_fee(
|
|
575
|
-
self,
|
|
603
|
+
self,
|
|
604
|
+
async_w3: "AsyncWeb3",
|
|
605
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
576
606
|
) -> None:
|
|
577
607
|
txn_params: TxParams = {
|
|
578
|
-
"from":
|
|
579
|
-
"to":
|
|
608
|
+
"from": async_keyfile_account_address_dual_type,
|
|
609
|
+
"to": async_keyfile_account_address_dual_type,
|
|
580
610
|
"value": Wei(1),
|
|
581
611
|
"gas": 21000,
|
|
582
612
|
"maxFeePerGas": Wei(250 * 10**9),
|
|
@@ -588,12 +618,14 @@ class AsyncEthModuleTest:
|
|
|
588
618
|
|
|
589
619
|
@pytest.mark.asyncio
|
|
590
620
|
async def test_eth_send_transaction_no_max_fee(
|
|
591
|
-
self,
|
|
621
|
+
self,
|
|
622
|
+
async_w3: "AsyncWeb3",
|
|
623
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
592
624
|
) -> None:
|
|
593
625
|
maxPriorityFeePerGas = async_w3.to_wei(2, "gwei")
|
|
594
626
|
txn_params: TxParams = {
|
|
595
|
-
"from":
|
|
596
|
-
"to":
|
|
627
|
+
"from": async_keyfile_account_address_dual_type,
|
|
628
|
+
"to": async_keyfile_account_address_dual_type,
|
|
597
629
|
"value": Wei(1),
|
|
598
630
|
"gas": 21000,
|
|
599
631
|
"maxPriorityFeePerGas": maxPriorityFeePerGas,
|
|
@@ -611,11 +643,13 @@ class AsyncEthModuleTest:
|
|
|
611
643
|
|
|
612
644
|
@pytest.mark.asyncio
|
|
613
645
|
async def test_eth_send_transaction_max_fee_less_than_tip(
|
|
614
|
-
self,
|
|
646
|
+
self,
|
|
647
|
+
async_w3: "AsyncWeb3",
|
|
648
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
615
649
|
) -> None:
|
|
616
650
|
txn_params: TxParams = {
|
|
617
|
-
"from":
|
|
618
|
-
"to":
|
|
651
|
+
"from": async_keyfile_account_address_dual_type,
|
|
652
|
+
"to": async_keyfile_account_address_dual_type,
|
|
619
653
|
"value": Wei(1),
|
|
620
654
|
"gas": 21000,
|
|
621
655
|
"maxFeePerGas": Wei(1 * 10**9),
|
|
@@ -628,14 +662,16 @@ class AsyncEthModuleTest:
|
|
|
628
662
|
|
|
629
663
|
@pytest.mark.asyncio
|
|
630
664
|
async def test_validation_middleware_chain_id_mismatch(
|
|
631
|
-
self,
|
|
665
|
+
self,
|
|
666
|
+
async_w3: "AsyncWeb3",
|
|
667
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
632
668
|
) -> None:
|
|
633
669
|
wrong_chain_id = 1234567890
|
|
634
670
|
actual_chain_id = await async_w3.eth.chain_id
|
|
635
671
|
|
|
636
672
|
txn_params: TxParams = {
|
|
637
|
-
"from":
|
|
638
|
-
"to":
|
|
673
|
+
"from": async_keyfile_account_address_dual_type,
|
|
674
|
+
"to": async_keyfile_account_address_dual_type,
|
|
639
675
|
"value": Wei(1),
|
|
640
676
|
"gas": 21000,
|
|
641
677
|
"maxFeePerGas": async_w3.to_wei(2, "gwei"),
|
|
@@ -669,29 +705,34 @@ class AsyncEthModuleTest:
|
|
|
669
705
|
async_w3.middleware_onion.remove("poa")
|
|
670
706
|
|
|
671
707
|
@pytest.mark.asyncio
|
|
672
|
-
async def
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
"
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
708
|
+
async def test_async_eth_send_raw_transaction(
|
|
709
|
+
self, async_w3: "AsyncWeb3", keyfile_account_pkey: HexStr
|
|
710
|
+
) -> None:
|
|
711
|
+
keyfile_account = async_w3.eth.account.from_key(keyfile_account_pkey)
|
|
712
|
+
txn = {
|
|
713
|
+
"chainId": 131277322940537, # the chainId set for the fixture
|
|
714
|
+
"from": keyfile_account.address,
|
|
715
|
+
"to": keyfile_account.address,
|
|
716
|
+
"value": Wei(0),
|
|
717
|
+
"gas": 21000,
|
|
718
|
+
"nonce": await async_w3.eth.get_transaction_count(
|
|
719
|
+
keyfile_account.address, "pending"
|
|
720
|
+
),
|
|
721
|
+
"gasPrice": 10**9,
|
|
722
|
+
}
|
|
723
|
+
signed = keyfile_account.sign_transaction(txn)
|
|
724
|
+
txn_hash = await async_w3.eth.send_raw_transaction(signed.rawTransaction)
|
|
725
|
+
assert txn_hash == HexBytes(signed.hash)
|
|
687
726
|
|
|
688
727
|
@pytest.mark.asyncio
|
|
689
728
|
async def test_GasPriceStrategyMiddleware(
|
|
690
|
-
self,
|
|
729
|
+
self,
|
|
730
|
+
async_w3: "AsyncWeb3",
|
|
731
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
691
732
|
) -> None:
|
|
692
733
|
txn_params: TxParams = {
|
|
693
|
-
"from":
|
|
694
|
-
"to":
|
|
734
|
+
"from": async_keyfile_account_address_dual_type,
|
|
735
|
+
"to": async_keyfile_account_address_dual_type,
|
|
695
736
|
"value": Wei(1),
|
|
696
737
|
"gas": 21000,
|
|
697
738
|
}
|
|
@@ -710,11 +751,13 @@ class AsyncEthModuleTest:
|
|
|
710
751
|
|
|
711
752
|
@pytest.mark.asyncio
|
|
712
753
|
async def test_gas_price_strategy_middleware_hex_value(
|
|
713
|
-
self,
|
|
754
|
+
self,
|
|
755
|
+
async_w3: "AsyncWeb3",
|
|
756
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
714
757
|
) -> None:
|
|
715
758
|
txn_params: TxParams = {
|
|
716
|
-
"from":
|
|
717
|
-
"to":
|
|
759
|
+
"from": async_keyfile_account_address_dual_type,
|
|
760
|
+
"to": async_keyfile_account_address_dual_type,
|
|
718
761
|
"value": Wei(1),
|
|
719
762
|
"gas": 21000,
|
|
720
763
|
}
|
|
@@ -738,13 +781,13 @@ class AsyncEthModuleTest:
|
|
|
738
781
|
async def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn(
|
|
739
782
|
self,
|
|
740
783
|
async_w3: "AsyncWeb3",
|
|
741
|
-
|
|
784
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
742
785
|
max_fee: Wei,
|
|
743
786
|
) -> None:
|
|
744
787
|
max_priority_fee = async_w3.to_wei(1, "gwei")
|
|
745
788
|
txn_params: TxParams = {
|
|
746
|
-
"from":
|
|
747
|
-
"to":
|
|
789
|
+
"from": async_keyfile_account_address_dual_type,
|
|
790
|
+
"to": async_keyfile_account_address_dual_type,
|
|
748
791
|
"value": Wei(1),
|
|
749
792
|
"gas": 21000,
|
|
750
793
|
"maxPriorityFeePerGas": max_priority_fee,
|
|
@@ -775,11 +818,11 @@ class AsyncEthModuleTest:
|
|
|
775
818
|
async def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn_no_tip(
|
|
776
819
|
self,
|
|
777
820
|
async_w3: "AsyncWeb3",
|
|
778
|
-
|
|
821
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
779
822
|
) -> None:
|
|
780
823
|
txn_params: TxParams = {
|
|
781
|
-
"from":
|
|
782
|
-
"to":
|
|
824
|
+
"from": async_keyfile_account_address_dual_type,
|
|
825
|
+
"to": async_keyfile_account_address_dual_type,
|
|
783
826
|
"value": Wei(1),
|
|
784
827
|
"gas": 21000,
|
|
785
828
|
"maxFeePerGas": Wei(1000000000),
|
|
@@ -799,12 +842,14 @@ class AsyncEthModuleTest:
|
|
|
799
842
|
|
|
800
843
|
@pytest.mark.asyncio
|
|
801
844
|
async def test_eth_estimate_gas(
|
|
802
|
-
self,
|
|
845
|
+
self,
|
|
846
|
+
async_w3: "AsyncWeb3",
|
|
847
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
803
848
|
) -> None:
|
|
804
849
|
gas_estimate = await async_w3.eth.estimate_gas(
|
|
805
850
|
{
|
|
806
|
-
"from":
|
|
807
|
-
"to":
|
|
851
|
+
"from": async_keyfile_account_address_dual_type,
|
|
852
|
+
"to": async_keyfile_account_address_dual_type,
|
|
808
853
|
"value": Wei(1),
|
|
809
854
|
}
|
|
810
855
|
)
|
|
@@ -834,7 +879,7 @@ class AsyncEthModuleTest:
|
|
|
834
879
|
async def test_eth_estimate_gas_with_override_param_type_check(
|
|
835
880
|
self,
|
|
836
881
|
async_w3: "AsyncWeb3",
|
|
837
|
-
async_math_contract: "
|
|
882
|
+
async_math_contract: "AsyncContract",
|
|
838
883
|
params: StateOverrideParams,
|
|
839
884
|
) -> None:
|
|
840
885
|
txn_params: TxParams = {"from": await async_w3.eth.coinbase}
|
|
@@ -1039,14 +1084,14 @@ class AsyncEthModuleTest:
|
|
|
1039
1084
|
self,
|
|
1040
1085
|
async_w3: "AsyncWeb3",
|
|
1041
1086
|
async_block_with_txn: BlockData,
|
|
1042
|
-
|
|
1087
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1043
1088
|
) -> None:
|
|
1044
1089
|
# eth_getRawTransactionByBlockNumberAndIndex: block identifier
|
|
1045
1090
|
# send a txn to make sure pending block has at least one txn
|
|
1046
1091
|
await async_w3.eth.send_transaction(
|
|
1047
1092
|
{
|
|
1048
|
-
"from":
|
|
1049
|
-
"to":
|
|
1093
|
+
"from": async_keyfile_account_address_dual_type,
|
|
1094
|
+
"to": async_keyfile_account_address_dual_type,
|
|
1050
1095
|
"value": Wei(1),
|
|
1051
1096
|
}
|
|
1052
1097
|
)
|
|
@@ -1094,15 +1139,13 @@ class AsyncEthModuleTest:
|
|
|
1094
1139
|
) -> None:
|
|
1095
1140
|
unknown_identifier = "unknown"
|
|
1096
1141
|
with pytest.raises(
|
|
1097
|
-
|
|
1142
|
+
Web3ValueError,
|
|
1098
1143
|
match=(
|
|
1099
1144
|
"Value did not match any of the recognized block identifiers: "
|
|
1100
1145
|
f"{unknown_identifier}"
|
|
1101
1146
|
),
|
|
1102
1147
|
):
|
|
1103
|
-
await async_w3.eth.get_raw_transaction_by_block(
|
|
1104
|
-
unknown_identifier, 0 # type: ignore
|
|
1105
|
-
)
|
|
1148
|
+
await async_w3.eth.get_raw_transaction_by_block(unknown_identifier, 0)
|
|
1106
1149
|
|
|
1107
1150
|
@pytest.mark.asyncio
|
|
1108
1151
|
async def test_eth_get_balance(self, async_w3: "AsyncWeb3") -> None:
|
|
@@ -1130,7 +1173,7 @@ class AsyncEthModuleTest:
|
|
|
1130
1173
|
async def test_eth_get_code_invalid_address(
|
|
1131
1174
|
self,
|
|
1132
1175
|
async_w3: "AsyncWeb3",
|
|
1133
|
-
async_math_contract: "
|
|
1176
|
+
async_math_contract: "AsyncContract",
|
|
1134
1177
|
) -> None:
|
|
1135
1178
|
with pytest.raises(InvalidAddress):
|
|
1136
1179
|
await async_w3.eth.get_code(
|
|
@@ -1139,7 +1182,7 @@ class AsyncEthModuleTest:
|
|
|
1139
1182
|
|
|
1140
1183
|
@pytest.mark.asyncio
|
|
1141
1184
|
async def test_eth_get_code_with_block_identifier(
|
|
1142
|
-
self, async_w3: "AsyncWeb3", async_emitter_contract: "
|
|
1185
|
+
self, async_w3: "AsyncWeb3", async_emitter_contract: "AsyncContract"
|
|
1143
1186
|
) -> None:
|
|
1144
1187
|
block_id = await async_w3.eth.block_number
|
|
1145
1188
|
code = await async_w3.eth.get_code(async_emitter_contract.address, block_id)
|
|
@@ -1150,29 +1193,16 @@ class AsyncEthModuleTest:
|
|
|
1150
1193
|
async def test_eth_create_access_list(
|
|
1151
1194
|
self,
|
|
1152
1195
|
async_w3: "AsyncWeb3",
|
|
1153
|
-
|
|
1154
|
-
async_math_contract: "
|
|
1196
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1197
|
+
async_math_contract: "AsyncContract",
|
|
1155
1198
|
) -> None:
|
|
1156
|
-
#
|
|
1157
|
-
|
|
1158
|
-
"from":
|
|
1159
|
-
"value": Wei(1),
|
|
1160
|
-
"gas": 21000,
|
|
1161
|
-
}
|
|
1162
|
-
txn = async_math_contract._prepare_transaction(
|
|
1163
|
-
fn_name="incrementCounter",
|
|
1164
|
-
fn_args=[1],
|
|
1165
|
-
transaction=txn_params,
|
|
1199
|
+
# build txn
|
|
1200
|
+
txn = await async_math_contract.functions.incrementCounter(1).build_transaction(
|
|
1201
|
+
{"from": async_keyfile_account_address_dual_type}
|
|
1166
1202
|
)
|
|
1167
1203
|
|
|
1168
|
-
# create access list
|
|
1169
|
-
response = await async_w3.eth.create_access_list(
|
|
1170
|
-
{
|
|
1171
|
-
"from": async_unlocked_account_dual_type,
|
|
1172
|
-
"to": async_math_contract.address,
|
|
1173
|
-
"data": txn["data"],
|
|
1174
|
-
}
|
|
1175
|
-
)
|
|
1204
|
+
# create access list
|
|
1205
|
+
response = await async_w3.eth.create_access_list(txn)
|
|
1176
1206
|
|
|
1177
1207
|
assert is_dict(response)
|
|
1178
1208
|
access_list = response["accessList"]
|
|
@@ -1182,19 +1212,28 @@ class AsyncEthModuleTest:
|
|
|
1182
1212
|
assert len(access_list[0]["storageKeys"][0]) == 32
|
|
1183
1213
|
assert int(response["gasUsed"]) >= 0
|
|
1184
1214
|
|
|
1215
|
+
# assert the result can be used directly in a transaction dict
|
|
1216
|
+
txn["accessList"] = response["accessList"]
|
|
1217
|
+
txn["gas"] = response["gasUsed"]
|
|
1218
|
+
|
|
1219
|
+
# send txn with access list
|
|
1220
|
+
await async_w3.eth.send_transaction(txn)
|
|
1221
|
+
|
|
1185
1222
|
@pytest.mark.asyncio
|
|
1186
1223
|
async def test_eth_get_transaction_count(
|
|
1187
|
-
self,
|
|
1224
|
+
self,
|
|
1225
|
+
async_w3: "AsyncWeb3",
|
|
1226
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1188
1227
|
) -> None:
|
|
1189
1228
|
transaction_count = await async_w3.eth.get_transaction_count(
|
|
1190
|
-
|
|
1229
|
+
async_keyfile_account_address_dual_type
|
|
1191
1230
|
)
|
|
1192
1231
|
assert is_integer(transaction_count)
|
|
1193
1232
|
assert transaction_count >= 0
|
|
1194
1233
|
|
|
1195
1234
|
@pytest.mark.asyncio
|
|
1196
1235
|
async def test_eth_call(
|
|
1197
|
-
self, async_w3: "AsyncWeb3", async_math_contract: "
|
|
1236
|
+
self, async_w3: "AsyncWeb3", async_math_contract: "AsyncContract"
|
|
1198
1237
|
) -> None:
|
|
1199
1238
|
coinbase = await async_w3.eth.coinbase
|
|
1200
1239
|
txn_params = async_math_contract._prepare_transaction(
|
|
@@ -1211,7 +1250,7 @@ class AsyncEthModuleTest:
|
|
|
1211
1250
|
async def test_eth_call_with_override_code(
|
|
1212
1251
|
self,
|
|
1213
1252
|
async_w3: "AsyncWeb3",
|
|
1214
|
-
async_revert_contract: "
|
|
1253
|
+
async_revert_contract: "AsyncContract",
|
|
1215
1254
|
) -> None:
|
|
1216
1255
|
coinbase = await async_w3.eth.coinbase
|
|
1217
1256
|
txn_params = async_revert_contract._prepare_transaction(
|
|
@@ -1267,7 +1306,7 @@ class AsyncEthModuleTest:
|
|
|
1267
1306
|
async def test_eth_call_with_override_param_type_check(
|
|
1268
1307
|
self,
|
|
1269
1308
|
async_w3: "AsyncWeb3",
|
|
1270
|
-
async_math_contract: "
|
|
1309
|
+
async_math_contract: "AsyncContract",
|
|
1271
1310
|
params: StateOverrideParams,
|
|
1272
1311
|
) -> None:
|
|
1273
1312
|
coinbase = await async_w3.eth.coinbase
|
|
@@ -1280,7 +1319,7 @@ class AsyncEthModuleTest:
|
|
|
1280
1319
|
|
|
1281
1320
|
@pytest.mark.asyncio
|
|
1282
1321
|
async def test_eth_call_with_0_result(
|
|
1283
|
-
self, async_w3: "AsyncWeb3", async_math_contract: "
|
|
1322
|
+
self, async_w3: "AsyncWeb3", async_math_contract: "AsyncContract"
|
|
1284
1323
|
) -> None:
|
|
1285
1324
|
coinbase = await async_w3.eth.coinbase
|
|
1286
1325
|
txn_params = async_math_contract._prepare_transaction(
|
|
@@ -1297,13 +1336,13 @@ class AsyncEthModuleTest:
|
|
|
1297
1336
|
async def test_eth_call_revert_with_msg(
|
|
1298
1337
|
self,
|
|
1299
1338
|
async_w3: "AsyncWeb3",
|
|
1300
|
-
async_revert_contract: "
|
|
1301
|
-
|
|
1339
|
+
async_revert_contract: "AsyncContract",
|
|
1340
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1302
1341
|
) -> None:
|
|
1303
1342
|
txn_params = async_revert_contract._prepare_transaction(
|
|
1304
1343
|
fn_name="revertWithMessage",
|
|
1305
1344
|
transaction={
|
|
1306
|
-
"from":
|
|
1345
|
+
"from": async_keyfile_account_address,
|
|
1307
1346
|
"to": async_revert_contract.address,
|
|
1308
1347
|
},
|
|
1309
1348
|
)
|
|
@@ -1316,14 +1355,14 @@ class AsyncEthModuleTest:
|
|
|
1316
1355
|
async def test_eth_call_revert_without_msg(
|
|
1317
1356
|
self,
|
|
1318
1357
|
async_w3: "AsyncWeb3",
|
|
1319
|
-
async_revert_contract: "
|
|
1320
|
-
|
|
1358
|
+
async_revert_contract: "AsyncContract",
|
|
1359
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1321
1360
|
) -> None:
|
|
1322
1361
|
with pytest.raises(ContractLogicError, match="execution reverted"):
|
|
1323
1362
|
txn_params = async_revert_contract._prepare_transaction(
|
|
1324
1363
|
fn_name="revertWithoutMessage",
|
|
1325
1364
|
transaction={
|
|
1326
|
-
"from":
|
|
1365
|
+
"from": async_keyfile_account_address,
|
|
1327
1366
|
"to": async_revert_contract.address,
|
|
1328
1367
|
},
|
|
1329
1368
|
)
|
|
@@ -1333,8 +1372,8 @@ class AsyncEthModuleTest:
|
|
|
1333
1372
|
async def test_eth_call_revert_custom_error_with_msg(
|
|
1334
1373
|
self,
|
|
1335
1374
|
async_w3: "AsyncWeb3",
|
|
1336
|
-
async_revert_contract: "
|
|
1337
|
-
|
|
1375
|
+
async_revert_contract: "AsyncContract",
|
|
1376
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1338
1377
|
) -> None:
|
|
1339
1378
|
data = async_revert_contract.encode_abi(
|
|
1340
1379
|
fn_name="UnauthorizedWithMessage", args=["You are not authorized"]
|
|
@@ -1342,7 +1381,7 @@ class AsyncEthModuleTest:
|
|
|
1342
1381
|
txn_params = async_revert_contract._prepare_transaction(
|
|
1343
1382
|
fn_name="customErrorWithMessage",
|
|
1344
1383
|
transaction={
|
|
1345
|
-
"from":
|
|
1384
|
+
"from": async_keyfile_account_address,
|
|
1346
1385
|
"to": async_revert_contract.address,
|
|
1347
1386
|
},
|
|
1348
1387
|
)
|
|
@@ -1353,14 +1392,14 @@ class AsyncEthModuleTest:
|
|
|
1353
1392
|
async def test_eth_call_revert_custom_error_without_msg(
|
|
1354
1393
|
self,
|
|
1355
1394
|
async_w3: "AsyncWeb3",
|
|
1356
|
-
async_revert_contract: "
|
|
1357
|
-
|
|
1395
|
+
async_revert_contract: "AsyncContract",
|
|
1396
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1358
1397
|
) -> None:
|
|
1359
1398
|
data = async_revert_contract.encode_abi(fn_name="Unauthorized")
|
|
1360
1399
|
txn_params = async_revert_contract._prepare_transaction(
|
|
1361
1400
|
fn_name="customErrorWithoutMessage",
|
|
1362
1401
|
transaction={
|
|
1363
|
-
"from":
|
|
1402
|
+
"from": async_keyfile_account_address,
|
|
1364
1403
|
"to": async_revert_contract.address,
|
|
1365
1404
|
},
|
|
1366
1405
|
)
|
|
@@ -1385,7 +1424,7 @@ class AsyncEthModuleTest:
|
|
|
1385
1424
|
async def test_contract_panic_errors(
|
|
1386
1425
|
self,
|
|
1387
1426
|
async_w3: "AsyncWeb3",
|
|
1388
|
-
async_panic_errors_contract: "
|
|
1427
|
+
async_panic_errors_contract: "AsyncContract",
|
|
1389
1428
|
panic_error: str,
|
|
1390
1429
|
params: List[Any],
|
|
1391
1430
|
) -> None:
|
|
@@ -1402,8 +1441,8 @@ class AsyncEthModuleTest:
|
|
|
1402
1441
|
async def test_eth_call_offchain_lookup(
|
|
1403
1442
|
self,
|
|
1404
1443
|
async_w3: "AsyncWeb3",
|
|
1405
|
-
async_offchain_lookup_contract: "
|
|
1406
|
-
|
|
1444
|
+
async_offchain_lookup_contract: "AsyncContract",
|
|
1445
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1407
1446
|
monkeypatch: "MonkeyPatch",
|
|
1408
1447
|
) -> None:
|
|
1409
1448
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -1428,7 +1467,7 @@ class AsyncEthModuleTest:
|
|
|
1428
1467
|
async def test_eth_call_offchain_lookup_raises_when_ccip_read_is_disabled(
|
|
1429
1468
|
self,
|
|
1430
1469
|
async_w3: "AsyncWeb3",
|
|
1431
|
-
async_offchain_lookup_contract: "
|
|
1470
|
+
async_offchain_lookup_contract: "AsyncContract",
|
|
1432
1471
|
) -> None:
|
|
1433
1472
|
return_data = (
|
|
1434
1473
|
OFFCHAIN_LOOKUP_4BYTE_DATA
|
|
@@ -1466,8 +1505,8 @@ class AsyncEthModuleTest:
|
|
|
1466
1505
|
async def test_eth_call_offchain_lookup_call_flag_overrides_provider_flag(
|
|
1467
1506
|
self,
|
|
1468
1507
|
async_w3: "AsyncWeb3",
|
|
1469
|
-
async_offchain_lookup_contract: "
|
|
1470
|
-
|
|
1508
|
+
async_offchain_lookup_contract: "AsyncContract",
|
|
1509
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1471
1510
|
monkeypatch: "MonkeyPatch",
|
|
1472
1511
|
) -> None:
|
|
1473
1512
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -1494,13 +1533,13 @@ class AsyncEthModuleTest:
|
|
|
1494
1533
|
async def test_eth_call_offchain_lookup_raises_if_max_redirects_is_less_than_4(
|
|
1495
1534
|
self,
|
|
1496
1535
|
async_w3: "AsyncWeb3",
|
|
1497
|
-
async_offchain_lookup_contract: "
|
|
1536
|
+
async_offchain_lookup_contract: "AsyncContract",
|
|
1498
1537
|
max_redirects: int,
|
|
1499
1538
|
) -> None:
|
|
1500
1539
|
default_max_redirects = async_w3.provider.ccip_read_max_redirects
|
|
1501
1540
|
|
|
1502
1541
|
async_w3.provider.ccip_read_max_redirects = max_redirects
|
|
1503
|
-
with pytest.raises(
|
|
1542
|
+
with pytest.raises(Web3ValueError, match="at least 4"):
|
|
1504
1543
|
await async_offchain_lookup_contract.caller().testOffchainLookup(
|
|
1505
1544
|
OFFCHAIN_LOOKUP_TEST_DATA
|
|
1506
1545
|
)
|
|
@@ -1511,8 +1550,8 @@ class AsyncEthModuleTest:
|
|
|
1511
1550
|
async def test_eth_call_offchain_lookup_raises_for_improperly_formatted_rest_request_response( # noqa: E501
|
|
1512
1551
|
self,
|
|
1513
1552
|
async_w3: "AsyncWeb3",
|
|
1514
|
-
async_offchain_lookup_contract: "
|
|
1515
|
-
|
|
1553
|
+
async_offchain_lookup_contract: "AsyncContract",
|
|
1554
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1516
1555
|
monkeypatch: "MonkeyPatch",
|
|
1517
1556
|
) -> None:
|
|
1518
1557
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -1535,8 +1574,8 @@ class AsyncEthModuleTest:
|
|
|
1535
1574
|
async def test_eth_call_offchain_lookup_tries_next_url_for_non_4xx_error_status_and_tests_POST( # noqa: E501
|
|
1536
1575
|
self,
|
|
1537
1576
|
async_w3: "AsyncWeb3",
|
|
1538
|
-
async_offchain_lookup_contract: "
|
|
1539
|
-
|
|
1577
|
+
async_offchain_lookup_contract: "AsyncContract",
|
|
1578
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1540
1579
|
monkeypatch: "MonkeyPatch",
|
|
1541
1580
|
status_code_non_4xx_error: int,
|
|
1542
1581
|
) -> None:
|
|
@@ -1573,8 +1612,8 @@ class AsyncEthModuleTest:
|
|
|
1573
1612
|
async def test_eth_call_offchain_lookup_calls_raise_for_status_for_4xx_status_code(
|
|
1574
1613
|
self,
|
|
1575
1614
|
async_w3: "AsyncWeb3",
|
|
1576
|
-
async_offchain_lookup_contract: "
|
|
1577
|
-
|
|
1615
|
+
async_offchain_lookup_contract: "AsyncContract",
|
|
1616
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1578
1617
|
monkeypatch: "MonkeyPatch",
|
|
1579
1618
|
) -> None:
|
|
1580
1619
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -1595,8 +1634,7 @@ class AsyncEthModuleTest:
|
|
|
1595
1634
|
@pytest.mark.asyncio
|
|
1596
1635
|
async def test_eth_call_offchain_lookup_raises_when_all_supplied_urls_fail(
|
|
1597
1636
|
self,
|
|
1598
|
-
|
|
1599
|
-
async_offchain_lookup_contract: "Contract",
|
|
1637
|
+
async_offchain_lookup_contract: "AsyncContract",
|
|
1600
1638
|
) -> None:
|
|
1601
1639
|
# GET and POST requests should fail since responses are not mocked
|
|
1602
1640
|
with pytest.raises(
|
|
@@ -1609,9 +1647,7 @@ class AsyncEthModuleTest:
|
|
|
1609
1647
|
@pytest.mark.asyncio
|
|
1610
1648
|
async def test_eth_call_continuous_offchain_lookup_raises_with_too_many_requests(
|
|
1611
1649
|
self,
|
|
1612
|
-
|
|
1613
|
-
async_offchain_lookup_contract: "Contract",
|
|
1614
|
-
async_unlocked_account: ChecksumAddress,
|
|
1650
|
+
async_offchain_lookup_contract: "AsyncContract",
|
|
1615
1651
|
monkeypatch: "MonkeyPatch",
|
|
1616
1652
|
) -> None:
|
|
1617
1653
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -1665,12 +1701,14 @@ class AsyncEthModuleTest:
|
|
|
1665
1701
|
|
|
1666
1702
|
@pytest.mark.asyncio
|
|
1667
1703
|
async def test_async_eth_get_transaction_receipt_unmined(
|
|
1668
|
-
self,
|
|
1704
|
+
self,
|
|
1705
|
+
async_w3: "AsyncWeb3",
|
|
1706
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1669
1707
|
) -> None:
|
|
1670
1708
|
txn_hash = await async_w3.eth.send_transaction(
|
|
1671
1709
|
{
|
|
1672
|
-
"from":
|
|
1673
|
-
"to":
|
|
1710
|
+
"from": async_keyfile_account_address_dual_type,
|
|
1711
|
+
"to": async_keyfile_account_address_dual_type,
|
|
1674
1712
|
"value": Wei(1),
|
|
1675
1713
|
"gas": 21000,
|
|
1676
1714
|
"maxFeePerGas": async_w3.to_wei(3, "gwei"),
|
|
@@ -1685,7 +1723,7 @@ class AsyncEthModuleTest:
|
|
|
1685
1723
|
self,
|
|
1686
1724
|
async_w3: "AsyncWeb3",
|
|
1687
1725
|
async_block_with_txn_with_log: BlockData,
|
|
1688
|
-
async_emitter_contract: "
|
|
1726
|
+
async_emitter_contract: "AsyncContract",
|
|
1689
1727
|
txn_hash_with_log: HexStr,
|
|
1690
1728
|
) -> None:
|
|
1691
1729
|
receipt = await async_w3.eth.wait_for_transaction_receipt(txn_hash_with_log)
|
|
@@ -1728,12 +1766,14 @@ class AsyncEthModuleTest:
|
|
|
1728
1766
|
|
|
1729
1767
|
@pytest.mark.asyncio
|
|
1730
1768
|
async def test_async_eth_wait_for_transaction_receipt_unmined(
|
|
1731
|
-
self,
|
|
1769
|
+
self,
|
|
1770
|
+
async_w3: "AsyncWeb3",
|
|
1771
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1732
1772
|
) -> None:
|
|
1733
1773
|
txn_hash = await async_w3.eth.send_transaction(
|
|
1734
1774
|
{
|
|
1735
|
-
"from":
|
|
1736
|
-
"to":
|
|
1775
|
+
"from": async_keyfile_account_address_dual_type,
|
|
1776
|
+
"to": async_keyfile_account_address_dual_type,
|
|
1737
1777
|
"value": Wei(1),
|
|
1738
1778
|
"gas": 21000,
|
|
1739
1779
|
"maxFeePerGas": async_w3.to_wei(3, "gwei"),
|
|
@@ -1752,7 +1792,7 @@ class AsyncEthModuleTest:
|
|
|
1752
1792
|
self,
|
|
1753
1793
|
async_w3: "AsyncWeb3",
|
|
1754
1794
|
async_block_with_txn_with_log: BlockData,
|
|
1755
|
-
async_emitter_contract: "
|
|
1795
|
+
async_emitter_contract: "AsyncContract",
|
|
1756
1796
|
txn_hash_with_log: HexStr,
|
|
1757
1797
|
) -> None:
|
|
1758
1798
|
receipt = await async_w3.eth.wait_for_transaction_receipt(txn_hash_with_log)
|
|
@@ -1777,7 +1817,7 @@ class AsyncEthModuleTest:
|
|
|
1777
1817
|
accounts = await async_w3.eth.accounts
|
|
1778
1818
|
assert is_list_like(accounts)
|
|
1779
1819
|
assert len(accounts) != 0
|
|
1780
|
-
assert all(
|
|
1820
|
+
assert all(is_checksum_address(account) for account in accounts)
|
|
1781
1821
|
assert await async_w3.eth.coinbase in accounts
|
|
1782
1822
|
|
|
1783
1823
|
@pytest.mark.asyncio
|
|
@@ -1798,7 +1838,7 @@ class AsyncEthModuleTest:
|
|
|
1798
1838
|
"fromBlock": async_block_with_txn_with_log["number"],
|
|
1799
1839
|
"toBlock": BlockNumber(async_block_with_txn_with_log["number"] - 1),
|
|
1800
1840
|
}
|
|
1801
|
-
with pytest.raises(
|
|
1841
|
+
with pytest.raises(Web3RPCError):
|
|
1802
1842
|
result = await async_w3.eth.get_logs(filter_params)
|
|
1803
1843
|
|
|
1804
1844
|
# Test with `address`
|
|
@@ -1950,7 +1990,7 @@ class AsyncEthModuleTest:
|
|
|
1950
1990
|
|
|
1951
1991
|
@pytest.mark.asyncio
|
|
1952
1992
|
async def test_async_eth_get_storage_at(
|
|
1953
|
-
self, async_w3: "AsyncWeb3", async_storage_contract: "
|
|
1993
|
+
self, async_w3: "AsyncWeb3", async_storage_contract: "AsyncContract"
|
|
1954
1994
|
) -> None:
|
|
1955
1995
|
async_storage_contract_address = async_storage_contract.address
|
|
1956
1996
|
|
|
@@ -1978,7 +2018,7 @@ class AsyncEthModuleTest:
|
|
|
1978
2018
|
@pytest.mark.asyncio
|
|
1979
2019
|
@pytest.mark.xfail
|
|
1980
2020
|
async def test_async_eth_get_storage_at_ens_name(
|
|
1981
|
-
self, async_w3: "AsyncWeb3", async_storage_contract: "
|
|
2021
|
+
self, async_w3: "AsyncWeb3", async_storage_contract: "AsyncContract"
|
|
1982
2022
|
) -> None:
|
|
1983
2023
|
with ens_addresses(async_w3, {"storage.eth": async_storage_contract.address}):
|
|
1984
2024
|
storage = await async_w3.eth.get_storage_at(ENS("storage.eth"), 1)
|
|
@@ -1995,16 +2035,18 @@ class AsyncEthModuleTest:
|
|
|
1995
2035
|
)
|
|
1996
2036
|
|
|
1997
2037
|
def test_async_provider_default_account(
|
|
1998
|
-
self,
|
|
2038
|
+
self,
|
|
2039
|
+
async_w3: "AsyncWeb3",
|
|
2040
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1999
2041
|
) -> None:
|
|
2000
2042
|
# check defaults to empty
|
|
2001
2043
|
default_account = async_w3.eth.default_account
|
|
2002
2044
|
assert default_account is empty
|
|
2003
2045
|
|
|
2004
2046
|
# check setter
|
|
2005
|
-
async_w3.eth.default_account =
|
|
2047
|
+
async_w3.eth.default_account = async_keyfile_account_address_dual_type
|
|
2006
2048
|
default_account = async_w3.eth.default_account
|
|
2007
|
-
assert default_account ==
|
|
2049
|
+
assert default_account == async_keyfile_account_address_dual_type
|
|
2008
2050
|
|
|
2009
2051
|
# reset to default
|
|
2010
2052
|
async_w3.eth.default_account = empty
|
|
@@ -2089,17 +2131,20 @@ class AsyncEthModuleTest:
|
|
|
2089
2131
|
|
|
2090
2132
|
@pytest.mark.asyncio
|
|
2091
2133
|
async def test_async_eth_sign(
|
|
2092
|
-
self,
|
|
2134
|
+
self,
|
|
2135
|
+
async_w3: "AsyncWeb3",
|
|
2136
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2093
2137
|
) -> None:
|
|
2094
2138
|
signature = await async_w3.eth.sign(
|
|
2095
|
-
|
|
2139
|
+
async_keyfile_account_address_dual_type,
|
|
2140
|
+
text="Message tö sign. Longer than hash!",
|
|
2096
2141
|
)
|
|
2097
2142
|
assert is_bytes(signature)
|
|
2098
2143
|
assert len(signature) == 32 + 32 + 1
|
|
2099
2144
|
|
|
2100
2145
|
# test other formats
|
|
2101
2146
|
hexsign = await async_w3.eth.sign(
|
|
2102
|
-
|
|
2147
|
+
async_keyfile_account_address_dual_type,
|
|
2103
2148
|
hexstr=HexStr(
|
|
2104
2149
|
"0x4d6573736167652074c3b6207369676e2e204c6f6e676572207468616e206861736821" # noqa: E501
|
|
2105
2150
|
),
|
|
@@ -2107,19 +2152,20 @@ class AsyncEthModuleTest:
|
|
|
2107
2152
|
assert hexsign == signature
|
|
2108
2153
|
|
|
2109
2154
|
intsign = await async_w3.eth.sign(
|
|
2110
|
-
|
|
2155
|
+
async_keyfile_account_address_dual_type,
|
|
2111
2156
|
0x4D6573736167652074C3B6207369676E2E204C6F6E676572207468616E206861736821,
|
|
2112
2157
|
)
|
|
2113
2158
|
assert intsign == signature
|
|
2114
2159
|
|
|
2115
2160
|
bytessign = await async_w3.eth.sign(
|
|
2116
|
-
|
|
2161
|
+
async_keyfile_account_address_dual_type,
|
|
2117
2162
|
b"Message t\xc3\xb6 sign. Longer than hash!",
|
|
2118
2163
|
)
|
|
2119
2164
|
assert bytessign == signature
|
|
2120
2165
|
|
|
2121
2166
|
new_signature = await async_w3.eth.sign(
|
|
2122
|
-
|
|
2167
|
+
async_keyfile_account_address_dual_type,
|
|
2168
|
+
text="different message is different",
|
|
2123
2169
|
)
|
|
2124
2170
|
assert new_signature != signature
|
|
2125
2171
|
|
|
@@ -2128,10 +2174,12 @@ class AsyncEthModuleTest:
|
|
|
2128
2174
|
reason="Async middleware to convert ENS names to addresses is missing"
|
|
2129
2175
|
)
|
|
2130
2176
|
async def test_async_eth_sign_ens_names(
|
|
2131
|
-
self,
|
|
2177
|
+
self,
|
|
2178
|
+
async_w3: "AsyncWeb3",
|
|
2179
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2132
2180
|
) -> None:
|
|
2133
2181
|
with ens_addresses(
|
|
2134
|
-
async_w3, {"unlocked-acct.eth":
|
|
2182
|
+
async_w3, {"unlocked-acct.eth": async_keyfile_account_address_dual_type}
|
|
2135
2183
|
):
|
|
2136
2184
|
signature = await async_w3.eth.sign(
|
|
2137
2185
|
ENS("unlocked-acct.eth"), text="Message tö sign. Longer than hash!"
|
|
@@ -2142,11 +2190,13 @@ class AsyncEthModuleTest:
|
|
|
2142
2190
|
@flaky_geth_dev_mining
|
|
2143
2191
|
@pytest.mark.asyncio
|
|
2144
2192
|
async def test_async_eth_replace_transaction_legacy(
|
|
2145
|
-
self,
|
|
2193
|
+
self,
|
|
2194
|
+
async_w3: "AsyncWeb3",
|
|
2195
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2146
2196
|
) -> None:
|
|
2147
2197
|
txn_params: TxParams = {
|
|
2148
|
-
"from":
|
|
2149
|
-
"to":
|
|
2198
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2199
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2150
2200
|
"value": Wei(1),
|
|
2151
2201
|
"gas": 21000,
|
|
2152
2202
|
"gasPrice": async_w3.to_wei(1, "gwei"),
|
|
@@ -2170,14 +2220,16 @@ class AsyncEthModuleTest:
|
|
|
2170
2220
|
@flaky_geth_dev_mining
|
|
2171
2221
|
@pytest.mark.asyncio
|
|
2172
2222
|
async def test_async_eth_replace_transaction(
|
|
2173
|
-
self,
|
|
2223
|
+
self,
|
|
2224
|
+
async_w3: "AsyncWeb3",
|
|
2225
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2174
2226
|
) -> None:
|
|
2175
2227
|
two_gwei_in_wei = async_w3.to_wei(2, "gwei")
|
|
2176
2228
|
three_gwei_in_wei = async_w3.to_wei(3, "gwei")
|
|
2177
2229
|
|
|
2178
2230
|
txn_params: TxParams = {
|
|
2179
|
-
"from":
|
|
2180
|
-
"to":
|
|
2231
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2232
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2181
2233
|
"value": Wei(1),
|
|
2182
2234
|
"gas": 21000,
|
|
2183
2235
|
"maxFeePerGas": two_gwei_in_wei,
|
|
@@ -2205,11 +2257,13 @@ class AsyncEthModuleTest:
|
|
|
2205
2257
|
@flaky_geth_dev_mining
|
|
2206
2258
|
@pytest.mark.asyncio
|
|
2207
2259
|
async def test_async_eth_replace_transaction_underpriced(
|
|
2208
|
-
self,
|
|
2260
|
+
self,
|
|
2261
|
+
async_w3: "AsyncWeb3",
|
|
2262
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2209
2263
|
) -> None:
|
|
2210
2264
|
txn_params: TxParams = {
|
|
2211
|
-
"from":
|
|
2212
|
-
"to":
|
|
2265
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2266
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2213
2267
|
"value": Wei(1),
|
|
2214
2268
|
"gas": 21000,
|
|
2215
2269
|
"maxFeePerGas": async_w3.to_wei(3, "gwei"),
|
|
@@ -2221,17 +2275,19 @@ class AsyncEthModuleTest:
|
|
|
2221
2275
|
txn_params["maxFeePerGas"] = one_gwei_in_wei
|
|
2222
2276
|
txn_params["maxPriorityFeePerGas"] = one_gwei_in_wei
|
|
2223
2277
|
|
|
2224
|
-
with pytest.raises(
|
|
2278
|
+
with pytest.raises(Web3RPCError, match="replacement transaction underpriced"):
|
|
2225
2279
|
await async_w3.eth.replace_transaction(txn_hash, txn_params)
|
|
2226
2280
|
|
|
2227
2281
|
@flaky_geth_dev_mining
|
|
2228
2282
|
@pytest.mark.asyncio
|
|
2229
2283
|
async def test_async_eth_replace_transaction_non_existing_transaction(
|
|
2230
|
-
self,
|
|
2284
|
+
self,
|
|
2285
|
+
async_w3: "AsyncWeb3",
|
|
2286
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2231
2287
|
) -> None:
|
|
2232
2288
|
txn_params: TxParams = {
|
|
2233
|
-
"from":
|
|
2234
|
-
"to":
|
|
2289
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2290
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2235
2291
|
"value": Wei(1),
|
|
2236
2292
|
"gas": 21000,
|
|
2237
2293
|
"maxFeePerGas": async_w3.to_wei(3, "gwei"),
|
|
@@ -2248,11 +2304,13 @@ class AsyncEthModuleTest:
|
|
|
2248
2304
|
@flaky_geth_dev_mining
|
|
2249
2305
|
@pytest.mark.asyncio
|
|
2250
2306
|
async def test_async_eth_replace_transaction_already_mined(
|
|
2251
|
-
self,
|
|
2307
|
+
self,
|
|
2308
|
+
async_w3: "AsyncWeb3",
|
|
2309
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2252
2310
|
) -> None:
|
|
2253
2311
|
txn_params: TxParams = {
|
|
2254
|
-
"from":
|
|
2255
|
-
"to":
|
|
2312
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2313
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2256
2314
|
"value": Wei(1),
|
|
2257
2315
|
"gas": 21000,
|
|
2258
2316
|
"maxFeePerGas": async_w3.to_wei(2, "gwei"),
|
|
@@ -2263,17 +2321,17 @@ class AsyncEthModuleTest:
|
|
|
2263
2321
|
|
|
2264
2322
|
txn_params["maxFeePerGas"] = async_w3.to_wei(3, "gwei")
|
|
2265
2323
|
txn_params["maxPriorityFeePerGas"] = async_w3.to_wei(2, "gwei")
|
|
2266
|
-
with pytest.raises(
|
|
2324
|
+
with pytest.raises(Web3ValueError, match="Supplied transaction with hash"):
|
|
2267
2325
|
await async_w3.eth.replace_transaction(txn_hash, txn_params)
|
|
2268
2326
|
|
|
2269
2327
|
@flaky_geth_dev_mining
|
|
2270
2328
|
@pytest.mark.asyncio
|
|
2271
2329
|
async def test_async_eth_replace_transaction_incorrect_nonce(
|
|
2272
|
-
self, async_w3: "AsyncWeb3",
|
|
2330
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
2273
2331
|
) -> None:
|
|
2274
2332
|
txn_params: TxParams = {
|
|
2275
|
-
"from":
|
|
2276
|
-
"to":
|
|
2333
|
+
"from": async_keyfile_account_address,
|
|
2334
|
+
"to": async_keyfile_account_address,
|
|
2277
2335
|
"value": Wei(1),
|
|
2278
2336
|
"gas": 21000,
|
|
2279
2337
|
"maxFeePerGas": async_w3.to_wei(2, "gwei"),
|
|
@@ -2285,17 +2343,19 @@ class AsyncEthModuleTest:
|
|
|
2285
2343
|
txn_params["maxFeePerGas"] = async_w3.to_wei(3, "gwei")
|
|
2286
2344
|
txn_params["maxPriorityFeePerGas"] = async_w3.to_wei(2, "gwei")
|
|
2287
2345
|
txn_params["nonce"] = Nonce(txn["nonce"] + 1)
|
|
2288
|
-
with pytest.raises(
|
|
2346
|
+
with pytest.raises(Web3ValueError):
|
|
2289
2347
|
await async_w3.eth.replace_transaction(txn_hash, txn_params)
|
|
2290
2348
|
|
|
2291
2349
|
@flaky_geth_dev_mining
|
|
2292
2350
|
@pytest.mark.asyncio
|
|
2293
2351
|
async def test_async_eth_replace_transaction_gas_price_too_low(
|
|
2294
|
-
self,
|
|
2352
|
+
self,
|
|
2353
|
+
async_w3: "AsyncWeb3",
|
|
2354
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2295
2355
|
) -> None:
|
|
2296
2356
|
txn_params: TxParams = {
|
|
2297
|
-
"from":
|
|
2298
|
-
"to":
|
|
2357
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2358
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2299
2359
|
"value": Wei(1),
|
|
2300
2360
|
"gas": 21000,
|
|
2301
2361
|
"gasPrice": async_w3.to_wei(2, "gwei"),
|
|
@@ -2303,19 +2363,19 @@ class AsyncEthModuleTest:
|
|
|
2303
2363
|
txn_hash = await async_w3.eth.send_transaction(txn_params)
|
|
2304
2364
|
|
|
2305
2365
|
txn_params["gasPrice"] = async_w3.to_wei(1, "gwei")
|
|
2306
|
-
with pytest.raises(
|
|
2366
|
+
with pytest.raises(Web3ValueError):
|
|
2307
2367
|
await async_w3.eth.replace_transaction(txn_hash, txn_params)
|
|
2308
2368
|
|
|
2309
2369
|
@flaky_geth_dev_mining
|
|
2310
2370
|
@pytest.mark.asyncio
|
|
2311
2371
|
async def test_async_eth_replace_transaction_gas_price_defaulting_minimum(
|
|
2312
|
-
self, async_w3: "AsyncWeb3",
|
|
2372
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
2313
2373
|
) -> None:
|
|
2314
2374
|
gas_price = async_w3.to_wei(1, "gwei")
|
|
2315
2375
|
|
|
2316
2376
|
txn_params: TxParams = {
|
|
2317
|
-
"from":
|
|
2318
|
-
"to":
|
|
2377
|
+
"from": async_keyfile_account_address,
|
|
2378
|
+
"to": async_keyfile_account_address,
|
|
2319
2379
|
"value": Wei(1),
|
|
2320
2380
|
"gas": 21000,
|
|
2321
2381
|
"gasPrice": gas_price,
|
|
@@ -2333,11 +2393,11 @@ class AsyncEthModuleTest:
|
|
|
2333
2393
|
@flaky_geth_dev_mining
|
|
2334
2394
|
@pytest.mark.asyncio
|
|
2335
2395
|
async def test_async_eth_replace_transaction_gas_price_defaulting_strategy_higher(
|
|
2336
|
-
self, async_w3: "AsyncWeb3",
|
|
2396
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
2337
2397
|
) -> None:
|
|
2338
2398
|
txn_params: TxParams = {
|
|
2339
|
-
"from":
|
|
2340
|
-
"to":
|
|
2399
|
+
"from": async_keyfile_account_address,
|
|
2400
|
+
"to": async_keyfile_account_address,
|
|
2341
2401
|
"value": Wei(1),
|
|
2342
2402
|
"gas": 21000,
|
|
2343
2403
|
"gasPrice": async_w3.to_wei(1, "gwei"),
|
|
@@ -2362,13 +2422,13 @@ class AsyncEthModuleTest:
|
|
|
2362
2422
|
@flaky_geth_dev_mining
|
|
2363
2423
|
@pytest.mark.asyncio
|
|
2364
2424
|
async def test_async_eth_replace_transaction_gas_price_defaulting_strategy_lower(
|
|
2365
|
-
self, async_w3: "AsyncWeb3",
|
|
2425
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
2366
2426
|
) -> None:
|
|
2367
2427
|
gas_price = async_w3.to_wei(2, "gwei")
|
|
2368
2428
|
|
|
2369
2429
|
txn_params: TxParams = {
|
|
2370
|
-
"from":
|
|
2371
|
-
"to":
|
|
2430
|
+
"from": async_keyfile_account_address,
|
|
2431
|
+
"to": async_keyfile_account_address,
|
|
2372
2432
|
"value": Wei(1),
|
|
2373
2433
|
"gas": 21000,
|
|
2374
2434
|
"gasPrice": gas_price,
|
|
@@ -2536,7 +2596,7 @@ class EthModuleTest:
|
|
|
2536
2596
|
accounts = w3.eth.accounts
|
|
2537
2597
|
assert is_list_like(accounts)
|
|
2538
2598
|
assert len(accounts) != 0
|
|
2539
|
-
assert all(
|
|
2599
|
+
assert all(is_checksum_address(account) for account in accounts)
|
|
2540
2600
|
assert w3.eth.coinbase in accounts
|
|
2541
2601
|
|
|
2542
2602
|
def test_eth_block_number(self, w3: "Web3") -> None:
|
|
@@ -2624,17 +2684,19 @@ class EthModuleTest:
|
|
|
2624
2684
|
)
|
|
2625
2685
|
|
|
2626
2686
|
def test_eth_get_transaction_count(
|
|
2627
|
-
self, w3: "Web3",
|
|
2687
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
2628
2688
|
) -> None:
|
|
2629
|
-
transaction_count = w3.eth.get_transaction_count(
|
|
2689
|
+
transaction_count = w3.eth.get_transaction_count(
|
|
2690
|
+
keyfile_account_address_dual_type
|
|
2691
|
+
)
|
|
2630
2692
|
assert is_integer(transaction_count)
|
|
2631
2693
|
assert transaction_count >= 0
|
|
2632
2694
|
|
|
2633
2695
|
def test_eth_get_transaction_count_ens_name(
|
|
2634
|
-
self, w3: "Web3",
|
|
2696
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
2635
2697
|
) -> None:
|
|
2636
2698
|
with ens_addresses(
|
|
2637
|
-
w3, {"unlocked-acct-dual-type.eth":
|
|
2699
|
+
w3, {"unlocked-acct-dual-type.eth": keyfile_account_address_dual_type}
|
|
2638
2700
|
):
|
|
2639
2701
|
transaction_count = w3.eth.get_transaction_count(
|
|
2640
2702
|
ENS("unlocked-acct-dual-type.eth")
|
|
@@ -2732,27 +2794,17 @@ class EthModuleTest:
|
|
|
2732
2794
|
def test_eth_create_access_list(
|
|
2733
2795
|
self,
|
|
2734
2796
|
w3: "Web3",
|
|
2735
|
-
|
|
2797
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
2736
2798
|
math_contract: "Contract",
|
|
2737
2799
|
) -> None:
|
|
2738
|
-
#
|
|
2739
|
-
|
|
2740
|
-
"from":
|
|
2741
|
-
"value": Wei(1),
|
|
2742
|
-
"gas": 21000,
|
|
2743
|
-
}
|
|
2744
|
-
|
|
2745
|
-
txn = math_contract.functions.incrementCounter(1).build_transaction(txn_params)
|
|
2746
|
-
|
|
2747
|
-
# create access list using data from transaction
|
|
2748
|
-
response = w3.eth.create_access_list(
|
|
2749
|
-
{
|
|
2750
|
-
"from": unlocked_account_dual_type,
|
|
2751
|
-
"to": math_contract.address,
|
|
2752
|
-
"data": txn["data"],
|
|
2753
|
-
}
|
|
2800
|
+
# build txn
|
|
2801
|
+
txn = math_contract.functions.incrementCounter(1).build_transaction(
|
|
2802
|
+
{"from": keyfile_account_address_dual_type}
|
|
2754
2803
|
)
|
|
2755
2804
|
|
|
2805
|
+
# create access list
|
|
2806
|
+
response = w3.eth.create_access_list(txn)
|
|
2807
|
+
|
|
2756
2808
|
assert is_dict(response)
|
|
2757
2809
|
access_list = response["accessList"]
|
|
2758
2810
|
assert len(access_list) > 0
|
|
@@ -2761,18 +2813,25 @@ class EthModuleTest:
|
|
|
2761
2813
|
assert len(access_list[0]["storageKeys"][0]) == 32
|
|
2762
2814
|
assert int(response["gasUsed"]) >= 0
|
|
2763
2815
|
|
|
2816
|
+
# assert the result can be used directly in a transaction dict
|
|
2817
|
+
txn["accessList"] = response["accessList"]
|
|
2818
|
+
txn["gas"] = response["gasUsed"]
|
|
2819
|
+
|
|
2820
|
+
# send txn with access list
|
|
2821
|
+
w3.eth.send_transaction(txn)
|
|
2822
|
+
|
|
2764
2823
|
def test_eth_sign(
|
|
2765
|
-
self, w3: "Web3",
|
|
2824
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
2766
2825
|
) -> None:
|
|
2767
2826
|
signature = w3.eth.sign(
|
|
2768
|
-
|
|
2827
|
+
keyfile_account_address_dual_type, text="Message tö sign. Longer than hash!"
|
|
2769
2828
|
)
|
|
2770
2829
|
assert is_bytes(signature)
|
|
2771
2830
|
assert len(signature) == 32 + 32 + 1
|
|
2772
2831
|
|
|
2773
2832
|
# test other formats
|
|
2774
2833
|
hexsign = w3.eth.sign(
|
|
2775
|
-
|
|
2834
|
+
keyfile_account_address_dual_type,
|
|
2776
2835
|
hexstr=HexStr(
|
|
2777
2836
|
"0x4d6573736167652074c3b6207369676e2e204c6f6e676572207468616e206861736821" # noqa: E501
|
|
2778
2837
|
),
|
|
@@ -2780,25 +2839,28 @@ class EthModuleTest:
|
|
|
2780
2839
|
assert hexsign == signature
|
|
2781
2840
|
|
|
2782
2841
|
intsign = w3.eth.sign(
|
|
2783
|
-
|
|
2842
|
+
keyfile_account_address_dual_type,
|
|
2784
2843
|
0x4D6573736167652074C3B6207369676E2E204C6F6E676572207468616E206861736821,
|
|
2785
2844
|
)
|
|
2786
2845
|
assert intsign == signature
|
|
2787
2846
|
|
|
2788
2847
|
bytessign = w3.eth.sign(
|
|
2789
|
-
|
|
2848
|
+
keyfile_account_address_dual_type,
|
|
2849
|
+
b"Message t\xc3\xb6 sign. Longer than hash!",
|
|
2790
2850
|
)
|
|
2791
2851
|
assert bytessign == signature
|
|
2792
2852
|
|
|
2793
2853
|
new_signature = w3.eth.sign(
|
|
2794
|
-
|
|
2854
|
+
keyfile_account_address_dual_type, text="different message is different"
|
|
2795
2855
|
)
|
|
2796
2856
|
assert new_signature != signature
|
|
2797
2857
|
|
|
2798
2858
|
def test_eth_sign_ens_names(
|
|
2799
|
-
self, w3: "Web3",
|
|
2859
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
2800
2860
|
) -> None:
|
|
2801
|
-
with ens_addresses(
|
|
2861
|
+
with ens_addresses(
|
|
2862
|
+
w3, {"unlocked-acct.eth": keyfile_account_address_dual_type}
|
|
2863
|
+
):
|
|
2802
2864
|
signature = w3.eth.sign(
|
|
2803
2865
|
"unlocked-acct.eth", text="Message tö sign. Longer than hash!"
|
|
2804
2866
|
)
|
|
@@ -2808,7 +2870,7 @@ class EthModuleTest:
|
|
|
2808
2870
|
def test_eth_sign_typed_data(
|
|
2809
2871
|
self,
|
|
2810
2872
|
w3: "Web3",
|
|
2811
|
-
|
|
2873
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
2812
2874
|
skip_if_testrpc: Callable[["Web3"], None],
|
|
2813
2875
|
) -> None:
|
|
2814
2876
|
validJSONMessage = """
|
|
@@ -2853,7 +2915,7 @@ class EthModuleTest:
|
|
|
2853
2915
|
skip_if_testrpc(w3)
|
|
2854
2916
|
signature = HexBytes(
|
|
2855
2917
|
w3.eth.sign_typed_data(
|
|
2856
|
-
|
|
2918
|
+
keyfile_account_address_dual_type, json.loads(validJSONMessage)
|
|
2857
2919
|
)
|
|
2858
2920
|
)
|
|
2859
2921
|
assert len(signature) == 32 + 32 + 1
|
|
@@ -2861,7 +2923,7 @@ class EthModuleTest:
|
|
|
2861
2923
|
def test_invalid_eth_sign_typed_data(
|
|
2862
2924
|
self,
|
|
2863
2925
|
w3: "Web3",
|
|
2864
|
-
|
|
2926
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
2865
2927
|
skip_if_testrpc: Callable[["Web3"], None],
|
|
2866
2928
|
) -> None:
|
|
2867
2929
|
skip_if_testrpc(w3)
|
|
@@ -2905,19 +2967,19 @@ class EthModuleTest:
|
|
|
2905
2967
|
}
|
|
2906
2968
|
"""
|
|
2907
2969
|
with pytest.raises(
|
|
2908
|
-
|
|
2970
|
+
Web3ValueError,
|
|
2909
2971
|
match=r".*Expected 2 items for array type Person\[2\], got 1 items.*",
|
|
2910
2972
|
):
|
|
2911
2973
|
w3.eth.sign_typed_data(
|
|
2912
|
-
|
|
2974
|
+
keyfile_account_address_dual_type, json.loads(invalid_typed_message)
|
|
2913
2975
|
)
|
|
2914
2976
|
|
|
2915
2977
|
def test_eth_sign_transaction_legacy(
|
|
2916
|
-
self, w3: "Web3",
|
|
2978
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
2917
2979
|
) -> None:
|
|
2918
2980
|
txn_params: TxParams = {
|
|
2919
|
-
"from":
|
|
2920
|
-
"to":
|
|
2981
|
+
"from": keyfile_account_address,
|
|
2982
|
+
"to": keyfile_account_address,
|
|
2921
2983
|
"value": Wei(1),
|
|
2922
2984
|
"gas": 21000,
|
|
2923
2985
|
"gasPrice": w3.eth.gas_price,
|
|
@@ -2925,7 +2987,7 @@ class EthModuleTest:
|
|
|
2925
2987
|
}
|
|
2926
2988
|
result = w3.eth.sign_transaction(txn_params)
|
|
2927
2989
|
signatory_account = w3.eth.account.recover_transaction(result["raw"])
|
|
2928
|
-
assert
|
|
2990
|
+
assert keyfile_account_address == signatory_account
|
|
2929
2991
|
assert result["tx"]["to"] == txn_params["to"]
|
|
2930
2992
|
assert result["tx"]["value"] == txn_params["value"]
|
|
2931
2993
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -2933,11 +2995,11 @@ class EthModuleTest:
|
|
|
2933
2995
|
assert result["tx"]["nonce"] == txn_params["nonce"]
|
|
2934
2996
|
|
|
2935
2997
|
def test_eth_sign_transaction(
|
|
2936
|
-
self, w3: "Web3",
|
|
2998
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
2937
2999
|
) -> None:
|
|
2938
3000
|
txn_params: TxParams = {
|
|
2939
|
-
"from":
|
|
2940
|
-
"to":
|
|
3001
|
+
"from": keyfile_account_address,
|
|
3002
|
+
"to": keyfile_account_address,
|
|
2941
3003
|
"value": Wei(1),
|
|
2942
3004
|
"gas": 21000,
|
|
2943
3005
|
"maxFeePerGas": w3.to_wei(2, "gwei"),
|
|
@@ -2946,7 +3008,7 @@ class EthModuleTest:
|
|
|
2946
3008
|
}
|
|
2947
3009
|
result = w3.eth.sign_transaction(txn_params)
|
|
2948
3010
|
signatory_account = w3.eth.account.recover_transaction(result["raw"])
|
|
2949
|
-
assert
|
|
3011
|
+
assert keyfile_account_address == signatory_account
|
|
2950
3012
|
assert result["tx"]["to"] == txn_params["to"]
|
|
2951
3013
|
assert result["tx"]["value"] == txn_params["value"]
|
|
2952
3014
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -2957,11 +3019,11 @@ class EthModuleTest:
|
|
|
2957
3019
|
assert result["tx"]["nonce"] == txn_params["nonce"]
|
|
2958
3020
|
|
|
2959
3021
|
def test_eth_sign_transaction_hex_fees(
|
|
2960
|
-
self, w3: "Web3",
|
|
3022
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
2961
3023
|
) -> None:
|
|
2962
3024
|
txn_params: TxParams = {
|
|
2963
|
-
"from":
|
|
2964
|
-
"to":
|
|
3025
|
+
"from": keyfile_account_address,
|
|
3026
|
+
"to": keyfile_account_address,
|
|
2965
3027
|
"value": Wei(1),
|
|
2966
3028
|
"gas": 21000,
|
|
2967
3029
|
"maxFeePerGas": hex(w3.to_wei(2, "gwei")),
|
|
@@ -2970,7 +3032,7 @@ class EthModuleTest:
|
|
|
2970
3032
|
}
|
|
2971
3033
|
result = w3.eth.sign_transaction(txn_params)
|
|
2972
3034
|
signatory_account = w3.eth.account.recover_transaction(result["raw"])
|
|
2973
|
-
assert
|
|
3035
|
+
assert keyfile_account_address == signatory_account
|
|
2974
3036
|
assert result["tx"]["to"] == txn_params["to"]
|
|
2975
3037
|
assert result["tx"]["value"] == txn_params["value"]
|
|
2976
3038
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -2981,9 +3043,9 @@ class EthModuleTest:
|
|
|
2981
3043
|
assert result["tx"]["nonce"] == txn_params["nonce"]
|
|
2982
3044
|
|
|
2983
3045
|
def test_eth_sign_transaction_ens_names(
|
|
2984
|
-
self, w3: "Web3",
|
|
3046
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
2985
3047
|
) -> None:
|
|
2986
|
-
with ens_addresses(w3, {"unlocked-account.eth":
|
|
3048
|
+
with ens_addresses(w3, {"unlocked-account.eth": keyfile_account_address}):
|
|
2987
3049
|
txn_params: TxParams = {
|
|
2988
3050
|
"from": "unlocked-account.eth",
|
|
2989
3051
|
"to": "unlocked-account.eth",
|
|
@@ -2995,8 +3057,8 @@ class EthModuleTest:
|
|
|
2995
3057
|
}
|
|
2996
3058
|
result = w3.eth.sign_transaction(txn_params)
|
|
2997
3059
|
signatory_account = w3.eth.account.recover_transaction(result["raw"])
|
|
2998
|
-
assert
|
|
2999
|
-
assert result["tx"]["to"] ==
|
|
3060
|
+
assert keyfile_account_address == signatory_account
|
|
3061
|
+
assert result["tx"]["to"] == keyfile_account_address
|
|
3000
3062
|
assert result["tx"]["value"] == txn_params["value"]
|
|
3001
3063
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
3002
3064
|
assert result["tx"]["maxFeePerGas"] == txn_params["maxFeePerGas"]
|
|
@@ -3007,12 +3069,12 @@ class EthModuleTest:
|
|
|
3007
3069
|
assert result["tx"]["nonce"] == txn_params["nonce"]
|
|
3008
3070
|
|
|
3009
3071
|
def test_eth_send_transaction_addr_checksum_required(
|
|
3010
|
-
self, w3: "Web3",
|
|
3072
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3011
3073
|
) -> None:
|
|
3012
|
-
non_checksum_addr =
|
|
3074
|
+
non_checksum_addr = keyfile_account_address.lower()
|
|
3013
3075
|
txn_params: TxParams = {
|
|
3014
|
-
"from":
|
|
3015
|
-
"to":
|
|
3076
|
+
"from": keyfile_account_address,
|
|
3077
|
+
"to": keyfile_account_address,
|
|
3016
3078
|
"value": Wei(1),
|
|
3017
3079
|
"gas": 21000,
|
|
3018
3080
|
"maxFeePerGas": w3.to_wei(2, "gwei"),
|
|
@@ -3032,11 +3094,11 @@ class EthModuleTest:
|
|
|
3032
3094
|
w3.eth.send_transaction(invalid_params)
|
|
3033
3095
|
|
|
3034
3096
|
def test_eth_send_transaction_legacy(
|
|
3035
|
-
self, w3: "Web3",
|
|
3097
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3036
3098
|
) -> None:
|
|
3037
3099
|
txn_params: TxParams = {
|
|
3038
|
-
"from":
|
|
3039
|
-
"to":
|
|
3100
|
+
"from": keyfile_account_address_dual_type,
|
|
3101
|
+
"to": keyfile_account_address_dual_type,
|
|
3040
3102
|
"value": Wei(1),
|
|
3041
3103
|
"gas": 21000,
|
|
3042
3104
|
"gasPrice": w3.to_wei(
|
|
@@ -3053,11 +3115,11 @@ class EthModuleTest:
|
|
|
3053
3115
|
assert txn["gasPrice"] == txn_params["gasPrice"]
|
|
3054
3116
|
|
|
3055
3117
|
def test_eth_send_transaction(
|
|
3056
|
-
self, w3: "Web3",
|
|
3118
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3057
3119
|
) -> None:
|
|
3058
3120
|
txn_params: TxParams = {
|
|
3059
|
-
"from":
|
|
3060
|
-
"to":
|
|
3121
|
+
"from": keyfile_account_address_dual_type,
|
|
3122
|
+
"to": keyfile_account_address_dual_type,
|
|
3061
3123
|
"value": Wei(1),
|
|
3062
3124
|
"gas": 21000,
|
|
3063
3125
|
"maxFeePerGas": w3.to_wei(3, "gwei"),
|
|
@@ -3075,20 +3137,22 @@ class EthModuleTest:
|
|
|
3075
3137
|
assert txn["gasPrice"] == txn_params["maxFeePerGas"]
|
|
3076
3138
|
|
|
3077
3139
|
def test_eth_send_transaction_with_nonce(
|
|
3078
|
-
self, w3: "Web3",
|
|
3140
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3079
3141
|
) -> None:
|
|
3080
3142
|
max_priority_fee_per_gas = w3.to_wei(1.234, "gwei")
|
|
3081
3143
|
max_fee_per_gas = Wei(
|
|
3082
3144
|
w3.eth.get_block("latest")["baseFeePerGas"] + max_priority_fee_per_gas
|
|
3083
3145
|
)
|
|
3084
3146
|
txn_params: TxParams = {
|
|
3085
|
-
"from":
|
|
3086
|
-
"to":
|
|
3147
|
+
"from": keyfile_account_address,
|
|
3148
|
+
"to": keyfile_account_address,
|
|
3087
3149
|
"value": Wei(1),
|
|
3088
3150
|
"gas": 21000,
|
|
3089
3151
|
"maxFeePerGas": max_fee_per_gas,
|
|
3090
3152
|
"maxPriorityFeePerGas": max_priority_fee_per_gas,
|
|
3091
|
-
"nonce": Nonce(
|
|
3153
|
+
"nonce": Nonce(
|
|
3154
|
+
w3.eth.get_transaction_count(keyfile_account_address, "pending")
|
|
3155
|
+
),
|
|
3092
3156
|
}
|
|
3093
3157
|
txn_hash = w3.eth.send_transaction(txn_params)
|
|
3094
3158
|
txn = w3.eth.get_transaction(txn_hash)
|
|
@@ -3104,11 +3168,11 @@ class EthModuleTest:
|
|
|
3104
3168
|
assert is_integer(txn_params["maxFeePerGas"])
|
|
3105
3169
|
|
|
3106
3170
|
def test_eth_send_transaction_default_fees(
|
|
3107
|
-
self, w3: "Web3",
|
|
3171
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3108
3172
|
) -> None:
|
|
3109
3173
|
txn_params: TxParams = {
|
|
3110
|
-
"from":
|
|
3111
|
-
"to":
|
|
3174
|
+
"from": keyfile_account_address_dual_type,
|
|
3175
|
+
"to": keyfile_account_address_dual_type,
|
|
3112
3176
|
"value": Wei(1),
|
|
3113
3177
|
"gas": 21000,
|
|
3114
3178
|
}
|
|
@@ -3124,11 +3188,11 @@ class EthModuleTest:
|
|
|
3124
3188
|
assert txn["gasPrice"] == txn["maxFeePerGas"]
|
|
3125
3189
|
|
|
3126
3190
|
def test_eth_send_transaction_hex_fees(
|
|
3127
|
-
self, w3: "Web3",
|
|
3191
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3128
3192
|
) -> None:
|
|
3129
3193
|
txn_params: TxParams = {
|
|
3130
|
-
"from":
|
|
3131
|
-
"to":
|
|
3194
|
+
"from": keyfile_account_address_dual_type,
|
|
3195
|
+
"to": keyfile_account_address_dual_type,
|
|
3132
3196
|
"value": Wei(1),
|
|
3133
3197
|
"gas": 21000,
|
|
3134
3198
|
"maxFeePerGas": hex(250 * 10**9),
|
|
@@ -3145,11 +3209,11 @@ class EthModuleTest:
|
|
|
3145
3209
|
assert txn["maxPriorityFeePerGas"] == 2 * 10**9
|
|
3146
3210
|
|
|
3147
3211
|
def test_eth_send_transaction_no_gas(
|
|
3148
|
-
self, w3: "Web3",
|
|
3212
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3149
3213
|
) -> None:
|
|
3150
3214
|
txn_params: TxParams = {
|
|
3151
|
-
"from":
|
|
3152
|
-
"to":
|
|
3215
|
+
"from": keyfile_account_address_dual_type,
|
|
3216
|
+
"to": keyfile_account_address_dual_type,
|
|
3153
3217
|
"value": Wei(1),
|
|
3154
3218
|
"maxFeePerGas": Wei(250 * 10**9),
|
|
3155
3219
|
"maxPriorityFeePerGas": Wei(2 * 10**9),
|
|
@@ -3163,11 +3227,11 @@ class EthModuleTest:
|
|
|
3163
3227
|
assert txn["gas"] == 121000 # 21000 + buffer
|
|
3164
3228
|
|
|
3165
3229
|
def test_eth_send_transaction_with_gas_price(
|
|
3166
|
-
self, w3: "Web3",
|
|
3230
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3167
3231
|
) -> None:
|
|
3168
3232
|
txn_params: TxParams = {
|
|
3169
|
-
"from":
|
|
3170
|
-
"to":
|
|
3233
|
+
"from": keyfile_account_address_dual_type,
|
|
3234
|
+
"to": keyfile_account_address_dual_type,
|
|
3171
3235
|
"value": Wei(1),
|
|
3172
3236
|
"gas": 21000,
|
|
3173
3237
|
"gasPrice": Wei(1),
|
|
@@ -3178,11 +3242,11 @@ class EthModuleTest:
|
|
|
3178
3242
|
w3.eth.send_transaction(txn_params)
|
|
3179
3243
|
|
|
3180
3244
|
def test_eth_send_transaction_no_priority_fee(
|
|
3181
|
-
self, w3: "Web3",
|
|
3245
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3182
3246
|
) -> None:
|
|
3183
3247
|
txn_params: TxParams = {
|
|
3184
|
-
"from":
|
|
3185
|
-
"to":
|
|
3248
|
+
"from": keyfile_account_address_dual_type,
|
|
3249
|
+
"to": keyfile_account_address_dual_type,
|
|
3186
3250
|
"value": Wei(1),
|
|
3187
3251
|
"gas": 21000,
|
|
3188
3252
|
"maxFeePerGas": Wei(250 * 10**9),
|
|
@@ -3193,12 +3257,12 @@ class EthModuleTest:
|
|
|
3193
3257
|
w3.eth.send_transaction(txn_params)
|
|
3194
3258
|
|
|
3195
3259
|
def test_eth_send_transaction_no_max_fee(
|
|
3196
|
-
self, w3: "Web3",
|
|
3260
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3197
3261
|
) -> None:
|
|
3198
3262
|
max_priority_fee_per_gas = w3.to_wei(2, "gwei")
|
|
3199
3263
|
txn_params: TxParams = {
|
|
3200
|
-
"from":
|
|
3201
|
-
"to":
|
|
3264
|
+
"from": keyfile_account_address_dual_type,
|
|
3265
|
+
"to": keyfile_account_address_dual_type,
|
|
3202
3266
|
"value": Wei(1),
|
|
3203
3267
|
"gas": 21000,
|
|
3204
3268
|
"maxPriorityFeePerGas": max_priority_fee_per_gas,
|
|
@@ -3215,11 +3279,11 @@ class EthModuleTest:
|
|
|
3215
3279
|
assert is_integer(txn["maxFeePerGas"])
|
|
3216
3280
|
|
|
3217
3281
|
def test_eth_send_transaction_max_fee_less_than_tip(
|
|
3218
|
-
self, w3: "Web3",
|
|
3282
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3219
3283
|
) -> None:
|
|
3220
3284
|
txn_params: TxParams = {
|
|
3221
|
-
"from":
|
|
3222
|
-
"to":
|
|
3285
|
+
"from": keyfile_account_address_dual_type,
|
|
3286
|
+
"to": keyfile_account_address_dual_type,
|
|
3223
3287
|
"value": Wei(1),
|
|
3224
3288
|
"gas": 21000,
|
|
3225
3289
|
"maxFeePerGas": Wei(1 * 10**9),
|
|
@@ -3231,14 +3295,14 @@ class EthModuleTest:
|
|
|
3231
3295
|
w3.eth.send_transaction(txn_params)
|
|
3232
3296
|
|
|
3233
3297
|
def test_validation_middleware_chain_id_mismatch(
|
|
3234
|
-
self, w3: "Web3",
|
|
3298
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3235
3299
|
) -> None:
|
|
3236
3300
|
wrong_chain_id = 1234567890
|
|
3237
3301
|
actual_chain_id = w3.eth.chain_id
|
|
3238
3302
|
|
|
3239
3303
|
txn_params: TxParams = {
|
|
3240
|
-
"from":
|
|
3241
|
-
"to":
|
|
3304
|
+
"from": keyfile_account_address_dual_type,
|
|
3305
|
+
"to": keyfile_account_address_dual_type,
|
|
3242
3306
|
"value": Wei(1),
|
|
3243
3307
|
"gas": Wei(21000),
|
|
3244
3308
|
"maxFeePerGas": w3.to_wei(2, "gwei"),
|
|
@@ -3256,12 +3320,15 @@ class EthModuleTest:
|
|
|
3256
3320
|
"max_fee", (1000000000, None), ids=["with_max_fee", "without_max_fee"]
|
|
3257
3321
|
)
|
|
3258
3322
|
def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn(
|
|
3259
|
-
self,
|
|
3323
|
+
self,
|
|
3324
|
+
w3: "Web3",
|
|
3325
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
3326
|
+
max_fee: Wei,
|
|
3260
3327
|
) -> None:
|
|
3261
3328
|
max_priority_fee = w3.to_wei(1, "gwei")
|
|
3262
3329
|
txn_params: TxParams = {
|
|
3263
|
-
"from":
|
|
3264
|
-
"to":
|
|
3330
|
+
"from": keyfile_account_address_dual_type,
|
|
3331
|
+
"to": keyfile_account_address_dual_type,
|
|
3265
3332
|
"value": Wei(1),
|
|
3266
3333
|
"gas": 21000,
|
|
3267
3334
|
"maxPriorityFeePerGas": max_priority_fee,
|
|
@@ -3291,11 +3358,11 @@ class EthModuleTest:
|
|
|
3291
3358
|
def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn_no_tip(
|
|
3292
3359
|
self,
|
|
3293
3360
|
w3: "Web3",
|
|
3294
|
-
|
|
3361
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
3295
3362
|
) -> None:
|
|
3296
3363
|
txn_params: TxParams = {
|
|
3297
|
-
"from":
|
|
3298
|
-
"to":
|
|
3364
|
+
"from": keyfile_account_address_dual_type,
|
|
3365
|
+
"to": keyfile_account_address_dual_type,
|
|
3299
3366
|
"value": Wei(1),
|
|
3300
3367
|
"gas": 21000,
|
|
3301
3368
|
"maxFeePerGas": Wei(1000000000),
|
|
@@ -3314,11 +3381,11 @@ class EthModuleTest:
|
|
|
3314
3381
|
w3.eth.set_gas_price_strategy(None) # reset strategy
|
|
3315
3382
|
|
|
3316
3383
|
def test_gas_price_strategy_hex_value(
|
|
3317
|
-
self, w3: "Web3",
|
|
3384
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3318
3385
|
) -> None:
|
|
3319
3386
|
txn_params: TxParams = {
|
|
3320
|
-
"from":
|
|
3321
|
-
"to":
|
|
3387
|
+
"from": keyfile_account_address_dual_type,
|
|
3388
|
+
"to": keyfile_account_address_dual_type,
|
|
3322
3389
|
"value": Wei(1),
|
|
3323
3390
|
"gas": 21000,
|
|
3324
3391
|
}
|
|
@@ -3337,11 +3404,11 @@ class EthModuleTest:
|
|
|
3337
3404
|
|
|
3338
3405
|
@flaky_geth_dev_mining
|
|
3339
3406
|
def test_eth_replace_transaction_legacy(
|
|
3340
|
-
self, w3: "Web3",
|
|
3407
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3341
3408
|
) -> None:
|
|
3342
3409
|
txn_params: TxParams = {
|
|
3343
|
-
"from":
|
|
3344
|
-
"to":
|
|
3410
|
+
"from": keyfile_account_address_dual_type,
|
|
3411
|
+
"to": keyfile_account_address_dual_type,
|
|
3345
3412
|
"value": Wei(1),
|
|
3346
3413
|
"gas": 21000,
|
|
3347
3414
|
"gasPrice": w3.to_wei(
|
|
@@ -3366,14 +3433,14 @@ class EthModuleTest:
|
|
|
3366
3433
|
|
|
3367
3434
|
@flaky_geth_dev_mining
|
|
3368
3435
|
def test_eth_replace_transaction(
|
|
3369
|
-
self, w3: "Web3",
|
|
3436
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3370
3437
|
) -> None:
|
|
3371
3438
|
two_gwei_in_wei = w3.to_wei(2, "gwei")
|
|
3372
3439
|
three_gwei_in_wei = w3.to_wei(3, "gwei")
|
|
3373
3440
|
|
|
3374
3441
|
txn_params: TxParams = {
|
|
3375
|
-
"from":
|
|
3376
|
-
"to":
|
|
3442
|
+
"from": keyfile_account_address_dual_type,
|
|
3443
|
+
"to": keyfile_account_address_dual_type,
|
|
3377
3444
|
"value": Wei(1),
|
|
3378
3445
|
"gas": 21000,
|
|
3379
3446
|
"maxFeePerGas": two_gwei_in_wei,
|
|
@@ -3400,11 +3467,11 @@ class EthModuleTest:
|
|
|
3400
3467
|
|
|
3401
3468
|
@flaky_geth_dev_mining
|
|
3402
3469
|
def test_eth_replace_transaction_underpriced(
|
|
3403
|
-
self, w3: "Web3",
|
|
3470
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3404
3471
|
) -> None:
|
|
3405
3472
|
txn_params: TxParams = {
|
|
3406
|
-
"from":
|
|
3407
|
-
"to":
|
|
3473
|
+
"from": keyfile_account_address_dual_type,
|
|
3474
|
+
"to": keyfile_account_address_dual_type,
|
|
3408
3475
|
"value": Wei(1),
|
|
3409
3476
|
"gas": 21000,
|
|
3410
3477
|
"maxFeePerGas": w3.to_wei(3, "gwei"),
|
|
@@ -3416,16 +3483,16 @@ class EthModuleTest:
|
|
|
3416
3483
|
txn_params["maxFeePerGas"] = one_gwei_in_wei
|
|
3417
3484
|
txn_params["maxPriorityFeePerGas"] = one_gwei_in_wei
|
|
3418
3485
|
|
|
3419
|
-
with pytest.raises(
|
|
3486
|
+
with pytest.raises(Web3RPCError, match="replacement transaction underpriced"):
|
|
3420
3487
|
w3.eth.replace_transaction(txn_hash, txn_params)
|
|
3421
3488
|
|
|
3422
3489
|
@flaky_geth_dev_mining
|
|
3423
3490
|
def test_eth_replace_transaction_non_existing_transaction(
|
|
3424
|
-
self, w3: "Web3",
|
|
3491
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3425
3492
|
) -> None:
|
|
3426
3493
|
txn_params: TxParams = {
|
|
3427
|
-
"from":
|
|
3428
|
-
"to":
|
|
3494
|
+
"from": keyfile_account_address_dual_type,
|
|
3495
|
+
"to": keyfile_account_address_dual_type,
|
|
3429
3496
|
"value": Wei(1),
|
|
3430
3497
|
"gas": 21000,
|
|
3431
3498
|
"maxFeePerGas": w3.to_wei(3, "gwei"),
|
|
@@ -3441,11 +3508,11 @@ class EthModuleTest:
|
|
|
3441
3508
|
|
|
3442
3509
|
@flaky_geth_dev_mining
|
|
3443
3510
|
def test_eth_replace_transaction_already_mined(
|
|
3444
|
-
self, w3: "Web3",
|
|
3511
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3445
3512
|
) -> None:
|
|
3446
3513
|
txn_params: TxParams = {
|
|
3447
|
-
"from":
|
|
3448
|
-
"to":
|
|
3514
|
+
"from": keyfile_account_address_dual_type,
|
|
3515
|
+
"to": keyfile_account_address_dual_type,
|
|
3449
3516
|
"value": Wei(1),
|
|
3450
3517
|
"gas": 21000,
|
|
3451
3518
|
"maxFeePerGas": w3.to_wei(2, "gwei"),
|
|
@@ -3456,16 +3523,16 @@ class EthModuleTest:
|
|
|
3456
3523
|
|
|
3457
3524
|
txn_params["maxFeePerGas"] = w3.to_wei(3, "gwei")
|
|
3458
3525
|
txn_params["maxPriorityFeePerGas"] = w3.to_wei(2, "gwei")
|
|
3459
|
-
with pytest.raises(
|
|
3526
|
+
with pytest.raises(Web3ValueError, match="Supplied transaction with hash"):
|
|
3460
3527
|
w3.eth.replace_transaction(txn_hash, txn_params)
|
|
3461
3528
|
|
|
3462
3529
|
@flaky_geth_dev_mining
|
|
3463
3530
|
def test_eth_replace_transaction_incorrect_nonce(
|
|
3464
|
-
self, w3: "Web3",
|
|
3531
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3465
3532
|
) -> None:
|
|
3466
3533
|
txn_params: TxParams = {
|
|
3467
|
-
"from":
|
|
3468
|
-
"to":
|
|
3534
|
+
"from": keyfile_account_address,
|
|
3535
|
+
"to": keyfile_account_address,
|
|
3469
3536
|
"value": Wei(1),
|
|
3470
3537
|
"gas": 21000,
|
|
3471
3538
|
"maxFeePerGas": w3.to_wei(2, "gwei"),
|
|
@@ -3477,16 +3544,16 @@ class EthModuleTest:
|
|
|
3477
3544
|
txn_params["maxFeePerGas"] = w3.to_wei(3, "gwei")
|
|
3478
3545
|
txn_params["maxPriorityFeePerGas"] = w3.to_wei(2, "gwei")
|
|
3479
3546
|
txn_params["nonce"] = Nonce(txn["nonce"] + 1)
|
|
3480
|
-
with pytest.raises(
|
|
3547
|
+
with pytest.raises(Web3ValueError):
|
|
3481
3548
|
w3.eth.replace_transaction(txn_hash, txn_params)
|
|
3482
3549
|
|
|
3483
3550
|
@flaky_geth_dev_mining
|
|
3484
3551
|
def test_eth_replace_transaction_gas_price_too_low(
|
|
3485
|
-
self, w3: "Web3",
|
|
3552
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3486
3553
|
) -> None:
|
|
3487
3554
|
txn_params: TxParams = {
|
|
3488
|
-
"from":
|
|
3489
|
-
"to":
|
|
3555
|
+
"from": keyfile_account_address_dual_type,
|
|
3556
|
+
"to": keyfile_account_address_dual_type,
|
|
3490
3557
|
"value": Wei(1),
|
|
3491
3558
|
"gas": 21000,
|
|
3492
3559
|
"gasPrice": w3.to_wei(2, "gwei"),
|
|
@@ -3494,18 +3561,18 @@ class EthModuleTest:
|
|
|
3494
3561
|
txn_hash = w3.eth.send_transaction(txn_params)
|
|
3495
3562
|
|
|
3496
3563
|
txn_params["gasPrice"] = w3.to_wei(1, "gwei")
|
|
3497
|
-
with pytest.raises(
|
|
3564
|
+
with pytest.raises(Web3ValueError):
|
|
3498
3565
|
w3.eth.replace_transaction(txn_hash, txn_params)
|
|
3499
3566
|
|
|
3500
3567
|
@flaky_geth_dev_mining
|
|
3501
3568
|
def test_eth_replace_transaction_gas_price_defaulting_minimum(
|
|
3502
|
-
self, w3: "Web3",
|
|
3569
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3503
3570
|
) -> None:
|
|
3504
3571
|
gas_price = w3.to_wei(1, "gwei")
|
|
3505
3572
|
|
|
3506
3573
|
txn_params: TxParams = {
|
|
3507
|
-
"from":
|
|
3508
|
-
"to":
|
|
3574
|
+
"from": keyfile_account_address,
|
|
3575
|
+
"to": keyfile_account_address,
|
|
3509
3576
|
"value": Wei(1),
|
|
3510
3577
|
"gas": 21000,
|
|
3511
3578
|
"gasPrice": gas_price,
|
|
@@ -3522,11 +3589,11 @@ class EthModuleTest:
|
|
|
3522
3589
|
|
|
3523
3590
|
@flaky_geth_dev_mining
|
|
3524
3591
|
def test_eth_replace_transaction_gas_price_defaulting_strategy_higher(
|
|
3525
|
-
self, w3: "Web3",
|
|
3592
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3526
3593
|
) -> None:
|
|
3527
3594
|
txn_params: TxParams = {
|
|
3528
|
-
"from":
|
|
3529
|
-
"to":
|
|
3595
|
+
"from": keyfile_account_address,
|
|
3596
|
+
"to": keyfile_account_address,
|
|
3530
3597
|
"value": Wei(1),
|
|
3531
3598
|
"gas": 21000,
|
|
3532
3599
|
"gasPrice": w3.to_wei(1, "gwei"),
|
|
@@ -3550,13 +3617,13 @@ class EthModuleTest:
|
|
|
3550
3617
|
|
|
3551
3618
|
@flaky_geth_dev_mining
|
|
3552
3619
|
def test_eth_replace_transaction_gas_price_defaulting_strategy_lower(
|
|
3553
|
-
self, w3: "Web3",
|
|
3620
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3554
3621
|
) -> None:
|
|
3555
3622
|
gas_price = w3.to_wei(2, "gwei")
|
|
3556
3623
|
|
|
3557
3624
|
txn_params: TxParams = {
|
|
3558
|
-
"from":
|
|
3559
|
-
"to":
|
|
3625
|
+
"from": keyfile_account_address,
|
|
3626
|
+
"to": keyfile_account_address,
|
|
3560
3627
|
"value": Wei(1),
|
|
3561
3628
|
"gas": 21000,
|
|
3562
3629
|
"gasPrice": gas_price,
|
|
@@ -3576,11 +3643,11 @@ class EthModuleTest:
|
|
|
3576
3643
|
w3.eth.set_gas_price_strategy(None) # reset strategy
|
|
3577
3644
|
|
|
3578
3645
|
def test_eth_modify_transaction_legacy(
|
|
3579
|
-
self, w3: "Web3",
|
|
3646
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3580
3647
|
) -> None:
|
|
3581
3648
|
txn_params: TxParams = {
|
|
3582
|
-
"from":
|
|
3583
|
-
"to":
|
|
3649
|
+
"from": keyfile_account_address,
|
|
3650
|
+
"to": keyfile_account_address,
|
|
3584
3651
|
"value": Wei(1),
|
|
3585
3652
|
"gas": 21000,
|
|
3586
3653
|
"gasPrice": w3.to_wei(
|
|
@@ -3605,11 +3672,11 @@ class EthModuleTest:
|
|
|
3605
3672
|
assert modified_txn["gasPrice"] == cast(int, txn_params["gasPrice"]) * 2
|
|
3606
3673
|
|
|
3607
3674
|
def test_eth_modify_transaction(
|
|
3608
|
-
self, w3: "Web3",
|
|
3675
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3609
3676
|
) -> None:
|
|
3610
3677
|
txn_params: TxParams = {
|
|
3611
|
-
"from":
|
|
3612
|
-
"to":
|
|
3678
|
+
"from": keyfile_account_address,
|
|
3679
|
+
"to": keyfile_account_address,
|
|
3613
3680
|
"value": Wei(1),
|
|
3614
3681
|
"gas": 21000,
|
|
3615
3682
|
"maxPriorityFeePerGas": w3.to_wei(1, "gwei"),
|
|
@@ -3640,23 +3707,21 @@ class EthModuleTest:
|
|
|
3640
3707
|
assert modified_txn["maxFeePerGas"] == cast(Wei, txn_params["maxFeePerGas"]) * 2
|
|
3641
3708
|
|
|
3642
3709
|
def test_eth_send_raw_transaction(
|
|
3643
|
-
self, w3: "Web3",
|
|
3644
|
-
) -> None:
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
)
|
|
3658
|
-
txn_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
|
|
3659
|
-
assert txn_hash == signed_tx.hash
|
|
3710
|
+
self, w3: "Web3", keyfile_account_pkey: HexStr
|
|
3711
|
+
) -> None:
|
|
3712
|
+
keyfile_account = w3.eth.account.from_key(keyfile_account_pkey)
|
|
3713
|
+
txn = {
|
|
3714
|
+
"chainId": 131277322940537, # the chainId set for the fixture
|
|
3715
|
+
"from": keyfile_account.address,
|
|
3716
|
+
"to": keyfile_account.address,
|
|
3717
|
+
"value": Wei(0),
|
|
3718
|
+
"gas": 21000,
|
|
3719
|
+
"nonce": w3.eth.get_transaction_count(keyfile_account.address, "pending"),
|
|
3720
|
+
"gasPrice": 10**9,
|
|
3721
|
+
}
|
|
3722
|
+
signed = keyfile_account.sign_transaction(txn)
|
|
3723
|
+
txn_hash = w3.eth.send_raw_transaction(signed.rawTransaction)
|
|
3724
|
+
assert txn_hash == HexBytes(signed.hash)
|
|
3660
3725
|
|
|
3661
3726
|
def test_eth_call(self, w3: "Web3", math_contract: "Contract") -> None:
|
|
3662
3727
|
coinbase = w3.eth.coinbase
|
|
@@ -3750,12 +3815,12 @@ class EthModuleTest:
|
|
|
3750
3815
|
self,
|
|
3751
3816
|
w3: "Web3",
|
|
3752
3817
|
revert_contract: "Contract",
|
|
3753
|
-
|
|
3818
|
+
keyfile_account_address: ChecksumAddress,
|
|
3754
3819
|
) -> None:
|
|
3755
3820
|
txn_params = revert_contract._prepare_transaction(
|
|
3756
3821
|
fn_name="revertWithMessage",
|
|
3757
3822
|
transaction={
|
|
3758
|
-
"from":
|
|
3823
|
+
"from": keyfile_account_address,
|
|
3759
3824
|
"to": revert_contract.address,
|
|
3760
3825
|
},
|
|
3761
3826
|
)
|
|
@@ -3770,13 +3835,13 @@ class EthModuleTest:
|
|
|
3770
3835
|
self,
|
|
3771
3836
|
w3: "Web3",
|
|
3772
3837
|
revert_contract: "Contract",
|
|
3773
|
-
|
|
3838
|
+
keyfile_account_address: ChecksumAddress,
|
|
3774
3839
|
) -> None:
|
|
3775
3840
|
with pytest.raises(ContractLogicError, match="execution reverted"):
|
|
3776
3841
|
txn_params = revert_contract._prepare_transaction(
|
|
3777
3842
|
fn_name="revertWithoutMessage",
|
|
3778
3843
|
transaction={
|
|
3779
|
-
"from":
|
|
3844
|
+
"from": keyfile_account_address,
|
|
3780
3845
|
"to": revert_contract.address,
|
|
3781
3846
|
},
|
|
3782
3847
|
)
|
|
@@ -3786,7 +3851,7 @@ class EthModuleTest:
|
|
|
3786
3851
|
self,
|
|
3787
3852
|
w3: "Web3",
|
|
3788
3853
|
revert_contract: "Contract",
|
|
3789
|
-
|
|
3854
|
+
keyfile_account_address: ChecksumAddress,
|
|
3790
3855
|
) -> None:
|
|
3791
3856
|
data = revert_contract.encode_abi(
|
|
3792
3857
|
fn_name="UnauthorizedWithMessage", args=["You are not authorized"]
|
|
@@ -3794,7 +3859,7 @@ class EthModuleTest:
|
|
|
3794
3859
|
txn_params = revert_contract._prepare_transaction(
|
|
3795
3860
|
fn_name="customErrorWithMessage",
|
|
3796
3861
|
transaction={
|
|
3797
|
-
"from":
|
|
3862
|
+
"from": keyfile_account_address,
|
|
3798
3863
|
"to": revert_contract.address,
|
|
3799
3864
|
},
|
|
3800
3865
|
)
|
|
@@ -3806,13 +3871,13 @@ class EthModuleTest:
|
|
|
3806
3871
|
self,
|
|
3807
3872
|
w3: "Web3",
|
|
3808
3873
|
revert_contract: "Contract",
|
|
3809
|
-
|
|
3874
|
+
keyfile_account_address: ChecksumAddress,
|
|
3810
3875
|
) -> None:
|
|
3811
3876
|
data = revert_contract.encode_abi(fn_name="Unauthorized")
|
|
3812
3877
|
txn_params = revert_contract._prepare_transaction(
|
|
3813
3878
|
fn_name="customErrorWithoutMessage",
|
|
3814
3879
|
transaction={
|
|
3815
|
-
"from":
|
|
3880
|
+
"from": keyfile_account_address,
|
|
3816
3881
|
"to": revert_contract.address,
|
|
3817
3882
|
},
|
|
3818
3883
|
)
|
|
@@ -3854,7 +3919,7 @@ class EthModuleTest:
|
|
|
3854
3919
|
self,
|
|
3855
3920
|
w3: "Web3",
|
|
3856
3921
|
offchain_lookup_contract: "Contract",
|
|
3857
|
-
|
|
3922
|
+
keyfile_account_address: ChecksumAddress,
|
|
3858
3923
|
monkeypatch: "MonkeyPatch",
|
|
3859
3924
|
) -> None:
|
|
3860
3925
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -3909,7 +3974,7 @@ class EthModuleTest:
|
|
|
3909
3974
|
self,
|
|
3910
3975
|
w3: "Web3",
|
|
3911
3976
|
offchain_lookup_contract: "Contract",
|
|
3912
|
-
|
|
3977
|
+
keyfile_account_address: ChecksumAddress,
|
|
3913
3978
|
monkeypatch: "MonkeyPatch",
|
|
3914
3979
|
) -> None:
|
|
3915
3980
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -3940,7 +4005,7 @@ class EthModuleTest:
|
|
|
3940
4005
|
default_max_redirects = w3.provider.ccip_read_max_redirects
|
|
3941
4006
|
|
|
3942
4007
|
w3.provider.ccip_read_max_redirects = max_redirects
|
|
3943
|
-
with pytest.raises(
|
|
4008
|
+
with pytest.raises(Web3ValueError, match="at least 4"):
|
|
3944
4009
|
offchain_lookup_contract.functions.testOffchainLookup(
|
|
3945
4010
|
OFFCHAIN_LOOKUP_TEST_DATA
|
|
3946
4011
|
).call()
|
|
@@ -3951,7 +4016,7 @@ class EthModuleTest:
|
|
|
3951
4016
|
self,
|
|
3952
4017
|
w3: "Web3",
|
|
3953
4018
|
offchain_lookup_contract: "Contract",
|
|
3954
|
-
|
|
4019
|
+
keyfile_account_address: ChecksumAddress,
|
|
3955
4020
|
monkeypatch: "MonkeyPatch",
|
|
3956
4021
|
) -> None:
|
|
3957
4022
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -3973,7 +4038,7 @@ class EthModuleTest:
|
|
|
3973
4038
|
self,
|
|
3974
4039
|
w3: "Web3",
|
|
3975
4040
|
offchain_lookup_contract: "Contract",
|
|
3976
|
-
|
|
4041
|
+
keyfile_account_address: ChecksumAddress,
|
|
3977
4042
|
monkeypatch: "MonkeyPatch",
|
|
3978
4043
|
status_code_non_4xx_error: int,
|
|
3979
4044
|
) -> None:
|
|
@@ -4010,7 +4075,7 @@ class EthModuleTest:
|
|
|
4010
4075
|
self,
|
|
4011
4076
|
w3: "Web3",
|
|
4012
4077
|
offchain_lookup_contract: "Contract",
|
|
4013
|
-
|
|
4078
|
+
keyfile_account_address: ChecksumAddress,
|
|
4014
4079
|
monkeypatch: "MonkeyPatch",
|
|
4015
4080
|
) -> None:
|
|
4016
4081
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -4029,7 +4094,6 @@ class EthModuleTest:
|
|
|
4029
4094
|
|
|
4030
4095
|
def test_eth_call_offchain_lookup_raises_when_all_supplied_urls_fail(
|
|
4031
4096
|
self,
|
|
4032
|
-
w3: "Web3",
|
|
4033
4097
|
offchain_lookup_contract: "Contract",
|
|
4034
4098
|
) -> None:
|
|
4035
4099
|
# GET and POST requests should fail since responses are not mocked
|
|
@@ -4042,9 +4106,7 @@ class EthModuleTest:
|
|
|
4042
4106
|
|
|
4043
4107
|
def test_eth_call_continuous_offchain_lookup_raises_with_too_many_requests(
|
|
4044
4108
|
self,
|
|
4045
|
-
w3: "Web3",
|
|
4046
4109
|
offchain_lookup_contract: "Contract",
|
|
4047
|
-
unlocked_account: ChecksumAddress,
|
|
4048
4110
|
monkeypatch: "MonkeyPatch",
|
|
4049
4111
|
) -> None:
|
|
4050
4112
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -4061,7 +4123,7 @@ class EthModuleTest:
|
|
|
4061
4123
|
self,
|
|
4062
4124
|
w3: "Web3",
|
|
4063
4125
|
revert_contract: "Contract",
|
|
4064
|
-
|
|
4126
|
+
keyfile_account_address: ChecksumAddress,
|
|
4065
4127
|
) -> None:
|
|
4066
4128
|
with pytest.raises(
|
|
4067
4129
|
ContractLogicError, match="execution reverted: Function has been reverted"
|
|
@@ -4069,7 +4131,7 @@ class EthModuleTest:
|
|
|
4069
4131
|
txn_params = revert_contract._prepare_transaction(
|
|
4070
4132
|
fn_name="revertWithMessage",
|
|
4071
4133
|
transaction={
|
|
4072
|
-
"from":
|
|
4134
|
+
"from": keyfile_account_address,
|
|
4073
4135
|
"to": revert_contract.address,
|
|
4074
4136
|
},
|
|
4075
4137
|
)
|
|
@@ -4079,13 +4141,13 @@ class EthModuleTest:
|
|
|
4079
4141
|
self,
|
|
4080
4142
|
w3: "Web3",
|
|
4081
4143
|
revert_contract: "Contract",
|
|
4082
|
-
|
|
4144
|
+
keyfile_account_address: ChecksumAddress,
|
|
4083
4145
|
) -> None:
|
|
4084
4146
|
with pytest.raises(ContractLogicError, match="execution reverted"):
|
|
4085
4147
|
txn_params = revert_contract._prepare_transaction(
|
|
4086
4148
|
fn_name="revertWithoutMessage",
|
|
4087
4149
|
transaction={
|
|
4088
|
-
"from":
|
|
4150
|
+
"from": keyfile_account_address,
|
|
4089
4151
|
"to": revert_contract.address,
|
|
4090
4152
|
},
|
|
4091
4153
|
)
|
|
@@ -4095,7 +4157,7 @@ class EthModuleTest:
|
|
|
4095
4157
|
self,
|
|
4096
4158
|
w3: "Web3",
|
|
4097
4159
|
revert_contract: "Contract",
|
|
4098
|
-
|
|
4160
|
+
keyfile_account_address: ChecksumAddress,
|
|
4099
4161
|
) -> None:
|
|
4100
4162
|
data = revert_contract.encode_abi(
|
|
4101
4163
|
fn_name="UnauthorizedWithMessage", args=["You are not authorized"]
|
|
@@ -4103,7 +4165,7 @@ class EthModuleTest:
|
|
|
4103
4165
|
txn_params = revert_contract._prepare_transaction(
|
|
4104
4166
|
fn_name="customErrorWithMessage",
|
|
4105
4167
|
transaction={
|
|
4106
|
-
"from":
|
|
4168
|
+
"from": keyfile_account_address,
|
|
4107
4169
|
"to": revert_contract.address,
|
|
4108
4170
|
},
|
|
4109
4171
|
)
|
|
@@ -4115,13 +4177,13 @@ class EthModuleTest:
|
|
|
4115
4177
|
self,
|
|
4116
4178
|
w3: "Web3",
|
|
4117
4179
|
revert_contract: "Contract",
|
|
4118
|
-
|
|
4180
|
+
keyfile_account_address: ChecksumAddress,
|
|
4119
4181
|
) -> None:
|
|
4120
4182
|
data = revert_contract.encode_abi(fn_name="Unauthorized")
|
|
4121
4183
|
txn_params = revert_contract._prepare_transaction(
|
|
4122
4184
|
fn_name="customErrorWithoutMessage",
|
|
4123
4185
|
transaction={
|
|
4124
|
-
"from":
|
|
4186
|
+
"from": keyfile_account_address,
|
|
4125
4187
|
"to": revert_contract.address,
|
|
4126
4188
|
},
|
|
4127
4189
|
)
|
|
@@ -4130,12 +4192,12 @@ class EthModuleTest:
|
|
|
4130
4192
|
assert excinfo.value.data == data
|
|
4131
4193
|
|
|
4132
4194
|
def test_eth_estimate_gas(
|
|
4133
|
-
self, w3: "Web3",
|
|
4195
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
4134
4196
|
) -> None:
|
|
4135
4197
|
gas_estimate = w3.eth.estimate_gas(
|
|
4136
4198
|
{
|
|
4137
|
-
"from":
|
|
4138
|
-
"to":
|
|
4199
|
+
"from": keyfile_account_address_dual_type,
|
|
4200
|
+
"to": keyfile_account_address_dual_type,
|
|
4139
4201
|
"value": Wei(1),
|
|
4140
4202
|
}
|
|
4141
4203
|
)
|
|
@@ -4143,12 +4205,12 @@ class EthModuleTest:
|
|
|
4143
4205
|
assert gas_estimate > 0
|
|
4144
4206
|
|
|
4145
4207
|
def test_eth_estimate_gas_with_block(
|
|
4146
|
-
self, w3: "Web3",
|
|
4208
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
4147
4209
|
) -> None:
|
|
4148
4210
|
gas_estimate = w3.eth.estimate_gas(
|
|
4149
4211
|
{
|
|
4150
|
-
"from":
|
|
4151
|
-
"to":
|
|
4212
|
+
"from": keyfile_account_address_dual_type,
|
|
4213
|
+
"to": keyfile_account_address_dual_type,
|
|
4152
4214
|
"value": Wei(1),
|
|
4153
4215
|
},
|
|
4154
4216
|
"latest",
|
|
@@ -4255,7 +4317,7 @@ class EthModuleTest:
|
|
|
4255
4317
|
) -> None:
|
|
4256
4318
|
block = w3.eth.get_block(block_with_txn["number"], True)
|
|
4257
4319
|
transaction = block["transactions"][0]
|
|
4258
|
-
assert transaction["hash"] == block_with_txn["transactions"][0]
|
|
4320
|
+
assert transaction["hash"] == block_with_txn["transactions"][0]
|
|
4259
4321
|
|
|
4260
4322
|
def test_eth_getBlockReceipts_hash(
|
|
4261
4323
|
self, w3: "Web3", empty_block: BlockData
|
|
@@ -4329,12 +4391,12 @@ class EthModuleTest:
|
|
|
4329
4391
|
assert effective_gas_price > 0
|
|
4330
4392
|
|
|
4331
4393
|
def test_eth_get_transaction_receipt_unmined(
|
|
4332
|
-
self, w3: "Web3",
|
|
4394
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
4333
4395
|
) -> None:
|
|
4334
4396
|
txn_hash = w3.eth.send_transaction(
|
|
4335
4397
|
{
|
|
4336
|
-
"from":
|
|
4337
|
-
"to":
|
|
4398
|
+
"from": keyfile_account_address_dual_type,
|
|
4399
|
+
"to": keyfile_account_address_dual_type,
|
|
4338
4400
|
"value": Wei(1),
|
|
4339
4401
|
"gas": 21000,
|
|
4340
4402
|
"maxFeePerGas": w3.to_wei(3, "gwei"),
|
|
@@ -4386,12 +4448,12 @@ class EthModuleTest:
|
|
|
4386
4448
|
assert effective_gas_price > 0
|
|
4387
4449
|
|
|
4388
4450
|
def test_eth_wait_for_transaction_receipt_unmined(
|
|
4389
|
-
self, w3: "Web3",
|
|
4451
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
4390
4452
|
) -> None:
|
|
4391
4453
|
txn_hash = w3.eth.send_transaction(
|
|
4392
4454
|
{
|
|
4393
|
-
"from":
|
|
4394
|
-
"to":
|
|
4455
|
+
"from": keyfile_account_address_dual_type,
|
|
4456
|
+
"to": keyfile_account_address_dual_type,
|
|
4395
4457
|
"value": Wei(1),
|
|
4396
4458
|
"gas": 21000,
|
|
4397
4459
|
"maxFeePerGas": w3.to_wei(3, "gwei"),
|
|
@@ -4489,7 +4551,7 @@ class EthModuleTest:
|
|
|
4489
4551
|
"fromBlock": block_with_txn_with_log["number"],
|
|
4490
4552
|
"toBlock": BlockNumber(block_with_txn_with_log["number"] - 1),
|
|
4491
4553
|
}
|
|
4492
|
-
with pytest.raises(
|
|
4554
|
+
with pytest.raises(Web3RPCError):
|
|
4493
4555
|
w3.eth.get_logs(filter_params)
|
|
4494
4556
|
|
|
4495
4557
|
# Test with `address`
|
|
@@ -4598,35 +4660,35 @@ class EthModuleTest:
|
|
|
4598
4660
|
assert len(result) == 0
|
|
4599
4661
|
|
|
4600
4662
|
def test_eth_call_old_contract_state(
|
|
4601
|
-
self,
|
|
4663
|
+
self,
|
|
4664
|
+
w3: "Web3",
|
|
4665
|
+
math_contract: "Contract",
|
|
4666
|
+
keyfile_account_address: ChecksumAddress,
|
|
4602
4667
|
) -> None:
|
|
4603
|
-
|
|
4604
|
-
block_num =
|
|
4605
|
-
block_hash =
|
|
4606
|
-
|
|
4607
|
-
math_contract.functions.incrementCounter().transact({"from": unlocked_account})
|
|
4668
|
+
latest_block = w3.eth.get_block("latest")
|
|
4669
|
+
block_num = latest_block["number"]
|
|
4670
|
+
block_hash = latest_block["hash"]
|
|
4608
4671
|
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
# Ideas to improve this test:
|
|
4613
|
-
# - Enable on-demand mining in more clients
|
|
4614
|
-
# - Increment the math contract in all of the fixtures, and check the
|
|
4615
|
-
# value in an old block
|
|
4672
|
+
latest_call_result = math_contract.functions.counter().call(
|
|
4673
|
+
block_identifier="latest"
|
|
4674
|
+
)
|
|
4616
4675
|
block_hash_call_result = math_contract.functions.counter().call(
|
|
4617
4676
|
block_identifier=block_hash
|
|
4618
4677
|
)
|
|
4619
4678
|
block_num_call_result = math_contract.functions.counter().call(
|
|
4620
4679
|
block_identifier=block_num
|
|
4621
4680
|
)
|
|
4622
|
-
latest_call_result = math_contract.functions.counter().call(
|
|
4623
|
-
block_identifier="latest"
|
|
4624
|
-
)
|
|
4625
4681
|
default_call_result = math_contract.functions.counter().call()
|
|
4682
|
+
|
|
4683
|
+
# send and wait 1 second to mine
|
|
4684
|
+
math_contract.functions.incrementCounter().transact(
|
|
4685
|
+
{"from": keyfile_account_address}
|
|
4686
|
+
)
|
|
4687
|
+
time.sleep(1)
|
|
4688
|
+
|
|
4626
4689
|
pending_call_result = math_contract.functions.counter().call(
|
|
4627
4690
|
block_identifier="pending"
|
|
4628
4691
|
)
|
|
4629
|
-
|
|
4630
4692
|
assert block_hash_call_result == 0
|
|
4631
4693
|
assert block_num_call_result == 0
|
|
4632
4694
|
assert latest_call_result == 0
|
|
@@ -4660,15 +4722,15 @@ class EthModuleTest:
|
|
|
4660
4722
|
def test_eth_get_raw_transaction_by_block(
|
|
4661
4723
|
self,
|
|
4662
4724
|
w3: "Web3",
|
|
4663
|
-
|
|
4725
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
4664
4726
|
block_with_txn: BlockData,
|
|
4665
4727
|
) -> None:
|
|
4666
4728
|
# eth_getRawTransactionByBlockNumberAndIndex: block identifier
|
|
4667
4729
|
# send a txn to make sure pending block has at least one txn
|
|
4668
4730
|
w3.eth.send_transaction(
|
|
4669
4731
|
{
|
|
4670
|
-
"from":
|
|
4671
|
-
"to":
|
|
4732
|
+
"from": keyfile_account_address_dual_type,
|
|
4733
|
+
"to": keyfile_account_address_dual_type,
|
|
4672
4734
|
"value": Wei(1),
|
|
4673
4735
|
}
|
|
4674
4736
|
)
|
|
@@ -4708,25 +4770,25 @@ class EthModuleTest:
|
|
|
4708
4770
|
) -> None:
|
|
4709
4771
|
unknown_identifier = "unknown"
|
|
4710
4772
|
with pytest.raises(
|
|
4711
|
-
|
|
4773
|
+
Web3ValueError,
|
|
4712
4774
|
match=(
|
|
4713
4775
|
"Value did not match any of the recognized block identifiers: "
|
|
4714
4776
|
f"{unknown_identifier}"
|
|
4715
4777
|
),
|
|
4716
4778
|
):
|
|
4717
|
-
w3.eth.get_raw_transaction_by_block(unknown_identifier, 0)
|
|
4779
|
+
w3.eth.get_raw_transaction_by_block(unknown_identifier, 0)
|
|
4718
4780
|
|
|
4719
4781
|
def test_default_account(
|
|
4720
|
-
self, w3: "Web3",
|
|
4782
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
4721
4783
|
) -> None:
|
|
4722
4784
|
# check defaults to empty
|
|
4723
4785
|
default_account = w3.eth.default_account
|
|
4724
4786
|
assert default_account is empty
|
|
4725
4787
|
|
|
4726
4788
|
# check setter
|
|
4727
|
-
w3.eth.default_account =
|
|
4789
|
+
w3.eth.default_account = keyfile_account_address_dual_type
|
|
4728
4790
|
default_account = w3.eth.default_account
|
|
4729
|
-
assert default_account ==
|
|
4791
|
+
assert default_account == keyfile_account_address_dual_type
|
|
4730
4792
|
|
|
4731
4793
|
# reset to default
|
|
4732
4794
|
w3.eth.default_account = empty
|