Skip to content

Commit deb0b31

Browse files
committed
test: Check tx metadata is migrated to watchonly
1 parent 6eb3df7 commit deb0b31

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/functional/wallet_migration.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import random
88
import shutil
9+
import time
10+
911
from test_framework.address import (
1012
script_to_p2sh,
1113
key_to_p2pkh,
@@ -311,12 +313,17 @@ def test_other_watchonly(self):
311313
sent_watchonly_txid = send["txid"]
312314

313315
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)
314318

315319
balances = imports0.getbalances()
316320
spendable_bal = balances["mine"]["trusted"]
317321
watchonly_bal = balances["watchonly"]["trusted"]
318322
assert_equal(len(imports0.listtransactions(include_watchonly=True)), 4)
319323

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+
320327
# Migrate
321328
imports0.migratewallet()
322329
assert_equal(imports0.getwalletinfo()["descriptors"], True)
@@ -334,8 +341,12 @@ def test_other_watchonly(self):
334341
assert_equal(watchonly_info["descriptors"], True)
335342
self.assert_is_sqlite("imports0_watchonly")
336343
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"])
339350
watchonly.gettransaction(sent_watchonly_txid)
340351
assert_equal(watchonly.getbalance(), watchonly_bal)
341352
assert_raises_rpc_error(-5, "Invalid or non-wallet transaction id", watchonly.gettransaction, received_txid)

0 commit comments

Comments
 (0)