diff options
author | Andrew Chow <github@achow101.com> | 2022-11-14 16:02:36 -0500 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-01-10 18:25:20 -0500 |
commit | b0fa5989e1b77a343349bd36f8bc407f9366a589 (patch) | |
tree | ab3b6480583d982a6d00f2bf2693b3d3f7bc4c92 /test/functional/wallet_orphanedreward.py | |
parent | 9addbd78901124a48fd41a82a9557fcf3490191d (diff) | |
download | bitcoin-b0fa5989e1b77a343349bd36f8bc407f9366a589.tar.xz |
test: Check that orphaned coinbase unconf spend is still abandoned
When an orphaned coinbase is reorged back into the main chain, any
unconfirmed ancestors should still be marked as abandoned due to the
original reorg that orphaned that coinbase.
Diffstat (limited to 'test/functional/wallet_orphanedreward.py')
-rwxr-xr-x | test/functional/wallet_orphanedreward.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/test/functional/wallet_orphanedreward.py b/test/functional/wallet_orphanedreward.py index 37f3992936..a617abae83 100755 --- a/test/functional/wallet_orphanedreward.py +++ b/test/functional/wallet_orphanedreward.py @@ -31,19 +31,40 @@ class OrphanedBlockRewardTest(BitcoinTestFramework): # the existing balance and the block reward. self.generate(self.nodes[0], 150) assert_equal(self.nodes[1].getbalance(), 10 + 25) + pre_reorg_conf_bals = self.nodes[1].getbalances() txid = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 30) + orig_chain_tip = self.nodes[0].getbestblockhash() + self.sync_mempools() # Orphan the block reward and make sure that the original coins # from the wallet can still be spent. self.nodes[0].invalidateblock(blk) - self.generate(self.nodes[0], 152) + blocks = self.generate(self.nodes[0], 152) + conflict_block = blocks[0] # We expect the descendants of orphaned rewards to no longer be considered assert_equal(self.nodes[1].getbalances()["mine"], { "trusted": 10, "untrusted_pending": 0, "immature": 0, }) - self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 9) + # And the unconfirmed tx to be abandoned + assert_equal(self.nodes[1].gettransaction(txid)["details"][0]["abandoned"], True) + + # The abandoning should persist through reloading + self.nodes[1].unloadwallet(self.default_wallet_name) + self.nodes[1].loadwallet(self.default_wallet_name) + assert_equal(self.nodes[1].gettransaction(txid)["details"][0]["abandoned"], True) + + # If the orphaned reward is reorged back into the main chain, any unconfirmed + # descendant txs at the time of the original reorg remain abandoned. + self.nodes[0].invalidateblock(conflict_block) + self.nodes[0].reconsiderblock(blk) + assert_equal(self.nodes[0].getbestblockhash(), orig_chain_tip) + self.generate(self.nodes[0], 3) + + assert_equal(self.nodes[1].getbalances(), pre_reorg_conf_bals) + assert_equal(self.nodes[1].gettransaction(txid)["details"][0]["abandoned"], True) + if __name__ == '__main__': OrphanedBlockRewardTest().main() |