Skip to content

Commit fcacbab

Browse files
committed
Merge bitcoin/bitcoin#29204: test: wallet migration, add coverage for tx extra data
016cc80 test: wallet migration, add coverage for tx extra data (furszy) Pull request description: Quick follow-up to #28610, coming from bitcoin/bitcoin#28610 (review). Verifying that the 'replaced_by_txid' and 'replaces_txid' tx data is preserved after migration, as well as the extra tx comments. ACKs for top commit: jamesob: Nice, ACK bitcoin/bitcoin@016cc80 achow101: ACK 016cc80 pablomartin4btc: ACK 016cc80 BrandonOdiwuor: lgtm ACK 016cc80 Tree-SHA512: 697cabece730cbe5c5947bf98455e80a8877c0352fbe2a66362ce5ea530b67882b0bec561a67d48fee200cdad717cd62c57fd809e2a94ff83c3fad30021e1d9e
2 parents 507dbe4 + 016cc80 commit fcacbab

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/functional/wallet_migration.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,40 @@ def test_avoidreuse(self):
932932
assert_equal(len(watchonly_utxos), 1)
933933
assert_equal(watchonly_utxos[0]["reused"], True)
934934

935+
def test_preserve_tx_extra_info(self):
936+
self.log.info("Test that tx extra data is preserved after migration")
937+
def_wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name)
938+
939+
# Create and fund wallet
940+
wallet = self.create_legacy_wallet("persist_comments")
941+
def_wallet.sendtoaddress(wallet.getnewaddress(), 2)
942+
943+
self.generate(self.nodes[0], 6)
944+
945+
# Create tx and bump it to store 'replaced_by_txid' and 'replaces_txid' data within the transactions.
946+
# Additionally, store an extra comment within the original tx.
947+
extra_comment = "don't discard me"
948+
original_tx_id = wallet.sendtoaddress(address=wallet.getnewaddress(), amount=1, comment=extra_comment)
949+
bumped_tx = wallet.bumpfee(txid=original_tx_id)
950+
951+
def check_comments():
952+
for record in wallet.listtransactions():
953+
if record["txid"] == original_tx_id:
954+
assert_equal(record["replaced_by_txid"], bumped_tx["txid"])
955+
assert_equal(record['comment'], extra_comment)
956+
elif record["txid"] == bumped_tx["txid"]:
957+
assert_equal(record["replaces_txid"], original_tx_id)
958+
959+
# Pre-migration verification
960+
check_comments()
961+
# Migrate
962+
wallet.migratewallet()
963+
# Post-migration verification
964+
check_comments()
965+
966+
wallet.unloadwallet()
967+
968+
935969
def run_test(self):
936970
self.generate(self.nodes[0], 101)
937971

@@ -952,6 +986,7 @@ def run_test(self):
952986
self.test_hybrid_pubkey()
953987
self.test_failed_migration_cleanup()
954988
self.test_avoidreuse()
989+
self.test_preserve_tx_extra_info()
955990

956991
if __name__ == '__main__':
957992
WalletMigrationTest().main()

0 commit comments

Comments
 (0)