Merge bitcoin/bitcoin#29204: test: wallet migration, add coverage for tx extra data

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

Pull request description:

  Quick follow-up to #28610, coming from https://github.com/bitcoin/bitcoin/pull/28610#pullrequestreview-1802823938.

  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 016cc807f7
  achow101:
    ACK 016cc807f7
  pablomartin4btc:
    ACK 016cc807f7
  BrandonOdiwuor:
    lgtm ACK 016cc807f7

Tree-SHA512: 697cabece730cbe5c5947bf98455e80a8877c0352fbe2a66362ce5ea530b67882b0bec561a67d48fee200cdad717cd62c57fd809e2a94ff83c3fad30021e1d9e
This commit is contained in:
Ava Chow 2024-01-10 14:29:28 -05:00
commit fcacbab487
No known key found for this signature in database
GPG Key ID: 17565732E08E5E41
1 changed files with 35 additions and 0 deletions

View File

@ -932,6 +932,40 @@ class WalletMigrationTest(BitcoinTestFramework):
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)
@ -952,6 +986,7 @@ class WalletMigrationTest(BitcoinTestFramework):
self.test_hybrid_pubkey()
self.test_failed_migration_cleanup()
self.test_avoidreuse()
self.test_preserve_tx_extra_info()
if __name__ == '__main__':
WalletMigrationTest().main()