@@ -702,22 +702,24 @@ async def test_ExtraDataToPOAMiddleware(
702
702
async_w3 .middleware_onion .remove ("poa" )
703
703
704
704
@pytest .mark .asyncio
705
- async def test_eth_send_raw_transaction (self , async_w3 : "AsyncWeb3" ) -> None :
706
- # address 0x6E6d469fa47ab2f6630bAfc03ECca1212c29B114
707
- # private key 0x3c2ab4e8f17a7dea191b8c991522660126d681039509dc3bb31af7c9bdb63518
708
- # This is an unfunded account, but the transaction has a 0 gas price, so is
709
- # valid. It never needs to be mined, we just want the transaction hash back
710
- # to confirm.
711
- # tx = {'to': '0x0000000000000000000000000000000000000000', 'value': 0, 'nonce': 1, 'gas': 21000, 'gasPrice': 10**9, 'chainId': 131277322940537} # noqa: E501
712
- # NOTE: nonce=1 to make txn unique from the non-async version of this test
713
- raw_txn = HexBytes (
714
- "0xf86901843b9aca00825208940000000000000000000000000000000000000000808086eecac466e116a00c35ef06cefed3667cb9936ed1ed87177fd37654a86de9c8a7739011348cfc1ba00873e59bc3baf78faf7e526866e59f0b3c44063921790fe3f52862b679cd8c61" # noqa: E501
715
- )
716
- expected_hash = HexStr (
717
- "0x87638eb356dd219b3c9e3288e7631be2adb619c93f76a9c749112632184eb861"
718
- )
719
- txn_hash = await async_w3 .eth .send_raw_transaction (raw_txn )
720
- assert txn_hash == async_w3 .to_bytes (hexstr = expected_hash )
705
+ async def test_async_eth_send_raw_transaction (
706
+ self , async_w3 : "AsyncWeb3" , keyfile_account_pkey : HexStr
707
+ ) -> None :
708
+ keyfile_account = async_w3 .eth .account .from_key (keyfile_account_pkey )
709
+ txn = {
710
+ "chainId" : 131277322940537 , # the chainId set for the fixture
711
+ "from" : keyfile_account .address ,
712
+ "to" : keyfile_account .address ,
713
+ "value" : Wei (0 ),
714
+ "gas" : 21000 ,
715
+ "nonce" : await async_w3 .eth .get_transaction_count (
716
+ keyfile_account .address , "pending"
717
+ ),
718
+ "gasPrice" : 1 ,
719
+ }
720
+ signed = keyfile_account .sign_transaction (txn )
721
+ txn_hash = await async_w3 .eth .send_raw_transaction (signed .rawTransaction )
722
+ assert txn_hash == HexBytes (signed .hash )
721
723
722
724
@pytest .mark .asyncio
723
725
async def test_GasPriceStrategyMiddleware (
@@ -3701,22 +3703,22 @@ def test_eth_modify_transaction(
3701
3703
)
3702
3704
assert modified_txn ["maxFeePerGas" ] == cast (Wei , txn_params ["maxFeePerGas" ]) * 2
3703
3705
3704
- def test_eth_send_raw_transaction (self , w3 : "Web3" ) -> None :
3705
- # address 0x6E6d469fa47ab2f6630bAfc03ECca1212c29B114
3706
- # private key 0x3c2ab4e8f17a7dea191b8c991522660126d681039509dc3bb31af7c9bdb63518
3707
- # This is an unfunded account, but the transaction has a 0 gas price, so is
3708
- # valid. It never needs to be mined, we just want the transaction hash back
3709
- # to confirm.
3710
- # tx = {'to': '0x0000000000000000000000000000000000000000', 'value': 0, 'nonce': 0, 'gas': 21000, 'gasPrice': 10**9, 'chainId': 131277322940537} # noqa: E501
3711
- # NOTE: nonce=0 to make txn unique from the async version of this test
3712
- raw_txn = HexBytes (
3713
- "0xf86980843b9aca00825208940000000000000000000000000000000000000000808086eecac466e115a064c3ae78af36ee5014e3437ad6587966f4b06cd96327bb5dc48b78b0c1cc8ae7a01b1b9ba32935bbf95bc453ad4995a90de10f61879a77b45ca07451a99cd58fd5" # noqa: E501
3714
- )
3715
- expected_hash = HexStr (
3716
- "0x42c2440fc4425952544c2300f33083c8135c3800de4b4918e1e2f06b7bd74269"
3717
- )
3718
- txn_hash = w3 .eth .send_raw_transaction (raw_txn )
3719
- assert txn_hash == w3 . to_bytes ( hexstr = expected_hash )
3706
+ def test_eth_send_raw_transaction (
3707
+ self , w3 : "Web3" , keyfile_account_pkey : HexStr
3708
+ ) -> None :
3709
+ keyfile_account = w3 . eth . account . from_key ( keyfile_account_pkey )
3710
+ txn = {
3711
+ "chainId" : 131277322940537 , # the chainId set for the fixture
3712
+ "from" : keyfile_account . address ,
3713
+ "to" : keyfile_account . address ,
3714
+ "value" : Wei ( 0 ),
3715
+ "gas" : 21000 ,
3716
+ "nonce" : w3 . eth . get_transaction_count ( keyfile_account . address , "pending" ),
3717
+ "gasPrice" : 1 ,
3718
+ }
3719
+ signed = keyfile_account . sign_transaction ( txn )
3720
+ txn_hash = w3 .eth .send_raw_transaction (signed . rawTransaction )
3721
+ assert txn_hash == HexBytes ( signed . hash )
3720
3722
3721
3723
def test_eth_call (self , w3 : "Web3" , math_contract : "Contract" ) -> None :
3722
3724
coinbase = w3 .eth .coinbase
0 commit comments