Skip to content

Commit 724f7e7

Browse files
committed
update 7702 test to test both send and send raw tx
1 parent 502939b commit 724f7e7

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

web3/_utils/module_testing/eth_module.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
)
3838
from eth_utils.toolz import (
3939
assoc,
40+
merge,
4041
)
4142
from hexbytes import (
4243
HexBytes,
@@ -717,7 +718,7 @@ async def test_async_sign_and_send_raw_middleware(
717718
async_w3.middleware_onion.remove("signing")
718719

719720
@pytest.mark.asyncio
720-
async def test_async_sign_authorization_and_send_raw_set_code_transaction(
721+
async def test_async_sign_authorization_send_raw_and_send_set_code_transactions(
721722
self,
722723
async_w3: "AsyncWeb3",
723724
keyfile_account_pkey: HexStr,
@@ -752,6 +753,7 @@ async def test_async_sign_authorization_and_send_raw_set_code_transaction(
752753
"authorizationList": [signed_auth],
753754
}
754755

756+
# test eth_sendRawTransaction
755757
signed = keyfile_account.sign_transaction(txn)
756758
tx_hash = await async_w3.eth.send_raw_transaction(signed.raw_transaction)
757759
get_tx = await async_w3.eth.get_transaction(tx_hash)
@@ -790,14 +792,17 @@ async def test_async_sign_authorization_and_send_raw_set_code_transaction(
790792
"nonce": nonce + 3,
791793
}
792794
signed_reset_auth = keyfile_account.sign_authorization(reset_auth)
793-
new_txn = dict(txn)
794-
new_txn["authorizationList"] = [signed_reset_auth]
795-
new_txn["nonce"] = nonce + 2
796-
797-
signed_reset = keyfile_account.sign_transaction(new_txn)
798-
reset_tx_hash = await async_w3.eth.send_raw_transaction(
799-
signed_reset.raw_transaction
795+
reset_code_txn = merge(
796+
txn,
797+
{
798+
"from": keyfile_account.address,
799+
"authorizationList": [signed_reset_auth],
800+
"nonce": nonce + 2,
801+
},
800802
)
803+
804+
# test eth_sendTransaction
805+
reset_tx_hash = await async_w3.eth.send_transaction(reset_code_txn)
801806
reset_tx_receipt = await async_w3.eth.wait_for_transaction_receipt(
802807
reset_tx_hash, timeout=10
803808
)
@@ -3867,7 +3872,7 @@ def test_sign_and_send_raw_middleware(
38673872
# cleanup
38683873
w3.middleware_onion.remove("signing")
38693874

3870-
def test_sign_authorization_and_send_raw_set_code_transaction(
3875+
def test_sign_authorization_send_raw_and_send_set_code_transactions(
38713876
self, w3: "Web3", keyfile_account_pkey: HexStr, math_contract: "Contract"
38723877
) -> None:
38733878
# TODO: remove blockNumber block_id from eth_call and eth_getCode calls once
@@ -3899,6 +3904,7 @@ def test_sign_authorization_and_send_raw_set_code_transaction(
38993904
"authorizationList": [signed_auth],
39003905
}
39013906

3907+
# test eth_sendRawTransaction
39023908
signed = keyfile_account.sign_transaction(txn)
39033909
tx_hash = w3.eth.send_raw_transaction(signed.raw_transaction)
39043910
get_tx = w3.eth.get_transaction(tx_hash)
@@ -3939,12 +3945,17 @@ def test_sign_authorization_and_send_raw_set_code_transaction(
39393945
"nonce": nonce + 3,
39403946
}
39413947
signed_reset_auth = keyfile_account.sign_authorization(reset_auth)
3942-
new_txn = dict(txn)
3943-
new_txn["authorizationList"] = [signed_reset_auth]
3944-
new_txn["nonce"] = nonce + 2
3948+
reset_code_txn = merge(
3949+
txn,
3950+
{
3951+
"from": keyfile_account.address,
3952+
"authorizationList": [signed_reset_auth],
3953+
"nonce": nonce + 2,
3954+
},
3955+
)
39453956

3946-
signed_reset = keyfile_account.sign_transaction(new_txn)
3947-
reset_tx_hash = w3.eth.send_raw_transaction(signed_reset.raw_transaction)
3957+
# test eth_sendTransaction
3958+
reset_tx_hash = w3.eth.send_transaction(reset_code_txn)
39483959
reset_tx_receipt = w3.eth.wait_for_transaction_receipt(
39493960
reset_tx_hash, timeout=10
39503961
)

0 commit comments

Comments
 (0)