5555
5656class GoEthereumPersonalModuleTest :
5757 def test_personal_import_raw_key (self , w3 : "Web3" ) -> None :
58- actual = w3 .geth .personal .import_raw_key (PRIVATE_KEY_HEX , PASSWORD )
58+ with pytest .warns (DeprecationWarning ):
59+ actual = w3 .geth .personal .import_raw_key (PRIVATE_KEY_HEX , PASSWORD )
5960 assert actual == ADDRESS
6061
6162 def test_personal_list_accounts (self , w3 : "Web3" ) -> None :
62- accounts = w3 .geth .personal .list_accounts ()
63+ with pytest .warns (DeprecationWarning ):
64+ accounts = w3 .geth .personal .list_accounts ()
6365 assert is_list_like (accounts )
6466 assert len (accounts ) > 0
6567 assert all ((is_checksum_address (item ) for item in accounts ))
6668
6769 def test_personal_list_wallets (self , w3 : "Web3" ) -> None :
68- wallets = w3 .geth .personal .list_wallets ()
70+ with pytest .warns (DeprecationWarning ):
71+ wallets = w3 .geth .personal .list_wallets ()
6972 assert is_list_like (wallets )
7073 assert len (wallets ) > 0
7174 assert is_checksum_address (wallets [0 ]["accounts" ][0 ]["address" ])
@@ -76,18 +79,19 @@ def test_personal_list_wallets(self, w3: "Web3") -> None:
7679 def test_personal_lock_account (
7780 self , w3 : "Web3" , unlockable_account_dual_type : ChecksumAddress
7881 ) -> None :
79- # TODO: how do we test this better?
80- w3 .geth .personal .lock_account (unlockable_account_dual_type )
82+ with pytest . warns ( DeprecationWarning ):
83+ w3 .geth .personal .lock_account (unlockable_account_dual_type )
8184
8285 def test_personal_unlock_account_success (
8386 self ,
8487 w3 : "Web3" ,
8588 unlockable_account_dual_type : ChecksumAddress ,
8689 unlockable_account_pw : str ,
8790 ) -> None :
88- result = w3 .geth .personal .unlock_account (
89- unlockable_account_dual_type , unlockable_account_pw
90- )
91+ with pytest .warns (DeprecationWarning ):
92+ result = w3 .geth .personal .unlock_account (
93+ unlockable_account_dual_type , unlockable_account_pw
94+ )
9195 assert result is True
9296
9397 def test_personal_unlock_account_failure (
@@ -99,7 +103,8 @@ def test_personal_unlock_account_failure(
99103 )
100104
101105 def test_personal_new_account (self , w3 : "Web3" ) -> None :
102- new_account = w3 .geth .personal .new_account (PASSWORD )
106+ with pytest .warns (DeprecationWarning ):
107+ new_account = w3 .geth .personal .new_account (PASSWORD )
103108 assert is_checksum_address (new_account )
104109
105110 def test_personal_send_transaction (
@@ -118,7 +123,10 @@ def test_personal_send_transaction(
118123 "value" : Wei (1 ),
119124 "gasPrice" : w3 .to_wei (1 , "gwei" ),
120125 }
121- txn_hash = w3 .geth .personal .send_transaction (txn_params , unlockable_account_pw )
126+ with pytest .warns (DeprecationWarning ):
127+ txn_hash = w3 .geth .personal .send_transaction (
128+ txn_params , unlockable_account_pw
129+ )
122130 assert txn_hash
123131 transaction = w3 .eth .get_transaction (txn_hash )
124132
@@ -139,10 +147,13 @@ def test_personal_sign_and_ecrecover(
139147 unlockable_account_pw : str ,
140148 ) -> None :
141149 message = "test-web3-geth-personal-sign"
142- signature = w3 .geth .personal .sign (
143- message , unlockable_account_dual_type , unlockable_account_pw
144- )
145- signer = w3 .geth .personal .ec_recover (message , signature )
150+ with pytest .warns (DeprecationWarning ):
151+ signature = w3 .geth .personal .sign (
152+ message , unlockable_account_dual_type , unlockable_account_pw
153+ )
154+
155+ with pytest .warns (DeprecationWarning ):
156+ signer = w3 .geth .personal .ec_recover (message , signature )
146157 assert is_same_address (signer , unlockable_account_dual_type )
147158
148159 @pytest .mark .xfail (
@@ -193,13 +204,14 @@ def test_personal_sign_typed_data(
193204 }
194205 }
195206 """
196- signature = HexBytes (
197- w3 .geth .personal .sign_typed_data (
198- json .loads (typed_message ),
199- unlockable_account_dual_type ,
200- unlockable_account_pw ,
207+ with pytest .warns (DeprecationWarning ):
208+ signature = HexBytes (
209+ w3 .geth .personal .sign_typed_data (
210+ json .loads (typed_message ),
211+ unlockable_account_dual_type ,
212+ unlockable_account_pw ,
213+ )
201214 )
202- )
203215
204216 expected_signature = HexBytes (
205217 "0xc8b56aaeefd10ab4005c2455daf28d9082af661ac347cd"
@@ -219,33 +231,38 @@ async def test_async_sign_and_ec_recover(
219231 unlockable_account_pw : str ,
220232 ) -> None :
221233 message = "This is a test"
222- signature = await async_w3 .geth .personal .sign (
223- message , async_unlockable_account_dual_type , unlockable_account_pw
224- )
234+ with pytest .warns (DeprecationWarning ):
235+ signature = await async_w3 .geth .personal .sign (
236+ message , async_unlockable_account_dual_type , unlockable_account_pw
237+ )
225238 address = await async_w3 .geth .personal .ec_recover (message , signature )
226239 assert is_same_address (async_unlockable_account_dual_type , address )
227240
228241 @pytest .mark .asyncio
229242 async def test_async_import_key (self , async_w3 : "AsyncWeb3" ) -> None :
230- address = await async_w3 .geth .personal .import_raw_key (
231- THIRD_PRIVATE_KEY_HEX , "Testing"
232- )
243+ with pytest .warns (DeprecationWarning ):
244+ address = await async_w3 .geth .personal .import_raw_key (
245+ THIRD_PRIVATE_KEY_HEX , "Testing"
246+ )
233247 assert address is not None
234248
235249 @pytest .mark .asyncio
236250 async def test_async_list_accounts (self , async_w3 : "AsyncWeb3" ) -> None :
237- accounts = await async_w3 .geth .personal .list_accounts ()
251+ with pytest .warns (DeprecationWarning ):
252+ accounts = await async_w3 .geth .personal .list_accounts ()
238253 assert len (accounts ) > 0
239254
240255 @pytest .mark .asyncio
241256 async def test_async_list_wallets (self , async_w3 : "AsyncWeb3" ) -> None :
242- wallets = await async_w3 .geth .personal .list_wallets ()
257+ with pytest .warns (DeprecationWarning ):
258+ wallets = await async_w3 .geth .personal .list_wallets ()
243259 assert isinstance (wallets [0 ], AttributeDict )
244260
245261 @pytest .mark .asyncio
246262 async def test_async_new_account (self , async_w3 : "AsyncWeb3" ) -> None :
247263 passphrase = "Create New Account"
248- account = await async_w3 .geth .personal .new_account (passphrase )
264+ with pytest .warns (DeprecationWarning ):
265+ account = await async_w3 .geth .personal .new_account (passphrase )
249266 assert is_checksum_address (account )
250267
251268 @pytest .mark .asyncio
@@ -255,13 +272,16 @@ async def test_async_unlock_lock_account(
255272 async_unlockable_account_dual_type : ChecksumAddress ,
256273 unlockable_account_pw : str ,
257274 ) -> None :
258- unlocked = await async_w3 .geth .personal .unlock_account (
259- async_unlockable_account_dual_type , unlockable_account_pw
260- )
275+ with pytest .warns (DeprecationWarning ):
276+ unlocked = await async_w3 .geth .personal .unlock_account (
277+ async_unlockable_account_dual_type , unlockable_account_pw
278+ )
261279 assert unlocked is True
262- locked = await async_w3 .geth .personal .lock_account (
263- async_unlockable_account_dual_type
264- )
280+
281+ with pytest .warns (DeprecationWarning ):
282+ locked = await async_w3 .geth .personal .lock_account (
283+ async_unlockable_account_dual_type
284+ )
265285 assert locked is True
266286
267287 @pytest .mark .asyncio
@@ -275,9 +295,10 @@ async def test_async_send_transaction(
275295 tx_params ["to" ] = async_unlockable_account_dual_type
276296 tx_params ["from" ] = async_unlockable_account_dual_type
277297 tx_params ["value" ] = Wei (123 )
278- response = await async_w3 .geth .personal .send_transaction (
279- tx_params , unlockable_account_pw
280- )
298+ with pytest .warns (DeprecationWarning ):
299+ response = await async_w3 .geth .personal .send_transaction (
300+ tx_params , unlockable_account_pw
301+ )
281302 assert response is not None
282303
283304 @pytest .mark .xfail (
@@ -291,10 +312,12 @@ async def test_async_sign_typed_data(
291312 unlockable_account_pw : str ,
292313 ) -> None :
293314 message = {"message" : "This is a test" }
294- signature = await async_w3 .geth .personal .sign_typed_data (
295- message , async_unlockable_account_dual_type , unlockable_account_pw
296- )
297- address = await async_w3 .geth .personal .ec_recover (
298- json .dumps (message ), signature
299- )
315+ with pytest .warns (DeprecationWarning ):
316+ signature = await async_w3 .geth .personal .sign_typed_data (
317+ message , async_unlockable_account_dual_type , unlockable_account_pw
318+ )
319+ with pytest .warns (DeprecationWarning ):
320+ address = await async_w3 .geth .personal .ec_recover (
321+ json .dumps (message ), signature
322+ )
300323 assert is_same_address (async_unlockable_account_dual_type , address )
0 commit comments