77import random
88import shutil
99import struct
10+ import time
1011
1112from test_framework .address import (
1213 script_to_p2sh ,
@@ -315,12 +316,17 @@ def test_other_watchonly(self):
315316 sent_watchonly_txid = send ["txid" ]
316317
317318 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 )
318321
319322 balances = imports0 .getbalances ()
320323 spendable_bal = balances ["mine" ]["trusted" ]
321324 watchonly_bal = balances ["watchonly" ]["trusted" ]
322325 assert_equal (len (imports0 .listtransactions (include_watchonly = True )), 4 )
323326
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+
324330 # Migrate
325331 imports0 .migratewallet ()
326332 assert_equal (imports0 .getwalletinfo ()["descriptors" ], True )
@@ -338,8 +344,12 @@ def test_other_watchonly(self):
338344 assert_equal (watchonly_info ["descriptors" ], True )
339345 self .assert_is_sqlite ("imports0_watchonly" )
340346 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" ])
343353 watchonly .gettransaction (sent_watchonly_txid )
344354 assert_equal (watchonly .getbalance (), watchonly_bal )
345355 assert_raises_rpc_error (- 5 , "Invalid or non-wallet transaction id" , watchonly .gettransaction , received_txid )
0 commit comments