Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_abandonconflict.py
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# In mempool txs from self should increase balance from change | # In mempool txs from self should increase balance from change | ||||
newbalance = self.nodes[0].getbalance() | newbalance = self.nodes[0].getbalance() | ||||
assert_equal(newbalance, balance - Decimal("30") + signed3_change) | assert_equal(newbalance, balance - Decimal("30") + signed3_change) | ||||
balance = newbalance | balance = newbalance | ||||
# Restart the node with a higher min relay fee so the parent tx is no longer in mempool | # Restart the node with a higher min relay fee so the parent tx is no longer in mempool | ||||
# TODO: redo with eviction | # TODO: redo with eviction | ||||
self.stop_node(0) | self.restart_node(0, extra_args=["-minrelaytxfee=0.0001"]) | ||||
self.start_node(0, extra_args=["-minrelaytxfee=0.0001"]) | |||||
assert self.nodes[0].getmempoolinfo()['loaded'] | assert self.nodes[0].getmempoolinfo()['loaded'] | ||||
# Verify txs no longer in either node's mempool | # Verify txs no longer in either node's mempool | ||||
assert_equal(len(self.nodes[0].getrawmempool()), 0) | assert_equal(len(self.nodes[0].getrawmempool()), 0) | ||||
assert_equal(len(self.nodes[1].getrawmempool()), 0) | assert_equal(len(self.nodes[1].getrawmempool()), 0) | ||||
# Transactions which are not in the mempool should only reduce wallet balance. | # Transactions which are not in the mempool should only reduce wallet balance. | ||||
# Transaction inputs should still be spent, but the change not yet | # Transaction inputs should still be spent, but the change not yet | ||||
Show All 18 Lines | def run_test(self): | ||||
# including that the child tx was also abandoned | # including that the child tx was also abandoned | ||||
self.nodes[0].abandontransaction(txAB1) | self.nodes[0].abandontransaction(txAB1) | ||||
newbalance = self.nodes[0].getbalance() | newbalance = self.nodes[0].getbalance() | ||||
assert_equal(newbalance, balance + Decimal("30")) | assert_equal(newbalance, balance + Decimal("30")) | ||||
balance = newbalance | balance = newbalance | ||||
# Verify that even with a low min relay fee, the tx is not re-accepted | # Verify that even with a low min relay fee, the tx is not re-accepted | ||||
# from wallet on startup once abandoned. | # from wallet on startup once abandoned. | ||||
self.stop_node(0) | self.restart_node(0, extra_args=["-minrelaytxfee=0.00001"]) | ||||
self.start_node(0, extra_args=["-minrelaytxfee=0.00001"]) | |||||
assert self.nodes[0].getmempoolinfo()['loaded'] | assert self.nodes[0].getmempoolinfo()['loaded'] | ||||
assert_equal(len(self.nodes[0].getrawmempool()), 0) | assert_equal(len(self.nodes[0].getrawmempool()), 0) | ||||
assert_equal(self.nodes[0].getbalance(), balance) | assert_equal(self.nodes[0].getbalance(), balance) | ||||
# If the transaction is re-sent the wallet also unabandons it. The | # If the transaction is re-sent the wallet also unabandons it. The | ||||
# change should be available, and it's child transaction should remain | # change should be available, and it's child transaction should remain | ||||
# abandoned. | # abandoned. | ||||
# NOTE: Abandoned transactions are internal to the wallet, and tracked | # NOTE: Abandoned transactions are internal to the wallet, and tracked | ||||
# separately from other indices. | # separately from other indices. | ||||
self.nodes[0].sendrawtransaction(signed["hex"]) | self.nodes[0].sendrawtransaction(signed["hex"]) | ||||
newbalance = self.nodes[0].getbalance() | newbalance = self.nodes[0].getbalance() | ||||
assert_equal(newbalance, balance - Decimal("20") + Decimal("14.99998")) | assert_equal(newbalance, balance - Decimal("20") + Decimal("14.99998")) | ||||
balance = newbalance | balance = newbalance | ||||
# Send child tx again so it is no longer abandoned. | # Send child tx again so it is no longer abandoned. | ||||
self.nodes[0].sendrawtransaction(signed2["hex"]) | self.nodes[0].sendrawtransaction(signed2["hex"]) | ||||
newbalance = self.nodes[0].getbalance() | newbalance = self.nodes[0].getbalance() | ||||
assert_equal(newbalance, balance - Decimal("10") | assert_equal(newbalance, balance - Decimal("10") | ||||
- Decimal("14.99998") + Decimal("24.9996")) | - Decimal("14.99998") + Decimal("24.9996")) | ||||
balance = newbalance | balance = newbalance | ||||
# Reset to a higher relay fee so that we abandon a transaction | # Reset to a higher relay fee so that we abandon a transaction | ||||
self.stop_node(0) | self.restart_node(0, extra_args=["-minrelaytxfee=0.0001"]) | ||||
self.start_node(0, extra_args=["-minrelaytxfee=0.0001"]) | |||||
assert self.nodes[0].getmempoolinfo()['loaded'] | assert self.nodes[0].getmempoolinfo()['loaded'] | ||||
assert_equal(len(self.nodes[0].getrawmempool()), 0) | assert_equal(len(self.nodes[0].getrawmempool()), 0) | ||||
newbalance = self.nodes[0].getbalance() | newbalance = self.nodes[0].getbalance() | ||||
assert_equal(newbalance, balance - Decimal("24.9996")) | assert_equal(newbalance, balance - Decimal("24.9996")) | ||||
balance = newbalance | balance = newbalance | ||||
# Create a double spend of AB1. Spend it again from only A's 10 output. | # Create a double spend of AB1. Spend it again from only A's 10 output. | ||||
# Mine double spend from node 1. | # Mine double spend from node 1. | ||||
Show All 33 Lines |