Skip to content

Commit

Permalink
Merge bitcoin#29204: test: wallet migration, add coverage for tx extr…
Browse files Browse the repository at this point in the history
…a data

016cc80 test: wallet migration, add coverage for tx extra data (furszy)

Pull request description:

  Quick follow-up to bitcoin#28610, coming from 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@016cc80
  achow101:
    ACK 016cc80
  pablomartin4btc:
    ACK 016cc80
  BrandonOdiwuor:
    lgtm ACK 016cc80

Tree-SHA512: 697cabece730cbe5c5947bf98455e80a8877c0352fbe2a66362ce5ea530b67882b0bec561a67d48fee200cdad717cd62c57fd809e2a94ff83c3fad30021e1d9e
  • Loading branch information
achow101 committed Jan 10, 2024
2 parents 507dbe4 + 016cc80 commit fcacbab
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/functional/wallet_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,40 @@ def test_avoidreuse(self):
assert_equal(len(watchonly_utxos), 1)
assert_equal(watchonly_utxos[0]["reused"], True)

def test_preserve_tx_extra_info(self):
self.log.info("Test that tx extra data is preserved after migration")
def_wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name)

# Create and fund wallet
wallet = self.create_legacy_wallet("persist_comments")
def_wallet.sendtoaddress(wallet.getnewaddress(), 2)

self.generate(self.nodes[0], 6)

# Create tx and bump it to store 'replaced_by_txid' and 'replaces_txid' data within the transactions.
# Additionally, store an extra comment within the original tx.
extra_comment = "don't discard me"
original_tx_id = wallet.sendtoaddress(address=wallet.getnewaddress(), amount=1, comment=extra_comment)
bumped_tx = wallet.bumpfee(txid=original_tx_id)

def check_comments():
for record in wallet.listtransactions():
if record["txid"] == original_tx_id:
assert_equal(record["replaced_by_txid"], bumped_tx["txid"])
assert_equal(record['comment'], extra_comment)
elif record["txid"] == bumped_tx["txid"]:
assert_equal(record["replaces_txid"], original_tx_id)

# Pre-migration verification
check_comments()
# Migrate
wallet.migratewallet()
# Post-migration verification
check_comments()

wallet.unloadwallet()


def run_test(self):
self.generate(self.nodes[0], 101)

Expand All @@ -952,6 +986,7 @@ def run_test(self):
self.test_hybrid_pubkey()
self.test_failed_migration_cleanup()
self.test_avoidreuse()
self.test_preserve_tx_extra_info()

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

0 comments on commit fcacbab

Please sign in to comment.