6
6
7
7
import random
8
8
import shutil
9
+ import time
10
+
9
11
from test_framework .address import (
10
12
script_to_p2sh ,
11
13
key_to_p2pkh ,
@@ -311,12 +313,17 @@ def test_other_watchonly(self):
311
313
sent_watchonly_txid = send ["txid" ]
312
314
313
315
self .generate (self .nodes [0 ], 1 )
316
+ received_watchonly_tx_info = imports0 .gettransaction (received_watchonly_txid , True )
317
+ received_sent_watchonly_tx_info = imports0 .gettransaction (received_sent_watchonly_txid , True )
314
318
315
319
balances = imports0 .getbalances ()
316
320
spendable_bal = balances ["mine" ]["trusted" ]
317
321
watchonly_bal = balances ["watchonly" ]["trusted" ]
318
322
assert_equal (len (imports0 .listtransactions (include_watchonly = True )), 4 )
319
323
324
+ # Mock time forward a bit so we can check that tx metadata is preserved
325
+ self .nodes [0 ].setmocktime (int (time .time ()) + 100 )
326
+
320
327
# Migrate
321
328
imports0 .migratewallet ()
322
329
assert_equal (imports0 .getwalletinfo ()["descriptors" ], True )
@@ -334,8 +341,12 @@ def test_other_watchonly(self):
334
341
assert_equal (watchonly_info ["descriptors" ], True )
335
342
self .assert_is_sqlite ("imports0_watchonly" )
336
343
assert_equal (watchonly_info ["private_keys_enabled" ], False )
337
- watchonly .gettransaction (received_watchonly_txid )
338
- watchonly .gettransaction (received_sent_watchonly_txid )
344
+ received_migrated_watchonly_tx_info = watchonly .gettransaction (received_watchonly_txid )
345
+ assert_equal (received_watchonly_tx_info ["time" ], received_migrated_watchonly_tx_info ["time" ])
346
+ assert_equal (received_watchonly_tx_info ["timereceived" ], received_migrated_watchonly_tx_info ["timereceived" ])
347
+ received_sent_migrated_watchonly_tx_info = watchonly .gettransaction (received_sent_watchonly_txid )
348
+ assert_equal (received_sent_watchonly_tx_info ["time" ], received_sent_migrated_watchonly_tx_info ["time" ])
349
+ assert_equal (received_sent_watchonly_tx_info ["timereceived" ], received_sent_migrated_watchonly_tx_info ["timereceived" ])
339
350
watchonly .gettransaction (sent_watchonly_txid )
340
351
assert_equal (watchonly .getbalance (), watchonly_bal )
341
352
assert_raises_rpc_error (- 5 , "Invalid or non-wallet transaction id" , watchonly .gettransaction , received_txid )
0 commit comments