web3 7.0.0b4__py3-none-any.whl → 7.0.0b6__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.
- web3/_utils/batching.py +217 -0
- web3/_utils/caching.py +26 -2
- web3/_utils/compat/__init__.py +1 -0
- web3/_utils/contracts.py +5 -5
- web3/_utils/events.py +20 -20
- web3/_utils/filters.py +6 -6
- web3/_utils/method_formatters.py +0 -23
- web3/_utils/module_testing/__init__.py +0 -3
- web3/_utils/module_testing/eth_module.py +442 -373
- web3/_utils/module_testing/module_testing_utils.py +13 -0
- web3/_utils/module_testing/web3_module.py +438 -17
- web3/_utils/rpc_abi.py +0 -18
- web3/contract/async_contract.py +11 -11
- web3/contract/base_contract.py +19 -18
- web3/contract/contract.py +13 -13
- web3/contract/utils.py +112 -4
- web3/eth/async_eth.py +10 -8
- web3/eth/eth.py +7 -6
- web3/exceptions.py +75 -21
- web3/gas_strategies/time_based.py +2 -2
- web3/geth.py +0 -188
- web3/main.py +21 -13
- web3/manager.py +237 -74
- web3/method.py +29 -9
- web3/middleware/base.py +43 -0
- web3/middleware/filter.py +18 -6
- web3/middleware/signing.py +2 -2
- web3/module.py +47 -7
- web3/providers/async_base.py +55 -23
- web3/providers/base.py +59 -26
- web3/providers/eth_tester/defaults.py +0 -48
- web3/providers/eth_tester/main.py +36 -11
- web3/providers/eth_tester/middleware.py +3 -8
- web3/providers/ipc.py +23 -8
- web3/providers/legacy_websocket.py +26 -1
- web3/providers/persistent/async_ipc.py +60 -76
- web3/providers/persistent/persistent.py +134 -10
- web3/providers/persistent/request_processor.py +98 -14
- web3/providers/persistent/websocket.py +43 -66
- web3/providers/rpc/async_rpc.py +20 -2
- web3/providers/rpc/rpc.py +22 -2
- web3/providers/rpc/utils.py +1 -10
- web3/tools/benchmark/node.py +2 -8
- web3/types.py +8 -2
- {web3-7.0.0b4.dist-info → web3-7.0.0b6.dist-info}/LICENSE +1 -1
- {web3-7.0.0b4.dist-info → web3-7.0.0b6.dist-info}/METADATA +32 -21
- {web3-7.0.0b4.dist-info → web3-7.0.0b6.dist-info}/RECORD +49 -49
- web3/_utils/module_testing/go_ethereum_personal_module.py +0 -300
- {web3-7.0.0b4.dist-info → web3-7.0.0b6.dist-info}/WHEEL +0 -0
- {web3-7.0.0b4.dist-info → web3-7.0.0b6.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,
|
|
@@ -179,11 +182,13 @@ class AsyncEthModuleTest:
|
|
|
179
182
|
|
|
180
183
|
@pytest.mark.asyncio
|
|
181
184
|
async def test_eth_send_transaction_legacy(
|
|
182
|
-
self,
|
|
185
|
+
self,
|
|
186
|
+
async_w3: "AsyncWeb3",
|
|
187
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
183
188
|
) -> None:
|
|
184
189
|
txn_params: TxParams = {
|
|
185
|
-
"from":
|
|
186
|
-
"to":
|
|
190
|
+
"from": async_keyfile_account_address_dual_type,
|
|
191
|
+
"to": async_keyfile_account_address_dual_type,
|
|
187
192
|
"value": Wei(1),
|
|
188
193
|
"gas": 21000,
|
|
189
194
|
"gasPrice": await async_w3.eth.gas_price,
|
|
@@ -199,11 +204,13 @@ class AsyncEthModuleTest:
|
|
|
199
204
|
|
|
200
205
|
@pytest.mark.asyncio
|
|
201
206
|
async def test_eth_modify_transaction_legacy(
|
|
202
|
-
self,
|
|
207
|
+
self,
|
|
208
|
+
async_w3: "AsyncWeb3",
|
|
209
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
203
210
|
) -> None:
|
|
204
211
|
txn_params: TxParams = {
|
|
205
|
-
"from":
|
|
206
|
-
"to":
|
|
212
|
+
"from": async_keyfile_account_address_dual_type,
|
|
213
|
+
"to": async_keyfile_account_address_dual_type,
|
|
207
214
|
"value": Wei(1),
|
|
208
215
|
"gas": 21000,
|
|
209
216
|
"gasPrice": async_w3.to_wei(
|
|
@@ -213,7 +220,7 @@ class AsyncEthModuleTest:
|
|
|
213
220
|
txn_hash = await async_w3.eth.send_transaction(txn_params)
|
|
214
221
|
|
|
215
222
|
modified_txn_hash = await async_w3.eth.modify_transaction(
|
|
216
|
-
txn_hash, gasPrice=(cast(
|
|
223
|
+
txn_hash, gasPrice=(cast(Wei, txn_params["gasPrice"] * 2)), value=Wei(2)
|
|
217
224
|
)
|
|
218
225
|
modified_txn = await async_w3.eth.get_transaction(modified_txn_hash)
|
|
219
226
|
|
|
@@ -229,11 +236,13 @@ class AsyncEthModuleTest:
|
|
|
229
236
|
|
|
230
237
|
@pytest.mark.asyncio
|
|
231
238
|
async def test_eth_modify_transaction(
|
|
232
|
-
self,
|
|
239
|
+
self,
|
|
240
|
+
async_w3: "AsyncWeb3",
|
|
241
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
233
242
|
) -> None:
|
|
234
243
|
txn_params: TxParams = {
|
|
235
|
-
"from":
|
|
236
|
-
"to":
|
|
244
|
+
"from": async_keyfile_account_address_dual_type,
|
|
245
|
+
"to": async_keyfile_account_address_dual_type,
|
|
237
246
|
"value": Wei(1),
|
|
238
247
|
"gas": 21000,
|
|
239
248
|
"maxPriorityFeePerGas": async_w3.to_wei(1, "gwei"),
|
|
@@ -243,9 +252,9 @@ class AsyncEthModuleTest:
|
|
|
243
252
|
|
|
244
253
|
modified_txn_hash = await async_w3.eth.modify_transaction(
|
|
245
254
|
txn_hash,
|
|
246
|
-
value=2,
|
|
247
|
-
maxPriorityFeePerGas=(cast(Wei, txn_params["maxPriorityFeePerGas"]
|
|
248
|
-
maxFeePerGas=(cast(Wei, txn_params["maxFeePerGas"]
|
|
255
|
+
value=Wei(2),
|
|
256
|
+
maxPriorityFeePerGas=(cast(Wei, txn_params["maxPriorityFeePerGas"] * 2)),
|
|
257
|
+
maxFeePerGas=(cast(Wei, txn_params["maxFeePerGas"] * 2)),
|
|
249
258
|
)
|
|
250
259
|
modified_txn = await async_w3.eth.get_transaction(modified_txn_hash)
|
|
251
260
|
|
|
@@ -265,11 +274,13 @@ class AsyncEthModuleTest:
|
|
|
265
274
|
|
|
266
275
|
@pytest.mark.asyncio
|
|
267
276
|
async def test_async_eth_sign_transaction(
|
|
268
|
-
self,
|
|
277
|
+
self,
|
|
278
|
+
async_w3: "AsyncWeb3",
|
|
279
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
269
280
|
) -> None:
|
|
270
281
|
txn_params: TxParams = {
|
|
271
|
-
"from":
|
|
272
|
-
"to":
|
|
282
|
+
"from": async_keyfile_account_address_dual_type,
|
|
283
|
+
"to": async_keyfile_account_address_dual_type,
|
|
273
284
|
"value": Wei(1),
|
|
274
285
|
"gas": 21000,
|
|
275
286
|
"maxFeePerGas": async_w3.to_wei(2, "gwei"),
|
|
@@ -278,7 +289,7 @@ class AsyncEthModuleTest:
|
|
|
278
289
|
}
|
|
279
290
|
result = await async_w3.eth.sign_transaction(txn_params)
|
|
280
291
|
signatory_account = async_w3.eth.account.recover_transaction(result["raw"])
|
|
281
|
-
assert
|
|
292
|
+
assert async_keyfile_account_address_dual_type == signatory_account
|
|
282
293
|
assert result["tx"]["to"] == txn_params["to"]
|
|
283
294
|
assert result["tx"]["value"] == txn_params["value"]
|
|
284
295
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -292,7 +303,7 @@ class AsyncEthModuleTest:
|
|
|
292
303
|
async def test_eth_sign_typed_data(
|
|
293
304
|
self,
|
|
294
305
|
async_w3: "AsyncWeb3",
|
|
295
|
-
|
|
306
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
296
307
|
async_skip_if_testrpc: Callable[["AsyncWeb3"], None],
|
|
297
308
|
) -> None:
|
|
298
309
|
validJSONMessage = """
|
|
@@ -337,7 +348,7 @@ class AsyncEthModuleTest:
|
|
|
337
348
|
async_skip_if_testrpc(async_w3)
|
|
338
349
|
signature = HexBytes(
|
|
339
350
|
await async_w3.eth.sign_typed_data(
|
|
340
|
-
|
|
351
|
+
async_keyfile_account_address_dual_type, json.loads(validJSONMessage)
|
|
341
352
|
)
|
|
342
353
|
)
|
|
343
354
|
assert len(signature) == 32 + 32 + 1
|
|
@@ -346,7 +357,7 @@ class AsyncEthModuleTest:
|
|
|
346
357
|
async def test_invalid_eth_sign_typed_data(
|
|
347
358
|
self,
|
|
348
359
|
async_w3: "AsyncWeb3",
|
|
349
|
-
|
|
360
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
350
361
|
async_skip_if_testrpc: Callable[["AsyncWeb3"], None],
|
|
351
362
|
) -> None:
|
|
352
363
|
async_skip_if_testrpc(async_w3)
|
|
@@ -390,20 +401,21 @@ class AsyncEthModuleTest:
|
|
|
390
401
|
}
|
|
391
402
|
"""
|
|
392
403
|
with pytest.raises(
|
|
393
|
-
|
|
404
|
+
Web3ValueError,
|
|
394
405
|
match=r".*Expected 2 items for array type Person\[2\], got 1 items.*",
|
|
395
406
|
):
|
|
396
407
|
await async_w3.eth.sign_typed_data(
|
|
397
|
-
|
|
408
|
+
async_keyfile_account_address_dual_type,
|
|
409
|
+
json.loads(invalid_typed_message),
|
|
398
410
|
)
|
|
399
411
|
|
|
400
412
|
@pytest.mark.asyncio
|
|
401
413
|
async def test_async_eth_sign_transaction_legacy(
|
|
402
|
-
self, async_w3: "AsyncWeb3",
|
|
414
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
403
415
|
) -> None:
|
|
404
416
|
txn_params: TxParams = {
|
|
405
|
-
"from":
|
|
406
|
-
"to":
|
|
417
|
+
"from": async_keyfile_account_address,
|
|
418
|
+
"to": async_keyfile_account_address,
|
|
407
419
|
"value": Wei(1),
|
|
408
420
|
"gas": 21000,
|
|
409
421
|
"gasPrice": await async_w3.eth.gas_price,
|
|
@@ -411,7 +423,7 @@ class AsyncEthModuleTest:
|
|
|
411
423
|
}
|
|
412
424
|
result = await async_w3.eth.sign_transaction(txn_params)
|
|
413
425
|
signatory_account = async_w3.eth.account.recover_transaction(result["raw"])
|
|
414
|
-
assert
|
|
426
|
+
assert async_keyfile_account_address == signatory_account
|
|
415
427
|
assert result["tx"]["to"] == txn_params["to"]
|
|
416
428
|
assert result["tx"]["value"] == txn_params["value"]
|
|
417
429
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -420,11 +432,11 @@ class AsyncEthModuleTest:
|
|
|
420
432
|
|
|
421
433
|
@pytest.mark.asyncio
|
|
422
434
|
async def test_async_eth_sign_transaction_hex_fees(
|
|
423
|
-
self, async_w3: "AsyncWeb3",
|
|
435
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
424
436
|
) -> None:
|
|
425
437
|
txn_params: TxParams = {
|
|
426
|
-
"from":
|
|
427
|
-
"to":
|
|
438
|
+
"from": async_keyfile_account_address,
|
|
439
|
+
"to": async_keyfile_account_address,
|
|
428
440
|
"value": Wei(1),
|
|
429
441
|
"gas": 21000,
|
|
430
442
|
"maxFeePerGas": hex(async_w3.to_wei(2, "gwei")),
|
|
@@ -433,7 +445,7 @@ class AsyncEthModuleTest:
|
|
|
433
445
|
}
|
|
434
446
|
result = await async_w3.eth.sign_transaction(txn_params)
|
|
435
447
|
signatory_account = async_w3.eth.account.recover_transaction(result["raw"])
|
|
436
|
-
assert
|
|
448
|
+
assert async_keyfile_account_address == signatory_account
|
|
437
449
|
assert result["tx"]["to"] == txn_params["to"]
|
|
438
450
|
assert result["tx"]["value"] == txn_params["value"]
|
|
439
451
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -448,9 +460,11 @@ class AsyncEthModuleTest:
|
|
|
448
460
|
reason="async name_to_address_middleware has not been implemented yet"
|
|
449
461
|
)
|
|
450
462
|
async def test_async_eth_sign_transaction_ens_names(
|
|
451
|
-
self, async_w3: "AsyncWeb3",
|
|
463
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
452
464
|
) -> None:
|
|
453
|
-
with ens_addresses(
|
|
465
|
+
with ens_addresses(
|
|
466
|
+
async_w3, {"unlocked-account.eth": async_keyfile_account_address}
|
|
467
|
+
):
|
|
454
468
|
txn_params: TxParams = {
|
|
455
469
|
"from": "unlocked-account.eth",
|
|
456
470
|
"to": "unlocked-account.eth",
|
|
@@ -462,8 +476,8 @@ class AsyncEthModuleTest:
|
|
|
462
476
|
}
|
|
463
477
|
result = await async_w3.eth.sign_transaction(txn_params)
|
|
464
478
|
signatory_account = async_w3.eth.account.recover_transaction(result["raw"])
|
|
465
|
-
assert
|
|
466
|
-
assert result["tx"]["to"] ==
|
|
479
|
+
assert async_keyfile_account_address == signatory_account
|
|
480
|
+
assert result["tx"]["to"] == async_keyfile_account_address
|
|
467
481
|
assert result["tx"]["value"] == txn_params["value"]
|
|
468
482
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
469
483
|
assert result["tx"]["maxFeePerGas"] == txn_params["maxFeePerGas"]
|
|
@@ -475,11 +489,13 @@ class AsyncEthModuleTest:
|
|
|
475
489
|
|
|
476
490
|
@pytest.mark.asyncio
|
|
477
491
|
async def test_eth_send_transaction(
|
|
478
|
-
self,
|
|
492
|
+
self,
|
|
493
|
+
async_w3: "AsyncWeb3",
|
|
494
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
479
495
|
) -> None:
|
|
480
496
|
txn_params: TxParams = {
|
|
481
|
-
"from":
|
|
482
|
-
"to":
|
|
497
|
+
"from": async_keyfile_account_address_dual_type,
|
|
498
|
+
"to": async_keyfile_account_address_dual_type,
|
|
483
499
|
"value": Wei(1),
|
|
484
500
|
"gas": 21000,
|
|
485
501
|
"maxFeePerGas": async_w3.to_wei(3, "gwei"),
|
|
@@ -498,11 +514,13 @@ class AsyncEthModuleTest:
|
|
|
498
514
|
|
|
499
515
|
@pytest.mark.asyncio
|
|
500
516
|
async def test_eth_send_transaction_default_fees(
|
|
501
|
-
self,
|
|
517
|
+
self,
|
|
518
|
+
async_w3: "AsyncWeb3",
|
|
519
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
502
520
|
) -> None:
|
|
503
521
|
txn_params: TxParams = {
|
|
504
|
-
"from":
|
|
505
|
-
"to":
|
|
522
|
+
"from": async_keyfile_account_address_dual_type,
|
|
523
|
+
"to": async_keyfile_account_address_dual_type,
|
|
506
524
|
"value": Wei(1),
|
|
507
525
|
"gas": 21000,
|
|
508
526
|
}
|
|
@@ -519,11 +537,13 @@ class AsyncEthModuleTest:
|
|
|
519
537
|
|
|
520
538
|
@pytest.mark.asyncio
|
|
521
539
|
async def test_eth_send_transaction_hex_fees(
|
|
522
|
-
self,
|
|
540
|
+
self,
|
|
541
|
+
async_w3: "AsyncWeb3",
|
|
542
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
523
543
|
) -> None:
|
|
524
544
|
txn_params: TxParams = {
|
|
525
|
-
"from":
|
|
526
|
-
"to":
|
|
545
|
+
"from": async_keyfile_account_address_dual_type,
|
|
546
|
+
"to": async_keyfile_account_address_dual_type,
|
|
527
547
|
"value": Wei(1),
|
|
528
548
|
"gas": 21000,
|
|
529
549
|
"maxFeePerGas": hex(250 * 10**9),
|
|
@@ -541,11 +561,13 @@ class AsyncEthModuleTest:
|
|
|
541
561
|
|
|
542
562
|
@pytest.mark.asyncio
|
|
543
563
|
async def test_eth_send_transaction_no_gas(
|
|
544
|
-
self,
|
|
564
|
+
self,
|
|
565
|
+
async_w3: "AsyncWeb3",
|
|
566
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
545
567
|
) -> None:
|
|
546
568
|
txn_params: TxParams = {
|
|
547
|
-
"from":
|
|
548
|
-
"to":
|
|
569
|
+
"from": async_keyfile_account_address_dual_type,
|
|
570
|
+
"to": async_keyfile_account_address_dual_type,
|
|
549
571
|
"value": Wei(1),
|
|
550
572
|
"maxFeePerGas": Wei(250 * 10**9),
|
|
551
573
|
"maxPriorityFeePerGas": Wei(2 * 10**9),
|
|
@@ -560,11 +582,13 @@ class AsyncEthModuleTest:
|
|
|
560
582
|
|
|
561
583
|
@pytest.mark.asyncio
|
|
562
584
|
async def test_eth_send_transaction_with_gas_price(
|
|
563
|
-
self,
|
|
585
|
+
self,
|
|
586
|
+
async_w3: "AsyncWeb3",
|
|
587
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
564
588
|
) -> None:
|
|
565
589
|
txn_params: TxParams = {
|
|
566
|
-
"from":
|
|
567
|
-
"to":
|
|
590
|
+
"from": async_keyfile_account_address_dual_type,
|
|
591
|
+
"to": async_keyfile_account_address_dual_type,
|
|
568
592
|
"value": Wei(1),
|
|
569
593
|
"gas": 21000,
|
|
570
594
|
"gasPrice": Wei(1),
|
|
@@ -576,11 +600,13 @@ class AsyncEthModuleTest:
|
|
|
576
600
|
|
|
577
601
|
@pytest.mark.asyncio
|
|
578
602
|
async def test_eth_send_transaction_no_priority_fee(
|
|
579
|
-
self,
|
|
603
|
+
self,
|
|
604
|
+
async_w3: "AsyncWeb3",
|
|
605
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
580
606
|
) -> None:
|
|
581
607
|
txn_params: TxParams = {
|
|
582
|
-
"from":
|
|
583
|
-
"to":
|
|
608
|
+
"from": async_keyfile_account_address_dual_type,
|
|
609
|
+
"to": async_keyfile_account_address_dual_type,
|
|
584
610
|
"value": Wei(1),
|
|
585
611
|
"gas": 21000,
|
|
586
612
|
"maxFeePerGas": Wei(250 * 10**9),
|
|
@@ -592,12 +618,14 @@ class AsyncEthModuleTest:
|
|
|
592
618
|
|
|
593
619
|
@pytest.mark.asyncio
|
|
594
620
|
async def test_eth_send_transaction_no_max_fee(
|
|
595
|
-
self,
|
|
621
|
+
self,
|
|
622
|
+
async_w3: "AsyncWeb3",
|
|
623
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
596
624
|
) -> None:
|
|
597
625
|
maxPriorityFeePerGas = async_w3.to_wei(2, "gwei")
|
|
598
626
|
txn_params: TxParams = {
|
|
599
|
-
"from":
|
|
600
|
-
"to":
|
|
627
|
+
"from": async_keyfile_account_address_dual_type,
|
|
628
|
+
"to": async_keyfile_account_address_dual_type,
|
|
601
629
|
"value": Wei(1),
|
|
602
630
|
"gas": 21000,
|
|
603
631
|
"maxPriorityFeePerGas": maxPriorityFeePerGas,
|
|
@@ -615,11 +643,13 @@ class AsyncEthModuleTest:
|
|
|
615
643
|
|
|
616
644
|
@pytest.mark.asyncio
|
|
617
645
|
async def test_eth_send_transaction_max_fee_less_than_tip(
|
|
618
|
-
self,
|
|
646
|
+
self,
|
|
647
|
+
async_w3: "AsyncWeb3",
|
|
648
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
619
649
|
) -> None:
|
|
620
650
|
txn_params: TxParams = {
|
|
621
|
-
"from":
|
|
622
|
-
"to":
|
|
651
|
+
"from": async_keyfile_account_address_dual_type,
|
|
652
|
+
"to": async_keyfile_account_address_dual_type,
|
|
623
653
|
"value": Wei(1),
|
|
624
654
|
"gas": 21000,
|
|
625
655
|
"maxFeePerGas": Wei(1 * 10**9),
|
|
@@ -632,14 +662,16 @@ class AsyncEthModuleTest:
|
|
|
632
662
|
|
|
633
663
|
@pytest.mark.asyncio
|
|
634
664
|
async def test_validation_middleware_chain_id_mismatch(
|
|
635
|
-
self,
|
|
665
|
+
self,
|
|
666
|
+
async_w3: "AsyncWeb3",
|
|
667
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
636
668
|
) -> None:
|
|
637
669
|
wrong_chain_id = 1234567890
|
|
638
670
|
actual_chain_id = await async_w3.eth.chain_id
|
|
639
671
|
|
|
640
672
|
txn_params: TxParams = {
|
|
641
|
-
"from":
|
|
642
|
-
"to":
|
|
673
|
+
"from": async_keyfile_account_address_dual_type,
|
|
674
|
+
"to": async_keyfile_account_address_dual_type,
|
|
643
675
|
"value": Wei(1),
|
|
644
676
|
"gas": 21000,
|
|
645
677
|
"maxFeePerGas": async_w3.to_wei(2, "gwei"),
|
|
@@ -673,29 +705,34 @@ class AsyncEthModuleTest:
|
|
|
673
705
|
async_w3.middleware_onion.remove("poa")
|
|
674
706
|
|
|
675
707
|
@pytest.mark.asyncio
|
|
676
|
-
async def
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
"
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
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.raw_transaction)
|
|
725
|
+
assert txn_hash == HexBytes(signed.hash)
|
|
691
726
|
|
|
692
727
|
@pytest.mark.asyncio
|
|
693
728
|
async def test_GasPriceStrategyMiddleware(
|
|
694
|
-
self,
|
|
729
|
+
self,
|
|
730
|
+
async_w3: "AsyncWeb3",
|
|
731
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
695
732
|
) -> None:
|
|
696
733
|
txn_params: TxParams = {
|
|
697
|
-
"from":
|
|
698
|
-
"to":
|
|
734
|
+
"from": async_keyfile_account_address_dual_type,
|
|
735
|
+
"to": async_keyfile_account_address_dual_type,
|
|
699
736
|
"value": Wei(1),
|
|
700
737
|
"gas": 21000,
|
|
701
738
|
}
|
|
@@ -714,11 +751,13 @@ class AsyncEthModuleTest:
|
|
|
714
751
|
|
|
715
752
|
@pytest.mark.asyncio
|
|
716
753
|
async def test_gas_price_strategy_middleware_hex_value(
|
|
717
|
-
self,
|
|
754
|
+
self,
|
|
755
|
+
async_w3: "AsyncWeb3",
|
|
756
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
718
757
|
) -> None:
|
|
719
758
|
txn_params: TxParams = {
|
|
720
|
-
"from":
|
|
721
|
-
"to":
|
|
759
|
+
"from": async_keyfile_account_address_dual_type,
|
|
760
|
+
"to": async_keyfile_account_address_dual_type,
|
|
722
761
|
"value": Wei(1),
|
|
723
762
|
"gas": 21000,
|
|
724
763
|
}
|
|
@@ -742,13 +781,13 @@ class AsyncEthModuleTest:
|
|
|
742
781
|
async def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn(
|
|
743
782
|
self,
|
|
744
783
|
async_w3: "AsyncWeb3",
|
|
745
|
-
|
|
784
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
746
785
|
max_fee: Wei,
|
|
747
786
|
) -> None:
|
|
748
787
|
max_priority_fee = async_w3.to_wei(1, "gwei")
|
|
749
788
|
txn_params: TxParams = {
|
|
750
|
-
"from":
|
|
751
|
-
"to":
|
|
789
|
+
"from": async_keyfile_account_address_dual_type,
|
|
790
|
+
"to": async_keyfile_account_address_dual_type,
|
|
752
791
|
"value": Wei(1),
|
|
753
792
|
"gas": 21000,
|
|
754
793
|
"maxPriorityFeePerGas": max_priority_fee,
|
|
@@ -779,11 +818,11 @@ class AsyncEthModuleTest:
|
|
|
779
818
|
async def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn_no_tip(
|
|
780
819
|
self,
|
|
781
820
|
async_w3: "AsyncWeb3",
|
|
782
|
-
|
|
821
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
783
822
|
) -> None:
|
|
784
823
|
txn_params: TxParams = {
|
|
785
|
-
"from":
|
|
786
|
-
"to":
|
|
824
|
+
"from": async_keyfile_account_address_dual_type,
|
|
825
|
+
"to": async_keyfile_account_address_dual_type,
|
|
787
826
|
"value": Wei(1),
|
|
788
827
|
"gas": 21000,
|
|
789
828
|
"maxFeePerGas": Wei(1000000000),
|
|
@@ -803,12 +842,14 @@ class AsyncEthModuleTest:
|
|
|
803
842
|
|
|
804
843
|
@pytest.mark.asyncio
|
|
805
844
|
async def test_eth_estimate_gas(
|
|
806
|
-
self,
|
|
845
|
+
self,
|
|
846
|
+
async_w3: "AsyncWeb3",
|
|
847
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
807
848
|
) -> None:
|
|
808
849
|
gas_estimate = await async_w3.eth.estimate_gas(
|
|
809
850
|
{
|
|
810
|
-
"from":
|
|
811
|
-
"to":
|
|
851
|
+
"from": async_keyfile_account_address_dual_type,
|
|
852
|
+
"to": async_keyfile_account_address_dual_type,
|
|
812
853
|
"value": Wei(1),
|
|
813
854
|
}
|
|
814
855
|
)
|
|
@@ -1043,14 +1084,14 @@ class AsyncEthModuleTest:
|
|
|
1043
1084
|
self,
|
|
1044
1085
|
async_w3: "AsyncWeb3",
|
|
1045
1086
|
async_block_with_txn: BlockData,
|
|
1046
|
-
|
|
1087
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1047
1088
|
) -> None:
|
|
1048
1089
|
# eth_getRawTransactionByBlockNumberAndIndex: block identifier
|
|
1049
1090
|
# send a txn to make sure pending block has at least one txn
|
|
1050
1091
|
await async_w3.eth.send_transaction(
|
|
1051
1092
|
{
|
|
1052
|
-
"from":
|
|
1053
|
-
"to":
|
|
1093
|
+
"from": async_keyfile_account_address_dual_type,
|
|
1094
|
+
"to": async_keyfile_account_address_dual_type,
|
|
1054
1095
|
"value": Wei(1),
|
|
1055
1096
|
}
|
|
1056
1097
|
)
|
|
@@ -1098,7 +1139,7 @@ class AsyncEthModuleTest:
|
|
|
1098
1139
|
) -> None:
|
|
1099
1140
|
unknown_identifier = "unknown"
|
|
1100
1141
|
with pytest.raises(
|
|
1101
|
-
|
|
1142
|
+
Web3ValueError,
|
|
1102
1143
|
match=(
|
|
1103
1144
|
"Value did not match any of the recognized block identifiers: "
|
|
1104
1145
|
f"{unknown_identifier}"
|
|
@@ -1152,12 +1193,12 @@ class AsyncEthModuleTest:
|
|
|
1152
1193
|
async def test_eth_create_access_list(
|
|
1153
1194
|
self,
|
|
1154
1195
|
async_w3: "AsyncWeb3",
|
|
1155
|
-
|
|
1196
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1156
1197
|
async_math_contract: "AsyncContract",
|
|
1157
1198
|
) -> None:
|
|
1158
1199
|
# build txn
|
|
1159
1200
|
txn = await async_math_contract.functions.incrementCounter(1).build_transaction(
|
|
1160
|
-
{"from":
|
|
1201
|
+
{"from": async_keyfile_account_address_dual_type}
|
|
1161
1202
|
)
|
|
1162
1203
|
|
|
1163
1204
|
# create access list
|
|
@@ -1180,10 +1221,12 @@ class AsyncEthModuleTest:
|
|
|
1180
1221
|
|
|
1181
1222
|
@pytest.mark.asyncio
|
|
1182
1223
|
async def test_eth_get_transaction_count(
|
|
1183
|
-
self,
|
|
1224
|
+
self,
|
|
1225
|
+
async_w3: "AsyncWeb3",
|
|
1226
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1184
1227
|
) -> None:
|
|
1185
1228
|
transaction_count = await async_w3.eth.get_transaction_count(
|
|
1186
|
-
|
|
1229
|
+
async_keyfile_account_address_dual_type
|
|
1187
1230
|
)
|
|
1188
1231
|
assert is_integer(transaction_count)
|
|
1189
1232
|
assert transaction_count >= 0
|
|
@@ -1294,12 +1337,12 @@ class AsyncEthModuleTest:
|
|
|
1294
1337
|
self,
|
|
1295
1338
|
async_w3: "AsyncWeb3",
|
|
1296
1339
|
async_revert_contract: "AsyncContract",
|
|
1297
|
-
|
|
1340
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1298
1341
|
) -> None:
|
|
1299
1342
|
txn_params = async_revert_contract._prepare_transaction(
|
|
1300
1343
|
fn_name="revertWithMessage",
|
|
1301
1344
|
transaction={
|
|
1302
|
-
"from":
|
|
1345
|
+
"from": async_keyfile_account_address,
|
|
1303
1346
|
"to": async_revert_contract.address,
|
|
1304
1347
|
},
|
|
1305
1348
|
)
|
|
@@ -1313,13 +1356,13 @@ class AsyncEthModuleTest:
|
|
|
1313
1356
|
self,
|
|
1314
1357
|
async_w3: "AsyncWeb3",
|
|
1315
1358
|
async_revert_contract: "AsyncContract",
|
|
1316
|
-
|
|
1359
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1317
1360
|
) -> None:
|
|
1318
1361
|
with pytest.raises(ContractLogicError, match="execution reverted"):
|
|
1319
1362
|
txn_params = async_revert_contract._prepare_transaction(
|
|
1320
1363
|
fn_name="revertWithoutMessage",
|
|
1321
1364
|
transaction={
|
|
1322
|
-
"from":
|
|
1365
|
+
"from": async_keyfile_account_address,
|
|
1323
1366
|
"to": async_revert_contract.address,
|
|
1324
1367
|
},
|
|
1325
1368
|
)
|
|
@@ -1330,7 +1373,7 @@ class AsyncEthModuleTest:
|
|
|
1330
1373
|
self,
|
|
1331
1374
|
async_w3: "AsyncWeb3",
|
|
1332
1375
|
async_revert_contract: "AsyncContract",
|
|
1333
|
-
|
|
1376
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1334
1377
|
) -> None:
|
|
1335
1378
|
data = async_revert_contract.encode_abi(
|
|
1336
1379
|
fn_name="UnauthorizedWithMessage", args=["You are not authorized"]
|
|
@@ -1338,7 +1381,7 @@ class AsyncEthModuleTest:
|
|
|
1338
1381
|
txn_params = async_revert_contract._prepare_transaction(
|
|
1339
1382
|
fn_name="customErrorWithMessage",
|
|
1340
1383
|
transaction={
|
|
1341
|
-
"from":
|
|
1384
|
+
"from": async_keyfile_account_address,
|
|
1342
1385
|
"to": async_revert_contract.address,
|
|
1343
1386
|
},
|
|
1344
1387
|
)
|
|
@@ -1350,13 +1393,13 @@ class AsyncEthModuleTest:
|
|
|
1350
1393
|
self,
|
|
1351
1394
|
async_w3: "AsyncWeb3",
|
|
1352
1395
|
async_revert_contract: "AsyncContract",
|
|
1353
|
-
|
|
1396
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1354
1397
|
) -> None:
|
|
1355
1398
|
data = async_revert_contract.encode_abi(fn_name="Unauthorized")
|
|
1356
1399
|
txn_params = async_revert_contract._prepare_transaction(
|
|
1357
1400
|
fn_name="customErrorWithoutMessage",
|
|
1358
1401
|
transaction={
|
|
1359
|
-
"from":
|
|
1402
|
+
"from": async_keyfile_account_address,
|
|
1360
1403
|
"to": async_revert_contract.address,
|
|
1361
1404
|
},
|
|
1362
1405
|
)
|
|
@@ -1399,7 +1442,7 @@ class AsyncEthModuleTest:
|
|
|
1399
1442
|
self,
|
|
1400
1443
|
async_w3: "AsyncWeb3",
|
|
1401
1444
|
async_offchain_lookup_contract: "AsyncContract",
|
|
1402
|
-
|
|
1445
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1403
1446
|
monkeypatch: "MonkeyPatch",
|
|
1404
1447
|
) -> None:
|
|
1405
1448
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -1463,7 +1506,7 @@ class AsyncEthModuleTest:
|
|
|
1463
1506
|
self,
|
|
1464
1507
|
async_w3: "AsyncWeb3",
|
|
1465
1508
|
async_offchain_lookup_contract: "AsyncContract",
|
|
1466
|
-
|
|
1509
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1467
1510
|
monkeypatch: "MonkeyPatch",
|
|
1468
1511
|
) -> None:
|
|
1469
1512
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -1496,7 +1539,7 @@ class AsyncEthModuleTest:
|
|
|
1496
1539
|
default_max_redirects = async_w3.provider.ccip_read_max_redirects
|
|
1497
1540
|
|
|
1498
1541
|
async_w3.provider.ccip_read_max_redirects = max_redirects
|
|
1499
|
-
with pytest.raises(
|
|
1542
|
+
with pytest.raises(Web3ValueError, match="at least 4"):
|
|
1500
1543
|
await async_offchain_lookup_contract.caller().testOffchainLookup(
|
|
1501
1544
|
OFFCHAIN_LOOKUP_TEST_DATA
|
|
1502
1545
|
)
|
|
@@ -1508,7 +1551,7 @@ class AsyncEthModuleTest:
|
|
|
1508
1551
|
self,
|
|
1509
1552
|
async_w3: "AsyncWeb3",
|
|
1510
1553
|
async_offchain_lookup_contract: "AsyncContract",
|
|
1511
|
-
|
|
1554
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1512
1555
|
monkeypatch: "MonkeyPatch",
|
|
1513
1556
|
) -> None:
|
|
1514
1557
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -1532,7 +1575,7 @@ class AsyncEthModuleTest:
|
|
|
1532
1575
|
self,
|
|
1533
1576
|
async_w3: "AsyncWeb3",
|
|
1534
1577
|
async_offchain_lookup_contract: "AsyncContract",
|
|
1535
|
-
|
|
1578
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1536
1579
|
monkeypatch: "MonkeyPatch",
|
|
1537
1580
|
status_code_non_4xx_error: int,
|
|
1538
1581
|
) -> None:
|
|
@@ -1570,7 +1613,7 @@ class AsyncEthModuleTest:
|
|
|
1570
1613
|
self,
|
|
1571
1614
|
async_w3: "AsyncWeb3",
|
|
1572
1615
|
async_offchain_lookup_contract: "AsyncContract",
|
|
1573
|
-
|
|
1616
|
+
async_keyfile_account_address: ChecksumAddress,
|
|
1574
1617
|
monkeypatch: "MonkeyPatch",
|
|
1575
1618
|
) -> None:
|
|
1576
1619
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -1591,7 +1634,6 @@ class AsyncEthModuleTest:
|
|
|
1591
1634
|
@pytest.mark.asyncio
|
|
1592
1635
|
async def test_eth_call_offchain_lookup_raises_when_all_supplied_urls_fail(
|
|
1593
1636
|
self,
|
|
1594
|
-
async_w3: "AsyncWeb3",
|
|
1595
1637
|
async_offchain_lookup_contract: "AsyncContract",
|
|
1596
1638
|
) -> None:
|
|
1597
1639
|
# GET and POST requests should fail since responses are not mocked
|
|
@@ -1605,9 +1647,7 @@ class AsyncEthModuleTest:
|
|
|
1605
1647
|
@pytest.mark.asyncio
|
|
1606
1648
|
async def test_eth_call_continuous_offchain_lookup_raises_with_too_many_requests(
|
|
1607
1649
|
self,
|
|
1608
|
-
async_w3: "AsyncWeb3",
|
|
1609
1650
|
async_offchain_lookup_contract: "AsyncContract",
|
|
1610
|
-
async_unlocked_account: ChecksumAddress,
|
|
1611
1651
|
monkeypatch: "MonkeyPatch",
|
|
1612
1652
|
) -> None:
|
|
1613
1653
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -1661,12 +1701,14 @@ class AsyncEthModuleTest:
|
|
|
1661
1701
|
|
|
1662
1702
|
@pytest.mark.asyncio
|
|
1663
1703
|
async def test_async_eth_get_transaction_receipt_unmined(
|
|
1664
|
-
self,
|
|
1704
|
+
self,
|
|
1705
|
+
async_w3: "AsyncWeb3",
|
|
1706
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1665
1707
|
) -> None:
|
|
1666
1708
|
txn_hash = await async_w3.eth.send_transaction(
|
|
1667
1709
|
{
|
|
1668
|
-
"from":
|
|
1669
|
-
"to":
|
|
1710
|
+
"from": async_keyfile_account_address_dual_type,
|
|
1711
|
+
"to": async_keyfile_account_address_dual_type,
|
|
1670
1712
|
"value": Wei(1),
|
|
1671
1713
|
"gas": 21000,
|
|
1672
1714
|
"maxFeePerGas": async_w3.to_wei(3, "gwei"),
|
|
@@ -1724,12 +1766,14 @@ class AsyncEthModuleTest:
|
|
|
1724
1766
|
|
|
1725
1767
|
@pytest.mark.asyncio
|
|
1726
1768
|
async def test_async_eth_wait_for_transaction_receipt_unmined(
|
|
1727
|
-
self,
|
|
1769
|
+
self,
|
|
1770
|
+
async_w3: "AsyncWeb3",
|
|
1771
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1728
1772
|
) -> None:
|
|
1729
1773
|
txn_hash = await async_w3.eth.send_transaction(
|
|
1730
1774
|
{
|
|
1731
|
-
"from":
|
|
1732
|
-
"to":
|
|
1775
|
+
"from": async_keyfile_account_address_dual_type,
|
|
1776
|
+
"to": async_keyfile_account_address_dual_type,
|
|
1733
1777
|
"value": Wei(1),
|
|
1734
1778
|
"gas": 21000,
|
|
1735
1779
|
"maxFeePerGas": async_w3.to_wei(3, "gwei"),
|
|
@@ -1794,7 +1838,7 @@ class AsyncEthModuleTest:
|
|
|
1794
1838
|
"fromBlock": async_block_with_txn_with_log["number"],
|
|
1795
1839
|
"toBlock": BlockNumber(async_block_with_txn_with_log["number"] - 1),
|
|
1796
1840
|
}
|
|
1797
|
-
with pytest.raises(
|
|
1841
|
+
with pytest.raises(Web3RPCError):
|
|
1798
1842
|
result = await async_w3.eth.get_logs(filter_params)
|
|
1799
1843
|
|
|
1800
1844
|
# Test with `address`
|
|
@@ -1991,16 +2035,18 @@ class AsyncEthModuleTest:
|
|
|
1991
2035
|
)
|
|
1992
2036
|
|
|
1993
2037
|
def test_async_provider_default_account(
|
|
1994
|
-
self,
|
|
2038
|
+
self,
|
|
2039
|
+
async_w3: "AsyncWeb3",
|
|
2040
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
1995
2041
|
) -> None:
|
|
1996
2042
|
# check defaults to empty
|
|
1997
2043
|
default_account = async_w3.eth.default_account
|
|
1998
2044
|
assert default_account is empty
|
|
1999
2045
|
|
|
2000
2046
|
# check setter
|
|
2001
|
-
async_w3.eth.default_account =
|
|
2047
|
+
async_w3.eth.default_account = async_keyfile_account_address_dual_type
|
|
2002
2048
|
default_account = async_w3.eth.default_account
|
|
2003
|
-
assert default_account ==
|
|
2049
|
+
assert default_account == async_keyfile_account_address_dual_type
|
|
2004
2050
|
|
|
2005
2051
|
# reset to default
|
|
2006
2052
|
async_w3.eth.default_account = empty
|
|
@@ -2085,17 +2131,20 @@ class AsyncEthModuleTest:
|
|
|
2085
2131
|
|
|
2086
2132
|
@pytest.mark.asyncio
|
|
2087
2133
|
async def test_async_eth_sign(
|
|
2088
|
-
self,
|
|
2134
|
+
self,
|
|
2135
|
+
async_w3: "AsyncWeb3",
|
|
2136
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2089
2137
|
) -> None:
|
|
2090
2138
|
signature = await async_w3.eth.sign(
|
|
2091
|
-
|
|
2139
|
+
async_keyfile_account_address_dual_type,
|
|
2140
|
+
text="Message tö sign. Longer than hash!",
|
|
2092
2141
|
)
|
|
2093
2142
|
assert is_bytes(signature)
|
|
2094
2143
|
assert len(signature) == 32 + 32 + 1
|
|
2095
2144
|
|
|
2096
2145
|
# test other formats
|
|
2097
2146
|
hexsign = await async_w3.eth.sign(
|
|
2098
|
-
|
|
2147
|
+
async_keyfile_account_address_dual_type,
|
|
2099
2148
|
hexstr=HexStr(
|
|
2100
2149
|
"0x4d6573736167652074c3b6207369676e2e204c6f6e676572207468616e206861736821" # noqa: E501
|
|
2101
2150
|
),
|
|
@@ -2103,19 +2152,20 @@ class AsyncEthModuleTest:
|
|
|
2103
2152
|
assert hexsign == signature
|
|
2104
2153
|
|
|
2105
2154
|
intsign = await async_w3.eth.sign(
|
|
2106
|
-
|
|
2155
|
+
async_keyfile_account_address_dual_type,
|
|
2107
2156
|
0x4D6573736167652074C3B6207369676E2E204C6F6E676572207468616E206861736821,
|
|
2108
2157
|
)
|
|
2109
2158
|
assert intsign == signature
|
|
2110
2159
|
|
|
2111
2160
|
bytessign = await async_w3.eth.sign(
|
|
2112
|
-
|
|
2161
|
+
async_keyfile_account_address_dual_type,
|
|
2113
2162
|
b"Message t\xc3\xb6 sign. Longer than hash!",
|
|
2114
2163
|
)
|
|
2115
2164
|
assert bytessign == signature
|
|
2116
2165
|
|
|
2117
2166
|
new_signature = await async_w3.eth.sign(
|
|
2118
|
-
|
|
2167
|
+
async_keyfile_account_address_dual_type,
|
|
2168
|
+
text="different message is different",
|
|
2119
2169
|
)
|
|
2120
2170
|
assert new_signature != signature
|
|
2121
2171
|
|
|
@@ -2124,10 +2174,12 @@ class AsyncEthModuleTest:
|
|
|
2124
2174
|
reason="Async middleware to convert ENS names to addresses is missing"
|
|
2125
2175
|
)
|
|
2126
2176
|
async def test_async_eth_sign_ens_names(
|
|
2127
|
-
self,
|
|
2177
|
+
self,
|
|
2178
|
+
async_w3: "AsyncWeb3",
|
|
2179
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2128
2180
|
) -> None:
|
|
2129
2181
|
with ens_addresses(
|
|
2130
|
-
async_w3, {"unlocked-acct.eth":
|
|
2182
|
+
async_w3, {"unlocked-acct.eth": async_keyfile_account_address_dual_type}
|
|
2131
2183
|
):
|
|
2132
2184
|
signature = await async_w3.eth.sign(
|
|
2133
2185
|
ENS("unlocked-acct.eth"), text="Message tö sign. Longer than hash!"
|
|
@@ -2138,11 +2190,13 @@ class AsyncEthModuleTest:
|
|
|
2138
2190
|
@flaky_geth_dev_mining
|
|
2139
2191
|
@pytest.mark.asyncio
|
|
2140
2192
|
async def test_async_eth_replace_transaction_legacy(
|
|
2141
|
-
self,
|
|
2193
|
+
self,
|
|
2194
|
+
async_w3: "AsyncWeb3",
|
|
2195
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2142
2196
|
) -> None:
|
|
2143
2197
|
txn_params: TxParams = {
|
|
2144
|
-
"from":
|
|
2145
|
-
"to":
|
|
2198
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2199
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2146
2200
|
"value": Wei(1),
|
|
2147
2201
|
"gas": 21000,
|
|
2148
2202
|
"gasPrice": async_w3.to_wei(1, "gwei"),
|
|
@@ -2166,14 +2220,16 @@ class AsyncEthModuleTest:
|
|
|
2166
2220
|
@flaky_geth_dev_mining
|
|
2167
2221
|
@pytest.mark.asyncio
|
|
2168
2222
|
async def test_async_eth_replace_transaction(
|
|
2169
|
-
self,
|
|
2223
|
+
self,
|
|
2224
|
+
async_w3: "AsyncWeb3",
|
|
2225
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2170
2226
|
) -> None:
|
|
2171
2227
|
two_gwei_in_wei = async_w3.to_wei(2, "gwei")
|
|
2172
2228
|
three_gwei_in_wei = async_w3.to_wei(3, "gwei")
|
|
2173
2229
|
|
|
2174
2230
|
txn_params: TxParams = {
|
|
2175
|
-
"from":
|
|
2176
|
-
"to":
|
|
2231
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2232
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2177
2233
|
"value": Wei(1),
|
|
2178
2234
|
"gas": 21000,
|
|
2179
2235
|
"maxFeePerGas": two_gwei_in_wei,
|
|
@@ -2201,11 +2257,13 @@ class AsyncEthModuleTest:
|
|
|
2201
2257
|
@flaky_geth_dev_mining
|
|
2202
2258
|
@pytest.mark.asyncio
|
|
2203
2259
|
async def test_async_eth_replace_transaction_underpriced(
|
|
2204
|
-
self,
|
|
2260
|
+
self,
|
|
2261
|
+
async_w3: "AsyncWeb3",
|
|
2262
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2205
2263
|
) -> None:
|
|
2206
2264
|
txn_params: TxParams = {
|
|
2207
|
-
"from":
|
|
2208
|
-
"to":
|
|
2265
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2266
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2209
2267
|
"value": Wei(1),
|
|
2210
2268
|
"gas": 21000,
|
|
2211
2269
|
"maxFeePerGas": async_w3.to_wei(3, "gwei"),
|
|
@@ -2217,17 +2275,19 @@ class AsyncEthModuleTest:
|
|
|
2217
2275
|
txn_params["maxFeePerGas"] = one_gwei_in_wei
|
|
2218
2276
|
txn_params["maxPriorityFeePerGas"] = one_gwei_in_wei
|
|
2219
2277
|
|
|
2220
|
-
with pytest.raises(
|
|
2278
|
+
with pytest.raises(Web3RPCError, match="replacement transaction underpriced"):
|
|
2221
2279
|
await async_w3.eth.replace_transaction(txn_hash, txn_params)
|
|
2222
2280
|
|
|
2223
2281
|
@flaky_geth_dev_mining
|
|
2224
2282
|
@pytest.mark.asyncio
|
|
2225
2283
|
async def test_async_eth_replace_transaction_non_existing_transaction(
|
|
2226
|
-
self,
|
|
2284
|
+
self,
|
|
2285
|
+
async_w3: "AsyncWeb3",
|
|
2286
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2227
2287
|
) -> None:
|
|
2228
2288
|
txn_params: TxParams = {
|
|
2229
|
-
"from":
|
|
2230
|
-
"to":
|
|
2289
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2290
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2231
2291
|
"value": Wei(1),
|
|
2232
2292
|
"gas": 21000,
|
|
2233
2293
|
"maxFeePerGas": async_w3.to_wei(3, "gwei"),
|
|
@@ -2244,11 +2304,13 @@ class AsyncEthModuleTest:
|
|
|
2244
2304
|
@flaky_geth_dev_mining
|
|
2245
2305
|
@pytest.mark.asyncio
|
|
2246
2306
|
async def test_async_eth_replace_transaction_already_mined(
|
|
2247
|
-
self,
|
|
2307
|
+
self,
|
|
2308
|
+
async_w3: "AsyncWeb3",
|
|
2309
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2248
2310
|
) -> None:
|
|
2249
2311
|
txn_params: TxParams = {
|
|
2250
|
-
"from":
|
|
2251
|
-
"to":
|
|
2312
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2313
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2252
2314
|
"value": Wei(1),
|
|
2253
2315
|
"gas": 21000,
|
|
2254
2316
|
"maxFeePerGas": async_w3.to_wei(2, "gwei"),
|
|
@@ -2259,17 +2321,17 @@ class AsyncEthModuleTest:
|
|
|
2259
2321
|
|
|
2260
2322
|
txn_params["maxFeePerGas"] = async_w3.to_wei(3, "gwei")
|
|
2261
2323
|
txn_params["maxPriorityFeePerGas"] = async_w3.to_wei(2, "gwei")
|
|
2262
|
-
with pytest.raises(
|
|
2324
|
+
with pytest.raises(Web3ValueError, match="Supplied transaction with hash"):
|
|
2263
2325
|
await async_w3.eth.replace_transaction(txn_hash, txn_params)
|
|
2264
2326
|
|
|
2265
2327
|
@flaky_geth_dev_mining
|
|
2266
2328
|
@pytest.mark.asyncio
|
|
2267
2329
|
async def test_async_eth_replace_transaction_incorrect_nonce(
|
|
2268
|
-
self, async_w3: "AsyncWeb3",
|
|
2330
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
2269
2331
|
) -> None:
|
|
2270
2332
|
txn_params: TxParams = {
|
|
2271
|
-
"from":
|
|
2272
|
-
"to":
|
|
2333
|
+
"from": async_keyfile_account_address,
|
|
2334
|
+
"to": async_keyfile_account_address,
|
|
2273
2335
|
"value": Wei(1),
|
|
2274
2336
|
"gas": 21000,
|
|
2275
2337
|
"maxFeePerGas": async_w3.to_wei(2, "gwei"),
|
|
@@ -2281,17 +2343,19 @@ class AsyncEthModuleTest:
|
|
|
2281
2343
|
txn_params["maxFeePerGas"] = async_w3.to_wei(3, "gwei")
|
|
2282
2344
|
txn_params["maxPriorityFeePerGas"] = async_w3.to_wei(2, "gwei")
|
|
2283
2345
|
txn_params["nonce"] = Nonce(txn["nonce"] + 1)
|
|
2284
|
-
with pytest.raises(
|
|
2346
|
+
with pytest.raises(Web3ValueError):
|
|
2285
2347
|
await async_w3.eth.replace_transaction(txn_hash, txn_params)
|
|
2286
2348
|
|
|
2287
2349
|
@flaky_geth_dev_mining
|
|
2288
2350
|
@pytest.mark.asyncio
|
|
2289
2351
|
async def test_async_eth_replace_transaction_gas_price_too_low(
|
|
2290
|
-
self,
|
|
2352
|
+
self,
|
|
2353
|
+
async_w3: "AsyncWeb3",
|
|
2354
|
+
async_keyfile_account_address_dual_type: ChecksumAddress,
|
|
2291
2355
|
) -> None:
|
|
2292
2356
|
txn_params: TxParams = {
|
|
2293
|
-
"from":
|
|
2294
|
-
"to":
|
|
2357
|
+
"from": async_keyfile_account_address_dual_type,
|
|
2358
|
+
"to": async_keyfile_account_address_dual_type,
|
|
2295
2359
|
"value": Wei(1),
|
|
2296
2360
|
"gas": 21000,
|
|
2297
2361
|
"gasPrice": async_w3.to_wei(2, "gwei"),
|
|
@@ -2299,19 +2363,19 @@ class AsyncEthModuleTest:
|
|
|
2299
2363
|
txn_hash = await async_w3.eth.send_transaction(txn_params)
|
|
2300
2364
|
|
|
2301
2365
|
txn_params["gasPrice"] = async_w3.to_wei(1, "gwei")
|
|
2302
|
-
with pytest.raises(
|
|
2366
|
+
with pytest.raises(Web3ValueError):
|
|
2303
2367
|
await async_w3.eth.replace_transaction(txn_hash, txn_params)
|
|
2304
2368
|
|
|
2305
2369
|
@flaky_geth_dev_mining
|
|
2306
2370
|
@pytest.mark.asyncio
|
|
2307
2371
|
async def test_async_eth_replace_transaction_gas_price_defaulting_minimum(
|
|
2308
|
-
self, async_w3: "AsyncWeb3",
|
|
2372
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
2309
2373
|
) -> None:
|
|
2310
2374
|
gas_price = async_w3.to_wei(1, "gwei")
|
|
2311
2375
|
|
|
2312
2376
|
txn_params: TxParams = {
|
|
2313
|
-
"from":
|
|
2314
|
-
"to":
|
|
2377
|
+
"from": async_keyfile_account_address,
|
|
2378
|
+
"to": async_keyfile_account_address,
|
|
2315
2379
|
"value": Wei(1),
|
|
2316
2380
|
"gas": 21000,
|
|
2317
2381
|
"gasPrice": gas_price,
|
|
@@ -2329,11 +2393,11 @@ class AsyncEthModuleTest:
|
|
|
2329
2393
|
@flaky_geth_dev_mining
|
|
2330
2394
|
@pytest.mark.asyncio
|
|
2331
2395
|
async def test_async_eth_replace_transaction_gas_price_defaulting_strategy_higher(
|
|
2332
|
-
self, async_w3: "AsyncWeb3",
|
|
2396
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
2333
2397
|
) -> None:
|
|
2334
2398
|
txn_params: TxParams = {
|
|
2335
|
-
"from":
|
|
2336
|
-
"to":
|
|
2399
|
+
"from": async_keyfile_account_address,
|
|
2400
|
+
"to": async_keyfile_account_address,
|
|
2337
2401
|
"value": Wei(1),
|
|
2338
2402
|
"gas": 21000,
|
|
2339
2403
|
"gasPrice": async_w3.to_wei(1, "gwei"),
|
|
@@ -2358,13 +2422,13 @@ class AsyncEthModuleTest:
|
|
|
2358
2422
|
@flaky_geth_dev_mining
|
|
2359
2423
|
@pytest.mark.asyncio
|
|
2360
2424
|
async def test_async_eth_replace_transaction_gas_price_defaulting_strategy_lower(
|
|
2361
|
-
self, async_w3: "AsyncWeb3",
|
|
2425
|
+
self, async_w3: "AsyncWeb3", async_keyfile_account_address: ChecksumAddress
|
|
2362
2426
|
) -> None:
|
|
2363
2427
|
gas_price = async_w3.to_wei(2, "gwei")
|
|
2364
2428
|
|
|
2365
2429
|
txn_params: TxParams = {
|
|
2366
|
-
"from":
|
|
2367
|
-
"to":
|
|
2430
|
+
"from": async_keyfile_account_address,
|
|
2431
|
+
"to": async_keyfile_account_address,
|
|
2368
2432
|
"value": Wei(1),
|
|
2369
2433
|
"gas": 21000,
|
|
2370
2434
|
"gasPrice": gas_price,
|
|
@@ -2620,17 +2684,19 @@ class EthModuleTest:
|
|
|
2620
2684
|
)
|
|
2621
2685
|
|
|
2622
2686
|
def test_eth_get_transaction_count(
|
|
2623
|
-
self, w3: "Web3",
|
|
2687
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
2624
2688
|
) -> None:
|
|
2625
|
-
transaction_count = w3.eth.get_transaction_count(
|
|
2689
|
+
transaction_count = w3.eth.get_transaction_count(
|
|
2690
|
+
keyfile_account_address_dual_type
|
|
2691
|
+
)
|
|
2626
2692
|
assert is_integer(transaction_count)
|
|
2627
2693
|
assert transaction_count >= 0
|
|
2628
2694
|
|
|
2629
2695
|
def test_eth_get_transaction_count_ens_name(
|
|
2630
|
-
self, w3: "Web3",
|
|
2696
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
2631
2697
|
) -> None:
|
|
2632
2698
|
with ens_addresses(
|
|
2633
|
-
w3, {"unlocked-acct-dual-type.eth":
|
|
2699
|
+
w3, {"unlocked-acct-dual-type.eth": keyfile_account_address_dual_type}
|
|
2634
2700
|
):
|
|
2635
2701
|
transaction_count = w3.eth.get_transaction_count(
|
|
2636
2702
|
ENS("unlocked-acct-dual-type.eth")
|
|
@@ -2728,12 +2794,12 @@ class EthModuleTest:
|
|
|
2728
2794
|
def test_eth_create_access_list(
|
|
2729
2795
|
self,
|
|
2730
2796
|
w3: "Web3",
|
|
2731
|
-
|
|
2797
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
2732
2798
|
math_contract: "Contract",
|
|
2733
2799
|
) -> None:
|
|
2734
2800
|
# build txn
|
|
2735
2801
|
txn = math_contract.functions.incrementCounter(1).build_transaction(
|
|
2736
|
-
{"from":
|
|
2802
|
+
{"from": keyfile_account_address_dual_type}
|
|
2737
2803
|
)
|
|
2738
2804
|
|
|
2739
2805
|
# create access list
|
|
@@ -2755,17 +2821,17 @@ class EthModuleTest:
|
|
|
2755
2821
|
w3.eth.send_transaction(txn)
|
|
2756
2822
|
|
|
2757
2823
|
def test_eth_sign(
|
|
2758
|
-
self, w3: "Web3",
|
|
2824
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
2759
2825
|
) -> None:
|
|
2760
2826
|
signature = w3.eth.sign(
|
|
2761
|
-
|
|
2827
|
+
keyfile_account_address_dual_type, text="Message tö sign. Longer than hash!"
|
|
2762
2828
|
)
|
|
2763
2829
|
assert is_bytes(signature)
|
|
2764
2830
|
assert len(signature) == 32 + 32 + 1
|
|
2765
2831
|
|
|
2766
2832
|
# test other formats
|
|
2767
2833
|
hexsign = w3.eth.sign(
|
|
2768
|
-
|
|
2834
|
+
keyfile_account_address_dual_type,
|
|
2769
2835
|
hexstr=HexStr(
|
|
2770
2836
|
"0x4d6573736167652074c3b6207369676e2e204c6f6e676572207468616e206861736821" # noqa: E501
|
|
2771
2837
|
),
|
|
@@ -2773,25 +2839,28 @@ class EthModuleTest:
|
|
|
2773
2839
|
assert hexsign == signature
|
|
2774
2840
|
|
|
2775
2841
|
intsign = w3.eth.sign(
|
|
2776
|
-
|
|
2842
|
+
keyfile_account_address_dual_type,
|
|
2777
2843
|
0x4D6573736167652074C3B6207369676E2E204C6F6E676572207468616E206861736821,
|
|
2778
2844
|
)
|
|
2779
2845
|
assert intsign == signature
|
|
2780
2846
|
|
|
2781
2847
|
bytessign = w3.eth.sign(
|
|
2782
|
-
|
|
2848
|
+
keyfile_account_address_dual_type,
|
|
2849
|
+
b"Message t\xc3\xb6 sign. Longer than hash!",
|
|
2783
2850
|
)
|
|
2784
2851
|
assert bytessign == signature
|
|
2785
2852
|
|
|
2786
2853
|
new_signature = w3.eth.sign(
|
|
2787
|
-
|
|
2854
|
+
keyfile_account_address_dual_type, text="different message is different"
|
|
2788
2855
|
)
|
|
2789
2856
|
assert new_signature != signature
|
|
2790
2857
|
|
|
2791
2858
|
def test_eth_sign_ens_names(
|
|
2792
|
-
self, w3: "Web3",
|
|
2859
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
2793
2860
|
) -> None:
|
|
2794
|
-
with ens_addresses(
|
|
2861
|
+
with ens_addresses(
|
|
2862
|
+
w3, {"unlocked-acct.eth": keyfile_account_address_dual_type}
|
|
2863
|
+
):
|
|
2795
2864
|
signature = w3.eth.sign(
|
|
2796
2865
|
"unlocked-acct.eth", text="Message tö sign. Longer than hash!"
|
|
2797
2866
|
)
|
|
@@ -2801,7 +2870,7 @@ class EthModuleTest:
|
|
|
2801
2870
|
def test_eth_sign_typed_data(
|
|
2802
2871
|
self,
|
|
2803
2872
|
w3: "Web3",
|
|
2804
|
-
|
|
2873
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
2805
2874
|
skip_if_testrpc: Callable[["Web3"], None],
|
|
2806
2875
|
) -> None:
|
|
2807
2876
|
validJSONMessage = """
|
|
@@ -2846,7 +2915,7 @@ class EthModuleTest:
|
|
|
2846
2915
|
skip_if_testrpc(w3)
|
|
2847
2916
|
signature = HexBytes(
|
|
2848
2917
|
w3.eth.sign_typed_data(
|
|
2849
|
-
|
|
2918
|
+
keyfile_account_address_dual_type, json.loads(validJSONMessage)
|
|
2850
2919
|
)
|
|
2851
2920
|
)
|
|
2852
2921
|
assert len(signature) == 32 + 32 + 1
|
|
@@ -2854,7 +2923,7 @@ class EthModuleTest:
|
|
|
2854
2923
|
def test_invalid_eth_sign_typed_data(
|
|
2855
2924
|
self,
|
|
2856
2925
|
w3: "Web3",
|
|
2857
|
-
|
|
2926
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
2858
2927
|
skip_if_testrpc: Callable[["Web3"], None],
|
|
2859
2928
|
) -> None:
|
|
2860
2929
|
skip_if_testrpc(w3)
|
|
@@ -2898,19 +2967,19 @@ class EthModuleTest:
|
|
|
2898
2967
|
}
|
|
2899
2968
|
"""
|
|
2900
2969
|
with pytest.raises(
|
|
2901
|
-
|
|
2970
|
+
Web3ValueError,
|
|
2902
2971
|
match=r".*Expected 2 items for array type Person\[2\], got 1 items.*",
|
|
2903
2972
|
):
|
|
2904
2973
|
w3.eth.sign_typed_data(
|
|
2905
|
-
|
|
2974
|
+
keyfile_account_address_dual_type, json.loads(invalid_typed_message)
|
|
2906
2975
|
)
|
|
2907
2976
|
|
|
2908
2977
|
def test_eth_sign_transaction_legacy(
|
|
2909
|
-
self, w3: "Web3",
|
|
2978
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
2910
2979
|
) -> None:
|
|
2911
2980
|
txn_params: TxParams = {
|
|
2912
|
-
"from":
|
|
2913
|
-
"to":
|
|
2981
|
+
"from": keyfile_account_address,
|
|
2982
|
+
"to": keyfile_account_address,
|
|
2914
2983
|
"value": Wei(1),
|
|
2915
2984
|
"gas": 21000,
|
|
2916
2985
|
"gasPrice": w3.eth.gas_price,
|
|
@@ -2918,7 +2987,7 @@ class EthModuleTest:
|
|
|
2918
2987
|
}
|
|
2919
2988
|
result = w3.eth.sign_transaction(txn_params)
|
|
2920
2989
|
signatory_account = w3.eth.account.recover_transaction(result["raw"])
|
|
2921
|
-
assert
|
|
2990
|
+
assert keyfile_account_address == signatory_account
|
|
2922
2991
|
assert result["tx"]["to"] == txn_params["to"]
|
|
2923
2992
|
assert result["tx"]["value"] == txn_params["value"]
|
|
2924
2993
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -2926,11 +2995,11 @@ class EthModuleTest:
|
|
|
2926
2995
|
assert result["tx"]["nonce"] == txn_params["nonce"]
|
|
2927
2996
|
|
|
2928
2997
|
def test_eth_sign_transaction(
|
|
2929
|
-
self, w3: "Web3",
|
|
2998
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
2930
2999
|
) -> None:
|
|
2931
3000
|
txn_params: TxParams = {
|
|
2932
|
-
"from":
|
|
2933
|
-
"to":
|
|
3001
|
+
"from": keyfile_account_address,
|
|
3002
|
+
"to": keyfile_account_address,
|
|
2934
3003
|
"value": Wei(1),
|
|
2935
3004
|
"gas": 21000,
|
|
2936
3005
|
"maxFeePerGas": w3.to_wei(2, "gwei"),
|
|
@@ -2939,7 +3008,7 @@ class EthModuleTest:
|
|
|
2939
3008
|
}
|
|
2940
3009
|
result = w3.eth.sign_transaction(txn_params)
|
|
2941
3010
|
signatory_account = w3.eth.account.recover_transaction(result["raw"])
|
|
2942
|
-
assert
|
|
3011
|
+
assert keyfile_account_address == signatory_account
|
|
2943
3012
|
assert result["tx"]["to"] == txn_params["to"]
|
|
2944
3013
|
assert result["tx"]["value"] == txn_params["value"]
|
|
2945
3014
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -2950,11 +3019,11 @@ class EthModuleTest:
|
|
|
2950
3019
|
assert result["tx"]["nonce"] == txn_params["nonce"]
|
|
2951
3020
|
|
|
2952
3021
|
def test_eth_sign_transaction_hex_fees(
|
|
2953
|
-
self, w3: "Web3",
|
|
3022
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
2954
3023
|
) -> None:
|
|
2955
3024
|
txn_params: TxParams = {
|
|
2956
|
-
"from":
|
|
2957
|
-
"to":
|
|
3025
|
+
"from": keyfile_account_address,
|
|
3026
|
+
"to": keyfile_account_address,
|
|
2958
3027
|
"value": Wei(1),
|
|
2959
3028
|
"gas": 21000,
|
|
2960
3029
|
"maxFeePerGas": hex(w3.to_wei(2, "gwei")),
|
|
@@ -2963,7 +3032,7 @@ class EthModuleTest:
|
|
|
2963
3032
|
}
|
|
2964
3033
|
result = w3.eth.sign_transaction(txn_params)
|
|
2965
3034
|
signatory_account = w3.eth.account.recover_transaction(result["raw"])
|
|
2966
|
-
assert
|
|
3035
|
+
assert keyfile_account_address == signatory_account
|
|
2967
3036
|
assert result["tx"]["to"] == txn_params["to"]
|
|
2968
3037
|
assert result["tx"]["value"] == txn_params["value"]
|
|
2969
3038
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
@@ -2974,9 +3043,9 @@ class EthModuleTest:
|
|
|
2974
3043
|
assert result["tx"]["nonce"] == txn_params["nonce"]
|
|
2975
3044
|
|
|
2976
3045
|
def test_eth_sign_transaction_ens_names(
|
|
2977
|
-
self, w3: "Web3",
|
|
3046
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
2978
3047
|
) -> None:
|
|
2979
|
-
with ens_addresses(w3, {"unlocked-account.eth":
|
|
3048
|
+
with ens_addresses(w3, {"unlocked-account.eth": keyfile_account_address}):
|
|
2980
3049
|
txn_params: TxParams = {
|
|
2981
3050
|
"from": "unlocked-account.eth",
|
|
2982
3051
|
"to": "unlocked-account.eth",
|
|
@@ -2988,8 +3057,8 @@ class EthModuleTest:
|
|
|
2988
3057
|
}
|
|
2989
3058
|
result = w3.eth.sign_transaction(txn_params)
|
|
2990
3059
|
signatory_account = w3.eth.account.recover_transaction(result["raw"])
|
|
2991
|
-
assert
|
|
2992
|
-
assert result["tx"]["to"] ==
|
|
3060
|
+
assert keyfile_account_address == signatory_account
|
|
3061
|
+
assert result["tx"]["to"] == keyfile_account_address
|
|
2993
3062
|
assert result["tx"]["value"] == txn_params["value"]
|
|
2994
3063
|
assert result["tx"]["gas"] == txn_params["gas"]
|
|
2995
3064
|
assert result["tx"]["maxFeePerGas"] == txn_params["maxFeePerGas"]
|
|
@@ -3000,12 +3069,12 @@ class EthModuleTest:
|
|
|
3000
3069
|
assert result["tx"]["nonce"] == txn_params["nonce"]
|
|
3001
3070
|
|
|
3002
3071
|
def test_eth_send_transaction_addr_checksum_required(
|
|
3003
|
-
self, w3: "Web3",
|
|
3072
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3004
3073
|
) -> None:
|
|
3005
|
-
non_checksum_addr =
|
|
3074
|
+
non_checksum_addr = keyfile_account_address.lower()
|
|
3006
3075
|
txn_params: TxParams = {
|
|
3007
|
-
"from":
|
|
3008
|
-
"to":
|
|
3076
|
+
"from": keyfile_account_address,
|
|
3077
|
+
"to": keyfile_account_address,
|
|
3009
3078
|
"value": Wei(1),
|
|
3010
3079
|
"gas": 21000,
|
|
3011
3080
|
"maxFeePerGas": w3.to_wei(2, "gwei"),
|
|
@@ -3025,11 +3094,11 @@ class EthModuleTest:
|
|
|
3025
3094
|
w3.eth.send_transaction(invalid_params)
|
|
3026
3095
|
|
|
3027
3096
|
def test_eth_send_transaction_legacy(
|
|
3028
|
-
self, w3: "Web3",
|
|
3097
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3029
3098
|
) -> None:
|
|
3030
3099
|
txn_params: TxParams = {
|
|
3031
|
-
"from":
|
|
3032
|
-
"to":
|
|
3100
|
+
"from": keyfile_account_address_dual_type,
|
|
3101
|
+
"to": keyfile_account_address_dual_type,
|
|
3033
3102
|
"value": Wei(1),
|
|
3034
3103
|
"gas": 21000,
|
|
3035
3104
|
"gasPrice": w3.to_wei(
|
|
@@ -3046,11 +3115,11 @@ class EthModuleTest:
|
|
|
3046
3115
|
assert txn["gasPrice"] == txn_params["gasPrice"]
|
|
3047
3116
|
|
|
3048
3117
|
def test_eth_send_transaction(
|
|
3049
|
-
self, w3: "Web3",
|
|
3118
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3050
3119
|
) -> None:
|
|
3051
3120
|
txn_params: TxParams = {
|
|
3052
|
-
"from":
|
|
3053
|
-
"to":
|
|
3121
|
+
"from": keyfile_account_address_dual_type,
|
|
3122
|
+
"to": keyfile_account_address_dual_type,
|
|
3054
3123
|
"value": Wei(1),
|
|
3055
3124
|
"gas": 21000,
|
|
3056
3125
|
"maxFeePerGas": w3.to_wei(3, "gwei"),
|
|
@@ -3068,20 +3137,22 @@ class EthModuleTest:
|
|
|
3068
3137
|
assert txn["gasPrice"] == txn_params["maxFeePerGas"]
|
|
3069
3138
|
|
|
3070
3139
|
def test_eth_send_transaction_with_nonce(
|
|
3071
|
-
self, w3: "Web3",
|
|
3140
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3072
3141
|
) -> None:
|
|
3073
3142
|
max_priority_fee_per_gas = w3.to_wei(1.234, "gwei")
|
|
3074
3143
|
max_fee_per_gas = Wei(
|
|
3075
3144
|
w3.eth.get_block("latest")["baseFeePerGas"] + max_priority_fee_per_gas
|
|
3076
3145
|
)
|
|
3077
3146
|
txn_params: TxParams = {
|
|
3078
|
-
"from":
|
|
3079
|
-
"to":
|
|
3147
|
+
"from": keyfile_account_address,
|
|
3148
|
+
"to": keyfile_account_address,
|
|
3080
3149
|
"value": Wei(1),
|
|
3081
3150
|
"gas": 21000,
|
|
3082
3151
|
"maxFeePerGas": max_fee_per_gas,
|
|
3083
3152
|
"maxPriorityFeePerGas": max_priority_fee_per_gas,
|
|
3084
|
-
"nonce": Nonce(
|
|
3153
|
+
"nonce": Nonce(
|
|
3154
|
+
w3.eth.get_transaction_count(keyfile_account_address, "pending")
|
|
3155
|
+
),
|
|
3085
3156
|
}
|
|
3086
3157
|
txn_hash = w3.eth.send_transaction(txn_params)
|
|
3087
3158
|
txn = w3.eth.get_transaction(txn_hash)
|
|
@@ -3097,11 +3168,11 @@ class EthModuleTest:
|
|
|
3097
3168
|
assert is_integer(txn_params["maxFeePerGas"])
|
|
3098
3169
|
|
|
3099
3170
|
def test_eth_send_transaction_default_fees(
|
|
3100
|
-
self, w3: "Web3",
|
|
3171
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3101
3172
|
) -> None:
|
|
3102
3173
|
txn_params: TxParams = {
|
|
3103
|
-
"from":
|
|
3104
|
-
"to":
|
|
3174
|
+
"from": keyfile_account_address_dual_type,
|
|
3175
|
+
"to": keyfile_account_address_dual_type,
|
|
3105
3176
|
"value": Wei(1),
|
|
3106
3177
|
"gas": 21000,
|
|
3107
3178
|
}
|
|
@@ -3117,11 +3188,11 @@ class EthModuleTest:
|
|
|
3117
3188
|
assert txn["gasPrice"] == txn["maxFeePerGas"]
|
|
3118
3189
|
|
|
3119
3190
|
def test_eth_send_transaction_hex_fees(
|
|
3120
|
-
self, w3: "Web3",
|
|
3191
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3121
3192
|
) -> None:
|
|
3122
3193
|
txn_params: TxParams = {
|
|
3123
|
-
"from":
|
|
3124
|
-
"to":
|
|
3194
|
+
"from": keyfile_account_address_dual_type,
|
|
3195
|
+
"to": keyfile_account_address_dual_type,
|
|
3125
3196
|
"value": Wei(1),
|
|
3126
3197
|
"gas": 21000,
|
|
3127
3198
|
"maxFeePerGas": hex(250 * 10**9),
|
|
@@ -3138,11 +3209,11 @@ class EthModuleTest:
|
|
|
3138
3209
|
assert txn["maxPriorityFeePerGas"] == 2 * 10**9
|
|
3139
3210
|
|
|
3140
3211
|
def test_eth_send_transaction_no_gas(
|
|
3141
|
-
self, w3: "Web3",
|
|
3212
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3142
3213
|
) -> None:
|
|
3143
3214
|
txn_params: TxParams = {
|
|
3144
|
-
"from":
|
|
3145
|
-
"to":
|
|
3215
|
+
"from": keyfile_account_address_dual_type,
|
|
3216
|
+
"to": keyfile_account_address_dual_type,
|
|
3146
3217
|
"value": Wei(1),
|
|
3147
3218
|
"maxFeePerGas": Wei(250 * 10**9),
|
|
3148
3219
|
"maxPriorityFeePerGas": Wei(2 * 10**9),
|
|
@@ -3156,11 +3227,11 @@ class EthModuleTest:
|
|
|
3156
3227
|
assert txn["gas"] == 121000 # 21000 + buffer
|
|
3157
3228
|
|
|
3158
3229
|
def test_eth_send_transaction_with_gas_price(
|
|
3159
|
-
self, w3: "Web3",
|
|
3230
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3160
3231
|
) -> None:
|
|
3161
3232
|
txn_params: TxParams = {
|
|
3162
|
-
"from":
|
|
3163
|
-
"to":
|
|
3233
|
+
"from": keyfile_account_address_dual_type,
|
|
3234
|
+
"to": keyfile_account_address_dual_type,
|
|
3164
3235
|
"value": Wei(1),
|
|
3165
3236
|
"gas": 21000,
|
|
3166
3237
|
"gasPrice": Wei(1),
|
|
@@ -3171,11 +3242,11 @@ class EthModuleTest:
|
|
|
3171
3242
|
w3.eth.send_transaction(txn_params)
|
|
3172
3243
|
|
|
3173
3244
|
def test_eth_send_transaction_no_priority_fee(
|
|
3174
|
-
self, w3: "Web3",
|
|
3245
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3175
3246
|
) -> None:
|
|
3176
3247
|
txn_params: TxParams = {
|
|
3177
|
-
"from":
|
|
3178
|
-
"to":
|
|
3248
|
+
"from": keyfile_account_address_dual_type,
|
|
3249
|
+
"to": keyfile_account_address_dual_type,
|
|
3179
3250
|
"value": Wei(1),
|
|
3180
3251
|
"gas": 21000,
|
|
3181
3252
|
"maxFeePerGas": Wei(250 * 10**9),
|
|
@@ -3186,12 +3257,12 @@ class EthModuleTest:
|
|
|
3186
3257
|
w3.eth.send_transaction(txn_params)
|
|
3187
3258
|
|
|
3188
3259
|
def test_eth_send_transaction_no_max_fee(
|
|
3189
|
-
self, w3: "Web3",
|
|
3260
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3190
3261
|
) -> None:
|
|
3191
3262
|
max_priority_fee_per_gas = w3.to_wei(2, "gwei")
|
|
3192
3263
|
txn_params: TxParams = {
|
|
3193
|
-
"from":
|
|
3194
|
-
"to":
|
|
3264
|
+
"from": keyfile_account_address_dual_type,
|
|
3265
|
+
"to": keyfile_account_address_dual_type,
|
|
3195
3266
|
"value": Wei(1),
|
|
3196
3267
|
"gas": 21000,
|
|
3197
3268
|
"maxPriorityFeePerGas": max_priority_fee_per_gas,
|
|
@@ -3208,11 +3279,11 @@ class EthModuleTest:
|
|
|
3208
3279
|
assert is_integer(txn["maxFeePerGas"])
|
|
3209
3280
|
|
|
3210
3281
|
def test_eth_send_transaction_max_fee_less_than_tip(
|
|
3211
|
-
self, w3: "Web3",
|
|
3282
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3212
3283
|
) -> None:
|
|
3213
3284
|
txn_params: TxParams = {
|
|
3214
|
-
"from":
|
|
3215
|
-
"to":
|
|
3285
|
+
"from": keyfile_account_address_dual_type,
|
|
3286
|
+
"to": keyfile_account_address_dual_type,
|
|
3216
3287
|
"value": Wei(1),
|
|
3217
3288
|
"gas": 21000,
|
|
3218
3289
|
"maxFeePerGas": Wei(1 * 10**9),
|
|
@@ -3224,14 +3295,14 @@ class EthModuleTest:
|
|
|
3224
3295
|
w3.eth.send_transaction(txn_params)
|
|
3225
3296
|
|
|
3226
3297
|
def test_validation_middleware_chain_id_mismatch(
|
|
3227
|
-
self, w3: "Web3",
|
|
3298
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3228
3299
|
) -> None:
|
|
3229
3300
|
wrong_chain_id = 1234567890
|
|
3230
3301
|
actual_chain_id = w3.eth.chain_id
|
|
3231
3302
|
|
|
3232
3303
|
txn_params: TxParams = {
|
|
3233
|
-
"from":
|
|
3234
|
-
"to":
|
|
3304
|
+
"from": keyfile_account_address_dual_type,
|
|
3305
|
+
"to": keyfile_account_address_dual_type,
|
|
3235
3306
|
"value": Wei(1),
|
|
3236
3307
|
"gas": Wei(21000),
|
|
3237
3308
|
"maxFeePerGas": w3.to_wei(2, "gwei"),
|
|
@@ -3249,12 +3320,15 @@ class EthModuleTest:
|
|
|
3249
3320
|
"max_fee", (1000000000, None), ids=["with_max_fee", "without_max_fee"]
|
|
3250
3321
|
)
|
|
3251
3322
|
def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn(
|
|
3252
|
-
self,
|
|
3323
|
+
self,
|
|
3324
|
+
w3: "Web3",
|
|
3325
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
3326
|
+
max_fee: Wei,
|
|
3253
3327
|
) -> None:
|
|
3254
3328
|
max_priority_fee = w3.to_wei(1, "gwei")
|
|
3255
3329
|
txn_params: TxParams = {
|
|
3256
|
-
"from":
|
|
3257
|
-
"to":
|
|
3330
|
+
"from": keyfile_account_address_dual_type,
|
|
3331
|
+
"to": keyfile_account_address_dual_type,
|
|
3258
3332
|
"value": Wei(1),
|
|
3259
3333
|
"gas": 21000,
|
|
3260
3334
|
"maxPriorityFeePerGas": max_priority_fee,
|
|
@@ -3284,11 +3358,11 @@ class EthModuleTest:
|
|
|
3284
3358
|
def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn_no_tip(
|
|
3285
3359
|
self,
|
|
3286
3360
|
w3: "Web3",
|
|
3287
|
-
|
|
3361
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
3288
3362
|
) -> None:
|
|
3289
3363
|
txn_params: TxParams = {
|
|
3290
|
-
"from":
|
|
3291
|
-
"to":
|
|
3364
|
+
"from": keyfile_account_address_dual_type,
|
|
3365
|
+
"to": keyfile_account_address_dual_type,
|
|
3292
3366
|
"value": Wei(1),
|
|
3293
3367
|
"gas": 21000,
|
|
3294
3368
|
"maxFeePerGas": Wei(1000000000),
|
|
@@ -3307,11 +3381,11 @@ class EthModuleTest:
|
|
|
3307
3381
|
w3.eth.set_gas_price_strategy(None) # reset strategy
|
|
3308
3382
|
|
|
3309
3383
|
def test_gas_price_strategy_hex_value(
|
|
3310
|
-
self, w3: "Web3",
|
|
3384
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3311
3385
|
) -> None:
|
|
3312
3386
|
txn_params: TxParams = {
|
|
3313
|
-
"from":
|
|
3314
|
-
"to":
|
|
3387
|
+
"from": keyfile_account_address_dual_type,
|
|
3388
|
+
"to": keyfile_account_address_dual_type,
|
|
3315
3389
|
"value": Wei(1),
|
|
3316
3390
|
"gas": 21000,
|
|
3317
3391
|
}
|
|
@@ -3330,11 +3404,11 @@ class EthModuleTest:
|
|
|
3330
3404
|
|
|
3331
3405
|
@flaky_geth_dev_mining
|
|
3332
3406
|
def test_eth_replace_transaction_legacy(
|
|
3333
|
-
self, w3: "Web3",
|
|
3407
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3334
3408
|
) -> None:
|
|
3335
3409
|
txn_params: TxParams = {
|
|
3336
|
-
"from":
|
|
3337
|
-
"to":
|
|
3410
|
+
"from": keyfile_account_address_dual_type,
|
|
3411
|
+
"to": keyfile_account_address_dual_type,
|
|
3338
3412
|
"value": Wei(1),
|
|
3339
3413
|
"gas": 21000,
|
|
3340
3414
|
"gasPrice": w3.to_wei(
|
|
@@ -3359,14 +3433,14 @@ class EthModuleTest:
|
|
|
3359
3433
|
|
|
3360
3434
|
@flaky_geth_dev_mining
|
|
3361
3435
|
def test_eth_replace_transaction(
|
|
3362
|
-
self, w3: "Web3",
|
|
3436
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3363
3437
|
) -> None:
|
|
3364
3438
|
two_gwei_in_wei = w3.to_wei(2, "gwei")
|
|
3365
3439
|
three_gwei_in_wei = w3.to_wei(3, "gwei")
|
|
3366
3440
|
|
|
3367
3441
|
txn_params: TxParams = {
|
|
3368
|
-
"from":
|
|
3369
|
-
"to":
|
|
3442
|
+
"from": keyfile_account_address_dual_type,
|
|
3443
|
+
"to": keyfile_account_address_dual_type,
|
|
3370
3444
|
"value": Wei(1),
|
|
3371
3445
|
"gas": 21000,
|
|
3372
3446
|
"maxFeePerGas": two_gwei_in_wei,
|
|
@@ -3393,11 +3467,11 @@ class EthModuleTest:
|
|
|
3393
3467
|
|
|
3394
3468
|
@flaky_geth_dev_mining
|
|
3395
3469
|
def test_eth_replace_transaction_underpriced(
|
|
3396
|
-
self, w3: "Web3",
|
|
3470
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3397
3471
|
) -> None:
|
|
3398
3472
|
txn_params: TxParams = {
|
|
3399
|
-
"from":
|
|
3400
|
-
"to":
|
|
3473
|
+
"from": keyfile_account_address_dual_type,
|
|
3474
|
+
"to": keyfile_account_address_dual_type,
|
|
3401
3475
|
"value": Wei(1),
|
|
3402
3476
|
"gas": 21000,
|
|
3403
3477
|
"maxFeePerGas": w3.to_wei(3, "gwei"),
|
|
@@ -3409,16 +3483,16 @@ class EthModuleTest:
|
|
|
3409
3483
|
txn_params["maxFeePerGas"] = one_gwei_in_wei
|
|
3410
3484
|
txn_params["maxPriorityFeePerGas"] = one_gwei_in_wei
|
|
3411
3485
|
|
|
3412
|
-
with pytest.raises(
|
|
3486
|
+
with pytest.raises(Web3RPCError, match="replacement transaction underpriced"):
|
|
3413
3487
|
w3.eth.replace_transaction(txn_hash, txn_params)
|
|
3414
3488
|
|
|
3415
3489
|
@flaky_geth_dev_mining
|
|
3416
3490
|
def test_eth_replace_transaction_non_existing_transaction(
|
|
3417
|
-
self, w3: "Web3",
|
|
3491
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3418
3492
|
) -> None:
|
|
3419
3493
|
txn_params: TxParams = {
|
|
3420
|
-
"from":
|
|
3421
|
-
"to":
|
|
3494
|
+
"from": keyfile_account_address_dual_type,
|
|
3495
|
+
"to": keyfile_account_address_dual_type,
|
|
3422
3496
|
"value": Wei(1),
|
|
3423
3497
|
"gas": 21000,
|
|
3424
3498
|
"maxFeePerGas": w3.to_wei(3, "gwei"),
|
|
@@ -3434,11 +3508,11 @@ class EthModuleTest:
|
|
|
3434
3508
|
|
|
3435
3509
|
@flaky_geth_dev_mining
|
|
3436
3510
|
def test_eth_replace_transaction_already_mined(
|
|
3437
|
-
self, w3: "Web3",
|
|
3511
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3438
3512
|
) -> None:
|
|
3439
3513
|
txn_params: TxParams = {
|
|
3440
|
-
"from":
|
|
3441
|
-
"to":
|
|
3514
|
+
"from": keyfile_account_address_dual_type,
|
|
3515
|
+
"to": keyfile_account_address_dual_type,
|
|
3442
3516
|
"value": Wei(1),
|
|
3443
3517
|
"gas": 21000,
|
|
3444
3518
|
"maxFeePerGas": w3.to_wei(2, "gwei"),
|
|
@@ -3449,16 +3523,16 @@ class EthModuleTest:
|
|
|
3449
3523
|
|
|
3450
3524
|
txn_params["maxFeePerGas"] = w3.to_wei(3, "gwei")
|
|
3451
3525
|
txn_params["maxPriorityFeePerGas"] = w3.to_wei(2, "gwei")
|
|
3452
|
-
with pytest.raises(
|
|
3526
|
+
with pytest.raises(Web3ValueError, match="Supplied transaction with hash"):
|
|
3453
3527
|
w3.eth.replace_transaction(txn_hash, txn_params)
|
|
3454
3528
|
|
|
3455
3529
|
@flaky_geth_dev_mining
|
|
3456
3530
|
def test_eth_replace_transaction_incorrect_nonce(
|
|
3457
|
-
self, w3: "Web3",
|
|
3531
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3458
3532
|
) -> None:
|
|
3459
3533
|
txn_params: TxParams = {
|
|
3460
|
-
"from":
|
|
3461
|
-
"to":
|
|
3534
|
+
"from": keyfile_account_address,
|
|
3535
|
+
"to": keyfile_account_address,
|
|
3462
3536
|
"value": Wei(1),
|
|
3463
3537
|
"gas": 21000,
|
|
3464
3538
|
"maxFeePerGas": w3.to_wei(2, "gwei"),
|
|
@@ -3470,16 +3544,16 @@ class EthModuleTest:
|
|
|
3470
3544
|
txn_params["maxFeePerGas"] = w3.to_wei(3, "gwei")
|
|
3471
3545
|
txn_params["maxPriorityFeePerGas"] = w3.to_wei(2, "gwei")
|
|
3472
3546
|
txn_params["nonce"] = Nonce(txn["nonce"] + 1)
|
|
3473
|
-
with pytest.raises(
|
|
3547
|
+
with pytest.raises(Web3ValueError):
|
|
3474
3548
|
w3.eth.replace_transaction(txn_hash, txn_params)
|
|
3475
3549
|
|
|
3476
3550
|
@flaky_geth_dev_mining
|
|
3477
3551
|
def test_eth_replace_transaction_gas_price_too_low(
|
|
3478
|
-
self, w3: "Web3",
|
|
3552
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
3479
3553
|
) -> None:
|
|
3480
3554
|
txn_params: TxParams = {
|
|
3481
|
-
"from":
|
|
3482
|
-
"to":
|
|
3555
|
+
"from": keyfile_account_address_dual_type,
|
|
3556
|
+
"to": keyfile_account_address_dual_type,
|
|
3483
3557
|
"value": Wei(1),
|
|
3484
3558
|
"gas": 21000,
|
|
3485
3559
|
"gasPrice": w3.to_wei(2, "gwei"),
|
|
@@ -3487,18 +3561,18 @@ class EthModuleTest:
|
|
|
3487
3561
|
txn_hash = w3.eth.send_transaction(txn_params)
|
|
3488
3562
|
|
|
3489
3563
|
txn_params["gasPrice"] = w3.to_wei(1, "gwei")
|
|
3490
|
-
with pytest.raises(
|
|
3564
|
+
with pytest.raises(Web3ValueError):
|
|
3491
3565
|
w3.eth.replace_transaction(txn_hash, txn_params)
|
|
3492
3566
|
|
|
3493
3567
|
@flaky_geth_dev_mining
|
|
3494
3568
|
def test_eth_replace_transaction_gas_price_defaulting_minimum(
|
|
3495
|
-
self, w3: "Web3",
|
|
3569
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3496
3570
|
) -> None:
|
|
3497
3571
|
gas_price = w3.to_wei(1, "gwei")
|
|
3498
3572
|
|
|
3499
3573
|
txn_params: TxParams = {
|
|
3500
|
-
"from":
|
|
3501
|
-
"to":
|
|
3574
|
+
"from": keyfile_account_address,
|
|
3575
|
+
"to": keyfile_account_address,
|
|
3502
3576
|
"value": Wei(1),
|
|
3503
3577
|
"gas": 21000,
|
|
3504
3578
|
"gasPrice": gas_price,
|
|
@@ -3515,11 +3589,11 @@ class EthModuleTest:
|
|
|
3515
3589
|
|
|
3516
3590
|
@flaky_geth_dev_mining
|
|
3517
3591
|
def test_eth_replace_transaction_gas_price_defaulting_strategy_higher(
|
|
3518
|
-
self, w3: "Web3",
|
|
3592
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3519
3593
|
) -> None:
|
|
3520
3594
|
txn_params: TxParams = {
|
|
3521
|
-
"from":
|
|
3522
|
-
"to":
|
|
3595
|
+
"from": keyfile_account_address,
|
|
3596
|
+
"to": keyfile_account_address,
|
|
3523
3597
|
"value": Wei(1),
|
|
3524
3598
|
"gas": 21000,
|
|
3525
3599
|
"gasPrice": w3.to_wei(1, "gwei"),
|
|
@@ -3543,13 +3617,13 @@ class EthModuleTest:
|
|
|
3543
3617
|
|
|
3544
3618
|
@flaky_geth_dev_mining
|
|
3545
3619
|
def test_eth_replace_transaction_gas_price_defaulting_strategy_lower(
|
|
3546
|
-
self, w3: "Web3",
|
|
3620
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3547
3621
|
) -> None:
|
|
3548
3622
|
gas_price = w3.to_wei(2, "gwei")
|
|
3549
3623
|
|
|
3550
3624
|
txn_params: TxParams = {
|
|
3551
|
-
"from":
|
|
3552
|
-
"to":
|
|
3625
|
+
"from": keyfile_account_address,
|
|
3626
|
+
"to": keyfile_account_address,
|
|
3553
3627
|
"value": Wei(1),
|
|
3554
3628
|
"gas": 21000,
|
|
3555
3629
|
"gasPrice": gas_price,
|
|
@@ -3569,11 +3643,11 @@ class EthModuleTest:
|
|
|
3569
3643
|
w3.eth.set_gas_price_strategy(None) # reset strategy
|
|
3570
3644
|
|
|
3571
3645
|
def test_eth_modify_transaction_legacy(
|
|
3572
|
-
self, w3: "Web3",
|
|
3646
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3573
3647
|
) -> None:
|
|
3574
3648
|
txn_params: TxParams = {
|
|
3575
|
-
"from":
|
|
3576
|
-
"to":
|
|
3649
|
+
"from": keyfile_account_address,
|
|
3650
|
+
"to": keyfile_account_address,
|
|
3577
3651
|
"value": Wei(1),
|
|
3578
3652
|
"gas": 21000,
|
|
3579
3653
|
"gasPrice": w3.to_wei(
|
|
@@ -3583,7 +3657,7 @@ class EthModuleTest:
|
|
|
3583
3657
|
txn_hash = w3.eth.send_transaction(txn_params)
|
|
3584
3658
|
|
|
3585
3659
|
modified_txn_hash = w3.eth.modify_transaction(
|
|
3586
|
-
txn_hash, gasPrice=(cast(
|
|
3660
|
+
txn_hash, gasPrice=(cast(Wei, txn_params["gasPrice"] * 2)), value=Wei(2)
|
|
3587
3661
|
)
|
|
3588
3662
|
modified_txn = w3.eth.get_transaction(modified_txn_hash)
|
|
3589
3663
|
|
|
@@ -3598,11 +3672,11 @@ class EthModuleTest:
|
|
|
3598
3672
|
assert modified_txn["gasPrice"] == cast(int, txn_params["gasPrice"]) * 2
|
|
3599
3673
|
|
|
3600
3674
|
def test_eth_modify_transaction(
|
|
3601
|
-
self, w3: "Web3",
|
|
3675
|
+
self, w3: "Web3", keyfile_account_address: ChecksumAddress
|
|
3602
3676
|
) -> None:
|
|
3603
3677
|
txn_params: TxParams = {
|
|
3604
|
-
"from":
|
|
3605
|
-
"to":
|
|
3678
|
+
"from": keyfile_account_address,
|
|
3679
|
+
"to": keyfile_account_address,
|
|
3606
3680
|
"value": Wei(1),
|
|
3607
3681
|
"gas": 21000,
|
|
3608
3682
|
"maxPriorityFeePerGas": w3.to_wei(1, "gwei"),
|
|
@@ -3612,9 +3686,9 @@ class EthModuleTest:
|
|
|
3612
3686
|
|
|
3613
3687
|
modified_txn_hash = w3.eth.modify_transaction(
|
|
3614
3688
|
txn_hash,
|
|
3615
|
-
value=2,
|
|
3616
|
-
maxPriorityFeePerGas=(cast(Wei, txn_params["maxPriorityFeePerGas"]
|
|
3617
|
-
maxFeePerGas=(cast(Wei, txn_params["maxFeePerGas"]
|
|
3689
|
+
value=Wei(2),
|
|
3690
|
+
maxPriorityFeePerGas=(cast(Wei, txn_params["maxPriorityFeePerGas"] * 2)),
|
|
3691
|
+
maxFeePerGas=(cast(Wei, txn_params["maxFeePerGas"] * 2)),
|
|
3618
3692
|
)
|
|
3619
3693
|
modified_txn = w3.eth.get_transaction(modified_txn_hash)
|
|
3620
3694
|
|
|
@@ -3633,23 +3707,21 @@ class EthModuleTest:
|
|
|
3633
3707
|
assert modified_txn["maxFeePerGas"] == cast(Wei, txn_params["maxFeePerGas"]) * 2
|
|
3634
3708
|
|
|
3635
3709
|
def test_eth_send_raw_transaction(
|
|
3636
|
-
self, w3: "Web3",
|
|
3637
|
-
) -> None:
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
)
|
|
3651
|
-
txn_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
|
|
3652
|
-
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.raw_transaction)
|
|
3724
|
+
assert txn_hash == HexBytes(signed.hash)
|
|
3653
3725
|
|
|
3654
3726
|
def test_eth_call(self, w3: "Web3", math_contract: "Contract") -> None:
|
|
3655
3727
|
coinbase = w3.eth.coinbase
|
|
@@ -3743,12 +3815,12 @@ class EthModuleTest:
|
|
|
3743
3815
|
self,
|
|
3744
3816
|
w3: "Web3",
|
|
3745
3817
|
revert_contract: "Contract",
|
|
3746
|
-
|
|
3818
|
+
keyfile_account_address: ChecksumAddress,
|
|
3747
3819
|
) -> None:
|
|
3748
3820
|
txn_params = revert_contract._prepare_transaction(
|
|
3749
3821
|
fn_name="revertWithMessage",
|
|
3750
3822
|
transaction={
|
|
3751
|
-
"from":
|
|
3823
|
+
"from": keyfile_account_address,
|
|
3752
3824
|
"to": revert_contract.address,
|
|
3753
3825
|
},
|
|
3754
3826
|
)
|
|
@@ -3763,13 +3835,13 @@ class EthModuleTest:
|
|
|
3763
3835
|
self,
|
|
3764
3836
|
w3: "Web3",
|
|
3765
3837
|
revert_contract: "Contract",
|
|
3766
|
-
|
|
3838
|
+
keyfile_account_address: ChecksumAddress,
|
|
3767
3839
|
) -> None:
|
|
3768
3840
|
with pytest.raises(ContractLogicError, match="execution reverted"):
|
|
3769
3841
|
txn_params = revert_contract._prepare_transaction(
|
|
3770
3842
|
fn_name="revertWithoutMessage",
|
|
3771
3843
|
transaction={
|
|
3772
|
-
"from":
|
|
3844
|
+
"from": keyfile_account_address,
|
|
3773
3845
|
"to": revert_contract.address,
|
|
3774
3846
|
},
|
|
3775
3847
|
)
|
|
@@ -3779,7 +3851,7 @@ class EthModuleTest:
|
|
|
3779
3851
|
self,
|
|
3780
3852
|
w3: "Web3",
|
|
3781
3853
|
revert_contract: "Contract",
|
|
3782
|
-
|
|
3854
|
+
keyfile_account_address: ChecksumAddress,
|
|
3783
3855
|
) -> None:
|
|
3784
3856
|
data = revert_contract.encode_abi(
|
|
3785
3857
|
fn_name="UnauthorizedWithMessage", args=["You are not authorized"]
|
|
@@ -3787,7 +3859,7 @@ class EthModuleTest:
|
|
|
3787
3859
|
txn_params = revert_contract._prepare_transaction(
|
|
3788
3860
|
fn_name="customErrorWithMessage",
|
|
3789
3861
|
transaction={
|
|
3790
|
-
"from":
|
|
3862
|
+
"from": keyfile_account_address,
|
|
3791
3863
|
"to": revert_contract.address,
|
|
3792
3864
|
},
|
|
3793
3865
|
)
|
|
@@ -3799,13 +3871,13 @@ class EthModuleTest:
|
|
|
3799
3871
|
self,
|
|
3800
3872
|
w3: "Web3",
|
|
3801
3873
|
revert_contract: "Contract",
|
|
3802
|
-
|
|
3874
|
+
keyfile_account_address: ChecksumAddress,
|
|
3803
3875
|
) -> None:
|
|
3804
3876
|
data = revert_contract.encode_abi(fn_name="Unauthorized")
|
|
3805
3877
|
txn_params = revert_contract._prepare_transaction(
|
|
3806
3878
|
fn_name="customErrorWithoutMessage",
|
|
3807
3879
|
transaction={
|
|
3808
|
-
"from":
|
|
3880
|
+
"from": keyfile_account_address,
|
|
3809
3881
|
"to": revert_contract.address,
|
|
3810
3882
|
},
|
|
3811
3883
|
)
|
|
@@ -3847,7 +3919,7 @@ class EthModuleTest:
|
|
|
3847
3919
|
self,
|
|
3848
3920
|
w3: "Web3",
|
|
3849
3921
|
offchain_lookup_contract: "Contract",
|
|
3850
|
-
|
|
3922
|
+
keyfile_account_address: ChecksumAddress,
|
|
3851
3923
|
monkeypatch: "MonkeyPatch",
|
|
3852
3924
|
) -> None:
|
|
3853
3925
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -3902,7 +3974,7 @@ class EthModuleTest:
|
|
|
3902
3974
|
self,
|
|
3903
3975
|
w3: "Web3",
|
|
3904
3976
|
offchain_lookup_contract: "Contract",
|
|
3905
|
-
|
|
3977
|
+
keyfile_account_address: ChecksumAddress,
|
|
3906
3978
|
monkeypatch: "MonkeyPatch",
|
|
3907
3979
|
) -> None:
|
|
3908
3980
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -3933,7 +4005,7 @@ class EthModuleTest:
|
|
|
3933
4005
|
default_max_redirects = w3.provider.ccip_read_max_redirects
|
|
3934
4006
|
|
|
3935
4007
|
w3.provider.ccip_read_max_redirects = max_redirects
|
|
3936
|
-
with pytest.raises(
|
|
4008
|
+
with pytest.raises(Web3ValueError, match="at least 4"):
|
|
3937
4009
|
offchain_lookup_contract.functions.testOffchainLookup(
|
|
3938
4010
|
OFFCHAIN_LOOKUP_TEST_DATA
|
|
3939
4011
|
).call()
|
|
@@ -3944,7 +4016,7 @@ class EthModuleTest:
|
|
|
3944
4016
|
self,
|
|
3945
4017
|
w3: "Web3",
|
|
3946
4018
|
offchain_lookup_contract: "Contract",
|
|
3947
|
-
|
|
4019
|
+
keyfile_account_address: ChecksumAddress,
|
|
3948
4020
|
monkeypatch: "MonkeyPatch",
|
|
3949
4021
|
) -> None:
|
|
3950
4022
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -3966,7 +4038,7 @@ class EthModuleTest:
|
|
|
3966
4038
|
self,
|
|
3967
4039
|
w3: "Web3",
|
|
3968
4040
|
offchain_lookup_contract: "Contract",
|
|
3969
|
-
|
|
4041
|
+
keyfile_account_address: ChecksumAddress,
|
|
3970
4042
|
monkeypatch: "MonkeyPatch",
|
|
3971
4043
|
status_code_non_4xx_error: int,
|
|
3972
4044
|
) -> None:
|
|
@@ -4003,7 +4075,7 @@ class EthModuleTest:
|
|
|
4003
4075
|
self,
|
|
4004
4076
|
w3: "Web3",
|
|
4005
4077
|
offchain_lookup_contract: "Contract",
|
|
4006
|
-
|
|
4078
|
+
keyfile_account_address: ChecksumAddress,
|
|
4007
4079
|
monkeypatch: "MonkeyPatch",
|
|
4008
4080
|
) -> None:
|
|
4009
4081
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -4022,7 +4094,6 @@ class EthModuleTest:
|
|
|
4022
4094
|
|
|
4023
4095
|
def test_eth_call_offchain_lookup_raises_when_all_supplied_urls_fail(
|
|
4024
4096
|
self,
|
|
4025
|
-
w3: "Web3",
|
|
4026
4097
|
offchain_lookup_contract: "Contract",
|
|
4027
4098
|
) -> None:
|
|
4028
4099
|
# GET and POST requests should fail since responses are not mocked
|
|
@@ -4035,9 +4106,7 @@ class EthModuleTest:
|
|
|
4035
4106
|
|
|
4036
4107
|
def test_eth_call_continuous_offchain_lookup_raises_with_too_many_requests(
|
|
4037
4108
|
self,
|
|
4038
|
-
w3: "Web3",
|
|
4039
4109
|
offchain_lookup_contract: "Contract",
|
|
4040
|
-
unlocked_account: ChecksumAddress,
|
|
4041
4110
|
monkeypatch: "MonkeyPatch",
|
|
4042
4111
|
) -> None:
|
|
4043
4112
|
normalized_contract_address = to_hex_if_bytes(
|
|
@@ -4054,7 +4123,7 @@ class EthModuleTest:
|
|
|
4054
4123
|
self,
|
|
4055
4124
|
w3: "Web3",
|
|
4056
4125
|
revert_contract: "Contract",
|
|
4057
|
-
|
|
4126
|
+
keyfile_account_address: ChecksumAddress,
|
|
4058
4127
|
) -> None:
|
|
4059
4128
|
with pytest.raises(
|
|
4060
4129
|
ContractLogicError, match="execution reverted: Function has been reverted"
|
|
@@ -4062,7 +4131,7 @@ class EthModuleTest:
|
|
|
4062
4131
|
txn_params = revert_contract._prepare_transaction(
|
|
4063
4132
|
fn_name="revertWithMessage",
|
|
4064
4133
|
transaction={
|
|
4065
|
-
"from":
|
|
4134
|
+
"from": keyfile_account_address,
|
|
4066
4135
|
"to": revert_contract.address,
|
|
4067
4136
|
},
|
|
4068
4137
|
)
|
|
@@ -4072,13 +4141,13 @@ class EthModuleTest:
|
|
|
4072
4141
|
self,
|
|
4073
4142
|
w3: "Web3",
|
|
4074
4143
|
revert_contract: "Contract",
|
|
4075
|
-
|
|
4144
|
+
keyfile_account_address: ChecksumAddress,
|
|
4076
4145
|
) -> None:
|
|
4077
4146
|
with pytest.raises(ContractLogicError, match="execution reverted"):
|
|
4078
4147
|
txn_params = revert_contract._prepare_transaction(
|
|
4079
4148
|
fn_name="revertWithoutMessage",
|
|
4080
4149
|
transaction={
|
|
4081
|
-
"from":
|
|
4150
|
+
"from": keyfile_account_address,
|
|
4082
4151
|
"to": revert_contract.address,
|
|
4083
4152
|
},
|
|
4084
4153
|
)
|
|
@@ -4088,7 +4157,7 @@ class EthModuleTest:
|
|
|
4088
4157
|
self,
|
|
4089
4158
|
w3: "Web3",
|
|
4090
4159
|
revert_contract: "Contract",
|
|
4091
|
-
|
|
4160
|
+
keyfile_account_address: ChecksumAddress,
|
|
4092
4161
|
) -> None:
|
|
4093
4162
|
data = revert_contract.encode_abi(
|
|
4094
4163
|
fn_name="UnauthorizedWithMessage", args=["You are not authorized"]
|
|
@@ -4096,7 +4165,7 @@ class EthModuleTest:
|
|
|
4096
4165
|
txn_params = revert_contract._prepare_transaction(
|
|
4097
4166
|
fn_name="customErrorWithMessage",
|
|
4098
4167
|
transaction={
|
|
4099
|
-
"from":
|
|
4168
|
+
"from": keyfile_account_address,
|
|
4100
4169
|
"to": revert_contract.address,
|
|
4101
4170
|
},
|
|
4102
4171
|
)
|
|
@@ -4108,13 +4177,13 @@ class EthModuleTest:
|
|
|
4108
4177
|
self,
|
|
4109
4178
|
w3: "Web3",
|
|
4110
4179
|
revert_contract: "Contract",
|
|
4111
|
-
|
|
4180
|
+
keyfile_account_address: ChecksumAddress,
|
|
4112
4181
|
) -> None:
|
|
4113
4182
|
data = revert_contract.encode_abi(fn_name="Unauthorized")
|
|
4114
4183
|
txn_params = revert_contract._prepare_transaction(
|
|
4115
4184
|
fn_name="customErrorWithoutMessage",
|
|
4116
4185
|
transaction={
|
|
4117
|
-
"from":
|
|
4186
|
+
"from": keyfile_account_address,
|
|
4118
4187
|
"to": revert_contract.address,
|
|
4119
4188
|
},
|
|
4120
4189
|
)
|
|
@@ -4123,12 +4192,12 @@ class EthModuleTest:
|
|
|
4123
4192
|
assert excinfo.value.data == data
|
|
4124
4193
|
|
|
4125
4194
|
def test_eth_estimate_gas(
|
|
4126
|
-
self, w3: "Web3",
|
|
4195
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
4127
4196
|
) -> None:
|
|
4128
4197
|
gas_estimate = w3.eth.estimate_gas(
|
|
4129
4198
|
{
|
|
4130
|
-
"from":
|
|
4131
|
-
"to":
|
|
4199
|
+
"from": keyfile_account_address_dual_type,
|
|
4200
|
+
"to": keyfile_account_address_dual_type,
|
|
4132
4201
|
"value": Wei(1),
|
|
4133
4202
|
}
|
|
4134
4203
|
)
|
|
@@ -4136,12 +4205,12 @@ class EthModuleTest:
|
|
|
4136
4205
|
assert gas_estimate > 0
|
|
4137
4206
|
|
|
4138
4207
|
def test_eth_estimate_gas_with_block(
|
|
4139
|
-
self, w3: "Web3",
|
|
4208
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
4140
4209
|
) -> None:
|
|
4141
4210
|
gas_estimate = w3.eth.estimate_gas(
|
|
4142
4211
|
{
|
|
4143
|
-
"from":
|
|
4144
|
-
"to":
|
|
4212
|
+
"from": keyfile_account_address_dual_type,
|
|
4213
|
+
"to": keyfile_account_address_dual_type,
|
|
4145
4214
|
"value": Wei(1),
|
|
4146
4215
|
},
|
|
4147
4216
|
"latest",
|
|
@@ -4322,12 +4391,12 @@ class EthModuleTest:
|
|
|
4322
4391
|
assert effective_gas_price > 0
|
|
4323
4392
|
|
|
4324
4393
|
def test_eth_get_transaction_receipt_unmined(
|
|
4325
|
-
self, w3: "Web3",
|
|
4394
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
4326
4395
|
) -> None:
|
|
4327
4396
|
txn_hash = w3.eth.send_transaction(
|
|
4328
4397
|
{
|
|
4329
|
-
"from":
|
|
4330
|
-
"to":
|
|
4398
|
+
"from": keyfile_account_address_dual_type,
|
|
4399
|
+
"to": keyfile_account_address_dual_type,
|
|
4331
4400
|
"value": Wei(1),
|
|
4332
4401
|
"gas": 21000,
|
|
4333
4402
|
"maxFeePerGas": w3.to_wei(3, "gwei"),
|
|
@@ -4379,12 +4448,12 @@ class EthModuleTest:
|
|
|
4379
4448
|
assert effective_gas_price > 0
|
|
4380
4449
|
|
|
4381
4450
|
def test_eth_wait_for_transaction_receipt_unmined(
|
|
4382
|
-
self, w3: "Web3",
|
|
4451
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
4383
4452
|
) -> None:
|
|
4384
4453
|
txn_hash = w3.eth.send_transaction(
|
|
4385
4454
|
{
|
|
4386
|
-
"from":
|
|
4387
|
-
"to":
|
|
4455
|
+
"from": keyfile_account_address_dual_type,
|
|
4456
|
+
"to": keyfile_account_address_dual_type,
|
|
4388
4457
|
"value": Wei(1),
|
|
4389
4458
|
"gas": 21000,
|
|
4390
4459
|
"maxFeePerGas": w3.to_wei(3, "gwei"),
|
|
@@ -4482,7 +4551,7 @@ class EthModuleTest:
|
|
|
4482
4551
|
"fromBlock": block_with_txn_with_log["number"],
|
|
4483
4552
|
"toBlock": BlockNumber(block_with_txn_with_log["number"] - 1),
|
|
4484
4553
|
}
|
|
4485
|
-
with pytest.raises(
|
|
4554
|
+
with pytest.raises(Web3RPCError):
|
|
4486
4555
|
w3.eth.get_logs(filter_params)
|
|
4487
4556
|
|
|
4488
4557
|
# Test with `address`
|
|
@@ -4591,35 +4660,35 @@ class EthModuleTest:
|
|
|
4591
4660
|
assert len(result) == 0
|
|
4592
4661
|
|
|
4593
4662
|
def test_eth_call_old_contract_state(
|
|
4594
|
-
self,
|
|
4663
|
+
self,
|
|
4664
|
+
w3: "Web3",
|
|
4665
|
+
math_contract: "Contract",
|
|
4666
|
+
keyfile_account_address: ChecksumAddress,
|
|
4595
4667
|
) -> None:
|
|
4596
|
-
|
|
4597
|
-
block_num =
|
|
4598
|
-
block_hash =
|
|
4599
|
-
|
|
4600
|
-
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"]
|
|
4601
4671
|
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
# Ideas to improve this test:
|
|
4606
|
-
# - Enable on-demand mining in more clients
|
|
4607
|
-
# - Increment the math contract in all of the fixtures, and check the
|
|
4608
|
-
# value in an old block
|
|
4672
|
+
latest_call_result = math_contract.functions.counter().call(
|
|
4673
|
+
block_identifier="latest"
|
|
4674
|
+
)
|
|
4609
4675
|
block_hash_call_result = math_contract.functions.counter().call(
|
|
4610
4676
|
block_identifier=block_hash
|
|
4611
4677
|
)
|
|
4612
4678
|
block_num_call_result = math_contract.functions.counter().call(
|
|
4613
4679
|
block_identifier=block_num
|
|
4614
4680
|
)
|
|
4615
|
-
latest_call_result = math_contract.functions.counter().call(
|
|
4616
|
-
block_identifier="latest"
|
|
4617
|
-
)
|
|
4618
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
|
+
|
|
4619
4689
|
pending_call_result = math_contract.functions.counter().call(
|
|
4620
4690
|
block_identifier="pending"
|
|
4621
4691
|
)
|
|
4622
|
-
|
|
4623
4692
|
assert block_hash_call_result == 0
|
|
4624
4693
|
assert block_num_call_result == 0
|
|
4625
4694
|
assert latest_call_result == 0
|
|
@@ -4653,15 +4722,15 @@ class EthModuleTest:
|
|
|
4653
4722
|
def test_eth_get_raw_transaction_by_block(
|
|
4654
4723
|
self,
|
|
4655
4724
|
w3: "Web3",
|
|
4656
|
-
|
|
4725
|
+
keyfile_account_address_dual_type: ChecksumAddress,
|
|
4657
4726
|
block_with_txn: BlockData,
|
|
4658
4727
|
) -> None:
|
|
4659
4728
|
# eth_getRawTransactionByBlockNumberAndIndex: block identifier
|
|
4660
4729
|
# send a txn to make sure pending block has at least one txn
|
|
4661
4730
|
w3.eth.send_transaction(
|
|
4662
4731
|
{
|
|
4663
|
-
"from":
|
|
4664
|
-
"to":
|
|
4732
|
+
"from": keyfile_account_address_dual_type,
|
|
4733
|
+
"to": keyfile_account_address_dual_type,
|
|
4665
4734
|
"value": Wei(1),
|
|
4666
4735
|
}
|
|
4667
4736
|
)
|
|
@@ -4701,7 +4770,7 @@ class EthModuleTest:
|
|
|
4701
4770
|
) -> None:
|
|
4702
4771
|
unknown_identifier = "unknown"
|
|
4703
4772
|
with pytest.raises(
|
|
4704
|
-
|
|
4773
|
+
Web3ValueError,
|
|
4705
4774
|
match=(
|
|
4706
4775
|
"Value did not match any of the recognized block identifiers: "
|
|
4707
4776
|
f"{unknown_identifier}"
|
|
@@ -4710,16 +4779,16 @@ class EthModuleTest:
|
|
|
4710
4779
|
w3.eth.get_raw_transaction_by_block(unknown_identifier, 0)
|
|
4711
4780
|
|
|
4712
4781
|
def test_default_account(
|
|
4713
|
-
self, w3: "Web3",
|
|
4782
|
+
self, w3: "Web3", keyfile_account_address_dual_type: ChecksumAddress
|
|
4714
4783
|
) -> None:
|
|
4715
4784
|
# check defaults to empty
|
|
4716
4785
|
default_account = w3.eth.default_account
|
|
4717
4786
|
assert default_account is empty
|
|
4718
4787
|
|
|
4719
4788
|
# check setter
|
|
4720
|
-
w3.eth.default_account =
|
|
4789
|
+
w3.eth.default_account = keyfile_account_address_dual_type
|
|
4721
4790
|
default_account = w3.eth.default_account
|
|
4722
|
-
assert default_account ==
|
|
4791
|
+
assert default_account == keyfile_account_address_dual_type
|
|
4723
4792
|
|
|
4724
4793
|
# reset to default
|
|
4725
4794
|
w3.eth.default_account = empty
|