diff --git a/test/functional/abandonconflict.py b/test/functional/abandonconflict.py --- a/test/functional/abandonconflict.py +++ b/test/functional/abandonconflict.py @@ -67,7 +67,9 @@ # Create a child tx spending AB1 and C inputs = [] + # Amount 14.99998 BCH inputs.append({"txid": txAB1, "vout": nAB}) + # Amount 10 BCH inputs.append({"txid": txC, "vout": nC}) outputs = {} outputs[self.nodes[0].getnewaddress()] = Decimal("24.9996") @@ -89,16 +91,18 @@ assert_equal(len(self.nodes[0].getrawmempool()), 0) assert_equal(len(self.nodes[1].getrawmempool()), 0) - # Not in mempool txs from self should only reduce balance - # inputs are still spent, but change not received + # Transactions which are not in the mempool should only reduce wallet balance. + # Transaction inputs should still be spent, but the change not yet received. newbalance = self.nodes[0].getbalance() assert_equal(newbalance, balance - Decimal("24.9996")) - # Unconfirmed received funds that are not in mempool, also shouldn't show - # up in unconfirmed balance + # Unconfirmed received funds that are not in mempool also shouldn't show + # up in unconfirmed balance. Note that the transactions stored in the wallet + # are not necessarily in the node's mempool. unconfbalance = self.nodes[0].getunconfirmedbalance( ) + self.nodes[0].getbalance() assert_equal(unconfbalance, newbalance) - # Also shouldn't show up in listunspent + # Unconfirmed transactions which are not in the mempool should also + # not be in listunspent assert(not txABC2 in [utxo["txid"] for utxo in self.nodes[0].listunspent(0)]) balance = newbalance @@ -110,28 +114,31 @@ assert_equal(newbalance, balance + Decimal("30")) balance = newbalance - # Verify that even with a low min relay fee, the tx is not reaccepted from wallet on startup once abandoned + # Verify that even with a low min relay fee, the tx is not re-accepted + # from wallet on startup once abandoned. self.stop_node(0) self.start_node(0, extra_args=["-minrelaytxfee=0.00001"]) assert_equal(len(self.nodes[0].getrawmempool()), 0) assert_equal(self.nodes[0].getbalance(), balance) - # But if its received again then it is unabandoned - # And since now in mempool, the change is available - # But its child tx remains abandoned + # If the transaction is re-sent the wallet also unabandons it. The + # change should be available, and it's child transaction should remain + # abandoned. + # NOTE: Abandoned transactions are internal to the wallet, and tracked + # separately from other indices. self.nodes[0].sendrawtransaction(signed["hex"]) newbalance = self.nodes[0].getbalance() assert_equal(newbalance, balance - Decimal("20") + Decimal("14.99998")) balance = newbalance - # Send child tx again so its unabandoned + # Send child tx again so it is not longer abandoned. self.nodes[0].sendrawtransaction(signed2["hex"]) newbalance = self.nodes[0].getbalance() assert_equal(newbalance, balance - Decimal("10") - Decimal("14.99998") + Decimal("24.9996")) balance = newbalance - # Remove using high relay fee again + # Reset to a higher relay fee so that we abandon a transaction self.stop_node(0) self.start_node(0, extra_args=["-minrelaytxfee=0.0001"]) assert_equal(len(self.nodes[0].getrawmempool()), 0) @@ -139,8 +146,8 @@ assert_equal(newbalance, balance - Decimal("24.9996")) balance = newbalance - # Create a double spend of AB1 by spending again from only A's 10 output - # Mine double spend from node 1 + # Create a double spend of AB1. Spend it again from only A's 10 output. + # Mine double spend from node 1. inputs = [] inputs.append({"txid": txA, "vout": nA}) outputs = {}