Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_abandonconflict.py
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Can not abandon confirmed transaction | # Can not abandon confirmed transaction | ||||
assert_raises_rpc_error(-5, 'Transaction not eligible for abandonment', | assert_raises_rpc_error(-5, 'Transaction not eligible for abandonment', | ||||
lambda: self.nodes[0].abandontransaction(txid=txA)) | lambda: self.nodes[0].abandontransaction(txid=txA)) | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
newbalance = self.nodes[0].getbalance() | newbalance = self.nodes[0].getbalance() | ||||
# no more than fees lost | # no more than fees lost | ||||
assert(balance - newbalance <= total_fees(txA, txB, txC)) | assert balance - newbalance <= total_fees(txA, txB, txC) | ||||
balance = newbalance | balance = newbalance | ||||
# Disconnect nodes so node0's transactions don't get into node1's mempool | # Disconnect nodes so node0's transactions don't get into node1's mempool | ||||
disconnect_nodes(self.nodes[0], self.nodes[1]) | disconnect_nodes(self.nodes[0], self.nodes[1]) | ||||
# Identify the 10btc outputs | # Identify the 10btc outputs | ||||
nA = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction( | nA = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction( | ||||
txA, 1)["vout"]) if vout["value"] == Decimal("10")) | txA, 1)["vout"]) if vout["value"] == Decimal("10")) | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Unconfirmed received funds that are not in mempool also shouldn't show | # Unconfirmed received funds that are not in mempool also shouldn't show | ||||
# up in unconfirmed balance. Note that the transactions stored in the wallet | # up in unconfirmed balance. Note that the transactions stored in the wallet | ||||
# are not necessarily in the node's mempool. | # are not necessarily in the node's mempool. | ||||
unconfbalance = self.nodes[0].getunconfirmedbalance( | unconfbalance = self.nodes[0].getunconfirmedbalance( | ||||
) + self.nodes[0].getbalance() | ) + self.nodes[0].getbalance() | ||||
assert_equal(unconfbalance, newbalance) | assert_equal(unconfbalance, newbalance) | ||||
# Unconfirmed transactions which are not in the mempool should also | # Unconfirmed transactions which are not in the mempool should also | ||||
# not be in listunspent | # not be in listunspent | ||||
assert(not txABC2 in [utxo["txid"] | assert not txABC2 in [utxo["txid"] | ||||
for utxo in self.nodes[0].listunspent(0)]) | for utxo in self.nodes[0].listunspent(0)] | ||||
balance = newbalance | balance = newbalance | ||||
# Abandon original transaction and verify inputs are available again | # Abandon original transaction and verify inputs are available again | ||||
# 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 | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |