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