From 4814e4063e674ad9b0a5c7e56059cd6a2bf9b764 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Fri, 6 Oct 2023 17:16:39 -0400 Subject: [PATCH] test: Check tx metadata is migrated to watchonly --- test/functional/wallet_migration.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/functional/wallet_migration.py b/test/functional/wallet_migration.py index ad8dbe78edb83..aede9281d5679 100755 --- a/test/functional/wallet_migration.py +++ b/test/functional/wallet_migration.py @@ -7,6 +7,7 @@ import random import shutil import struct +import time from test_framework.address import ( script_to_p2sh, @@ -315,12 +316,17 @@ def test_other_watchonly(self): sent_watchonly_txid = send["txid"] self.generate(self.nodes[0], 1) + received_watchonly_tx_info = imports0.gettransaction(received_watchonly_txid, True) + received_sent_watchonly_tx_info = imports0.gettransaction(received_sent_watchonly_txid, True) balances = imports0.getbalances() spendable_bal = balances["mine"]["trusted"] watchonly_bal = balances["watchonly"]["trusted"] assert_equal(len(imports0.listtransactions(include_watchonly=True)), 4) + # Mock time forward a bit so we can check that tx metadata is preserved + self.nodes[0].setmocktime(int(time.time()) + 100) + # Migrate imports0.migratewallet() assert_equal(imports0.getwalletinfo()["descriptors"], True) @@ -338,8 +344,12 @@ def test_other_watchonly(self): assert_equal(watchonly_info["descriptors"], True) self.assert_is_sqlite("imports0_watchonly") assert_equal(watchonly_info["private_keys_enabled"], False) - watchonly.gettransaction(received_watchonly_txid) - watchonly.gettransaction(received_sent_watchonly_txid) + received_migrated_watchonly_tx_info = watchonly.gettransaction(received_watchonly_txid) + assert_equal(received_watchonly_tx_info["time"], received_migrated_watchonly_tx_info["time"]) + assert_equal(received_watchonly_tx_info["timereceived"], received_migrated_watchonly_tx_info["timereceived"]) + received_sent_migrated_watchonly_tx_info = watchonly.gettransaction(received_sent_watchonly_txid) + assert_equal(received_sent_watchonly_tx_info["time"], received_sent_migrated_watchonly_tx_info["time"]) + assert_equal(received_sent_watchonly_tx_info["timereceived"], received_sent_migrated_watchonly_tx_info["timereceived"]) watchonly.gettransaction(sent_watchonly_txid) assert_equal(watchonly.getbalance(), watchonly_bal) assert_raises_rpc_error(-5, "Invalid or non-wallet transaction id", watchonly.gettransaction, received_txid)