Skip to content

Commit b927000

Browse files
committed
test: Check tx metadata is migrated to watchonly
1 parent b09e568 commit b927000

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/functional/wallet_migration.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import random
88
import shutil
99
import struct
10+
import time
1011

1112
from 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

Comments
 (0)