@@ -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,27 @@ 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 , web3 : "Web3" , unlocked_account : ChecksumAddress ) -> None :
539+ txn_params : TxParams = {
540+ 'from' : unlocked_account ,
541+ 'to' : unlocked_account ,
542+ 'value' : Wei (1 ),
543+ 'gas' : Wei (21000 ),
544+ 'gasPrice' : web3 .eth .gas_price ,
545+ 'nonce' : Nonce (0 ),
546+ }
547+ with pytest .warns (DeprecationWarning ,
548+ match = 'signTransaction is deprecated in favor of sign_transaction' ):
549+ result = web3 .eth .signTransaction (txn_params )
550+ signatory_account = web3 .eth .account .recover_transaction (result ['raw' ])
551+ assert unlocked_account == signatory_account
552+ assert result ['tx' ]['to' ] == txn_params ['to' ]
553+ assert result ['tx' ]['value' ] == txn_params ['value' ]
554+ assert result ['tx' ]['gas' ] == txn_params ['gas' ]
555+ assert result ['tx' ]['gasPrice' ] == txn_params ['gasPrice' ]
556+ assert result ['tx' ]['nonce' ] == txn_params ['nonce' ]
557+
558+ def test_eth_sign_transaction_ens_names (
539559 self , web3 : "Web3" , unlocked_account : ChecksumAddress
540560 ) -> None :
541561 with ens_addresses (web3 , {'unlocked-account.eth' : unlocked_account }):
@@ -547,7 +567,7 @@ def test_eth_signTransaction_ens_names(
547567 'gasPrice' : web3 .eth .gas_price ,
548568 'nonce' : Nonce (0 ),
549569 }
550- result = web3 .eth .signTransaction (txn_params )
570+ result = web3 .eth .sign_transaction (txn_params )
551571 signatory_account = web3 .eth .account .recover_transaction (result ['raw' ])
552572 assert unlocked_account == signatory_account
553573 assert result ['tx' ]['to' ] == unlocked_account
0 commit comments