@@ -517,7 +517,7 @@ def test_invalid_eth_signTypedData(
517517 json .loads (invalid_typed_message )
518518 )
519519
520- def test_eth_signTransaction (self , web3 : "Web3" , unlocked_account : ChecksumAddress ) -> None :
520+ def test_eth_sign_transaction (self , web3 : "Web3" , unlocked_account : ChecksumAddress ) -> None :
521521 txn_params : TxParams = {
522522 'from' : unlocked_account ,
523523 'to' : unlocked_account ,
@@ -526,7 +526,7 @@ def test_eth_signTransaction(self, web3: "Web3", unlocked_account: ChecksumAddre
526526 'gasPrice' : web3 .eth .gas_price ,
527527 'nonce' : Nonce (0 ),
528528 }
529- result = web3 .eth .signTransaction (txn_params )
529+ result = web3 .eth .sign_transaction (txn_params )
530530 signatory_account = web3 .eth .account .recover_transaction (result ['raw' ])
531531 assert unlocked_account == signatory_account
532532 assert result ['tx' ]['to' ] == txn_params ['to' ]
@@ -535,7 +535,29 @@ def test_eth_signTransaction(self, web3: "Web3", unlocked_account: ChecksumAddre
535535 assert result ['tx' ]['gasPrice' ] == txn_params ['gasPrice' ]
536536 assert result ['tx' ]['nonce' ] == txn_params ['nonce' ]
537537
538- def test_eth_signTransaction_ens_names (
538+ def test_eth_signTransaction_deprecated (self ,
539+ web3 : "Web3" ,
540+ unlocked_account : ChecksumAddress ) -> None :
541+ txn_params : TxParams = {
542+ 'from' : unlocked_account ,
543+ 'to' : unlocked_account ,
544+ 'value' : Wei (1 ),
545+ 'gas' : Wei (21000 ),
546+ 'gasPrice' : web3 .eth .gas_price ,
547+ 'nonce' : Nonce (0 ),
548+ }
549+ with pytest .warns (DeprecationWarning ,
550+ match = 'signTransaction is deprecated in favor of sign_transaction' ):
551+ result = web3 .eth .signTransaction (txn_params )
552+ signatory_account = web3 .eth .account .recover_transaction (result ['raw' ])
553+ assert unlocked_account == signatory_account
554+ assert result ['tx' ]['to' ] == txn_params ['to' ]
555+ assert result ['tx' ]['value' ] == txn_params ['value' ]
556+ assert result ['tx' ]['gas' ] == txn_params ['gas' ]
557+ assert result ['tx' ]['gasPrice' ] == txn_params ['gasPrice' ]
558+ assert result ['tx' ]['nonce' ] == txn_params ['nonce' ]
559+
560+ def test_eth_sign_transaction_ens_names (
539561 self , web3 : "Web3" , unlocked_account : ChecksumAddress
540562 ) -> None :
541563 with ens_addresses (web3 , {'unlocked-account.eth' : unlocked_account }):
@@ -547,7 +569,7 @@ def test_eth_signTransaction_ens_names(
547569 'gasPrice' : web3 .eth .gas_price ,
548570 'nonce' : Nonce (0 ),
549571 }
550- result = web3 .eth .signTransaction (txn_params )
572+ result = web3 .eth .sign_transaction (txn_params )
551573 signatory_account = web3 .eth .account .recover_transaction (result ['raw' ])
552574 assert unlocked_account == signatory_account
553575 assert result ['tx' ]['to' ] == unlocked_account
0 commit comments