Skip to content

Commit

Permalink
test: Check tx metadata is migrated to watchonly
Browse files Browse the repository at this point in the history
  • Loading branch information
achow101 committed Oct 17, 2023
1 parent 197a625 commit 13dd5e5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/functional/wallet_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import random
import shutil
import struct
import time

from test_framework.address import (
script_to_p2sh,
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 13dd5e5

Please sign in to comment.