diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2024-01-03 15:53:40 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2024-01-08 12:04:31 -0300 |
commit | 016cc807f77a9128d430a0df1edd133521628a33 (patch) | |
tree | ecfb4bb2c32407645f477164c8694da7714330d7 /test/functional/wallet_migration.py | |
parent | c2d04f1319a6af6140d17339c4814e0cfc605dd2 (diff) | |
download | bitcoin-016cc807f77a9128d430a0df1edd133521628a33.tar.xz |
test: wallet migration, add coverage for tx extra data
Verifying that the 'replaced_by_txid' and 'replaces_txid'
tx data is preserved after migration, as well as the
extra tx comments.
Diffstat (limited to 'test/functional/wallet_migration.py')
-rwxr-xr-x | test/functional/wallet_migration.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/functional/wallet_migration.py b/test/functional/wallet_migration.py index b171673be5..3d68dbe07a 100755 --- a/test/functional/wallet_migration.py +++ b/test/functional/wallet_migration.py @@ -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() |