@@ -723,6 +723,8 @@ async def test_async_sign_authorization_and_send_raw_set_code_transaction(
723
723
keyfile_account_pkey : HexStr ,
724
724
async_math_contract : "AsyncContract" ,
725
725
) -> None :
726
+ # TODO: remove blockNumber block_id from eth_call and eth_getCode calls once
727
+ # geth behavior for "latest" seems stable again.
726
728
keyfile_account = async_w3 .eth .account .from_key (keyfile_account_pkey )
727
729
728
730
chain_id = await async_w3 .eth .chain_id
@@ -737,9 +739,7 @@ async def test_async_sign_authorization_and_send_raw_set_code_transaction(
737
739
738
740
# get current math counter and increase it only in the delegation by n
739
741
math_counter = await async_math_contract .functions .counter ().call ()
740
- built_tx = await async_math_contract .functions .incrementCounter (
741
- math_counter + 1337
742
- ).build_transaction ({})
742
+ data = async_math_contract .encode_abi ("incrementCounter" , [math_counter + 1337 ])
743
743
txn : TxParams = {
744
744
"chainId" : chain_id ,
745
745
"to" : keyfile_account .address ,
@@ -748,23 +748,30 @@ async def test_async_sign_authorization_and_send_raw_set_code_transaction(
748
748
"nonce" : nonce ,
749
749
"maxPriorityFeePerGas" : Wei (10 ** 9 ),
750
750
"maxFeePerGas" : Wei (10 ** 9 ),
751
- "data" : built_tx [ " data" ] ,
751
+ "data" : data ,
752
752
"authorizationList" : [signed_auth ],
753
753
}
754
754
755
755
signed = keyfile_account .sign_transaction (txn )
756
756
tx_hash = await async_w3 .eth .send_raw_transaction (signed .raw_transaction )
757
757
get_tx = await async_w3 .eth .get_transaction (tx_hash )
758
- await async_w3 .eth .wait_for_transaction_receipt (tx_hash , timeout = 10 )
758
+ tx_receipt = await async_w3 .eth .wait_for_transaction_receipt (
759
+ tx_hash , timeout = 10
760
+ )
759
761
760
- code = await async_w3 .eth .get_code (keyfile_account .address )
762
+ code = await async_w3 .eth .get_code (
763
+ keyfile_account .address , block_identifier = tx_receipt ["blockNumber" ]
764
+ )
761
765
assert code .to_0x_hex () == f"0xef0100{ async_math_contract .address [2 :].lower ()} "
762
766
delegated = async_w3 .eth .contract (
763
767
address = keyfile_account .address , abi = async_math_contract .abi
764
768
)
769
+
765
770
# assert the math counter is increased by 1337 only in delegated acct
766
771
assert await async_math_contract .functions .counter ().call () == math_counter
767
- delegated_call = await delegated .functions .counter ().call ()
772
+ delegated_call = await delegated .functions .counter ().call (
773
+ block_identifier = tx_receipt ["blockNumber" ]
774
+ )
768
775
assert delegated_call == math_counter + 1337
769
776
770
777
assert len (get_tx ["authorizationList" ]) == 1
@@ -791,9 +798,13 @@ async def test_async_sign_authorization_and_send_raw_set_code_transaction(
791
798
reset_tx_hash = await async_w3 .eth .send_raw_transaction (
792
799
signed_reset .raw_transaction
793
800
)
794
- await async_w3 .eth .wait_for_transaction_receipt (reset_tx_hash , timeout = 10 )
801
+ reset_tx_receipt = await async_w3 .eth .wait_for_transaction_receipt (
802
+ reset_tx_hash , timeout = 10
803
+ )
795
804
796
- reset_code = await async_w3 .eth .get_code (keyfile_account .address )
805
+ reset_code = await async_w3 .eth .get_code (
806
+ keyfile_account .address , reset_tx_receipt ["blockNumber" ]
807
+ )
797
808
assert reset_code == HexBytes ("0x" )
798
809
799
810
@pytest .mark .asyncio
@@ -1881,6 +1892,10 @@ async def test_async_eth_wait_for_transaction_receipt_mined(
1881
1892
assert effective_gas_price > 0
1882
1893
1883
1894
@pytest .mark .asyncio
1895
+ # TODO: Remove xfail when issue has been identified
1896
+ @pytest .mark .xfail (
1897
+ reason = "latest geth seems to cause this to be flaky" , strict = False
1898
+ )
1884
1899
async def test_async_eth_wait_for_transaction_receipt_unmined (
1885
1900
self ,
1886
1901
async_w3 : "AsyncWeb3" ,
@@ -3855,6 +3870,8 @@ def test_sign_and_send_raw_middleware(
3855
3870
def test_sign_authorization_and_send_raw_set_code_transaction (
3856
3871
self , w3 : "Web3" , keyfile_account_pkey : HexStr , math_contract : "Contract"
3857
3872
) -> None :
3873
+ # TODO: remove blockNumber block_id from eth_call and eth_getCode calls once
3874
+ # geth behavior for "latest" seems stable again.
3858
3875
keyfile_account = w3 .eth .account .from_key (keyfile_account_pkey )
3859
3876
3860
3877
chain_id = w3 .eth .chain_id
@@ -3869,9 +3886,7 @@ def test_sign_authorization_and_send_raw_set_code_transaction(
3869
3886
3870
3887
# get current math counter and increase it only in the delegation by n
3871
3888
math_counter = math_contract .functions .counter ().call ()
3872
- data = math_contract .functions .incrementCounter (
3873
- math_counter + 1337
3874
- ).build_transaction ({})["data" ]
3889
+ data = math_contract .encode_abi ("incrementCounter" , [math_counter + 1337 ])
3875
3890
txn : TxParams = {
3876
3891
"chainId" : chain_id ,
3877
3892
"to" : keyfile_account .address ,
@@ -3887,16 +3902,26 @@ def test_sign_authorization_and_send_raw_set_code_transaction(
3887
3902
signed = keyfile_account .sign_transaction (txn )
3888
3903
tx_hash = w3 .eth .send_raw_transaction (signed .raw_transaction )
3889
3904
get_tx = w3 .eth .get_transaction (tx_hash )
3890
- w3 .eth .wait_for_transaction_receipt (tx_hash , timeout = 10 )
3905
+ receipt = w3 .eth .wait_for_transaction_receipt (tx_hash , timeout = 10 )
3891
3906
3892
- code = w3 .eth .get_code (keyfile_account .address )
3907
+ code = w3 .eth .get_code (
3908
+ keyfile_account .address , block_identifier = receipt ["blockNumber" ]
3909
+ )
3893
3910
assert code .to_0x_hex () == f"0xef0100{ math_contract .address [2 :].lower ()} "
3894
3911
delegated = w3 .eth .contract (
3895
3912
address = keyfile_account .address , abi = math_contract .abi
3896
3913
)
3897
3914
# assert the math counter is increased by 1337 only in delegated acct
3898
- assert math_contract .functions .counter ().call () == math_counter
3899
- assert delegated .functions .counter ().call () == math_counter + 1337
3915
+ assert (
3916
+ math_contract .functions .counter ().call (
3917
+ block_identifier = receipt ["blockNumber" ]
3918
+ )
3919
+ == math_counter
3920
+ )
3921
+ assert (
3922
+ delegated .functions .counter ().call (block_identifier = receipt ["blockNumber" ])
3923
+ == math_counter + 1337
3924
+ )
3900
3925
3901
3926
assert len (get_tx ["authorizationList" ]) == 1
3902
3927
get_auth = get_tx ["authorizationList" ][0 ]
@@ -3920,9 +3945,13 @@ def test_sign_authorization_and_send_raw_set_code_transaction(
3920
3945
3921
3946
signed_reset = keyfile_account .sign_transaction (new_txn )
3922
3947
reset_tx_hash = w3 .eth .send_raw_transaction (signed_reset .raw_transaction )
3923
- w3 .eth .wait_for_transaction_receipt (reset_tx_hash , timeout = 10 )
3948
+ reset_tx_receipt = w3 .eth .wait_for_transaction_receipt (
3949
+ reset_tx_hash , timeout = 10
3950
+ )
3924
3951
3925
- reset_code = w3 .eth .get_code (keyfile_account .address )
3952
+ reset_code = w3 .eth .get_code (
3953
+ keyfile_account .address , block_identifier = reset_tx_receipt ["blockNumber" ]
3954
+ )
3926
3955
assert reset_code == HexBytes ("0x" )
3927
3956
3928
3957
def test_eth_call (self , w3 : "Web3" , math_contract : "Contract" ) -> None :
0 commit comments