Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_zapwallettxes.py
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# This transaction will not be confirmed | # This transaction will not be confirmed | ||||
txid2 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 20) | txid2 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 20) | ||||
# Confirmed and unconfirmed transactions are now in the wallet. | # Confirmed and unconfirmed transactions are now in the wallet. | ||||
assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1) | assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1) | ||||
assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2) | assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2) | ||||
# Stop-start node0. Both confirmed and unconfirmed transactions remain | # Restart node0. Both confirmed and unconfirmed transactions remain | ||||
# in the wallet. | # in the wallet. | ||||
self.stop_node(0) | self.restart_node(0) | ||||
self.start_node(0) | |||||
assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1) | assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1) | ||||
assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2) | assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2) | ||||
# Stop node0 and restart with zapwallettxes and persistmempool. The unconfirmed | # Restart node0 with zapwallettxes and persistmempool. The unconfirmed | ||||
# transaction is zapped from the wallet, but is re-added when the | # transaction is zapped from the wallet, but is re-added when the | ||||
# mempool is reloaded. | # mempool is reloaded. | ||||
self.stop_node(0) | self.restart_node(0, ["-persistmempool=1", "-zapwallettxes=2"]) | ||||
self.start_node(0, ["-persistmempool=1", "-zapwallettxes=2"]) | |||||
wait_until(lambda: self.nodes[0].getmempoolinfo()[ | wait_until(lambda: self.nodes[0].getmempoolinfo()[ | ||||
'size'] == 1, timeout=3) | 'size'] == 1, timeout=3) | ||||
# Flush mempool to wallet | # Flush mempool to wallet | ||||
self.nodes[0].syncwithvalidationinterfacequeue() | self.nodes[0].syncwithvalidationinterfacequeue() | ||||
assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1) | assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1) | ||||
assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2) | assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2) | ||||
# Stop node0 and restart with zapwallettxes, but not persistmempool. | # Restart node0 with zapwallettxes, but not persistmempool. | ||||
# The unconfirmed transaction is zapped and is no longer in the wallet. | # The unconfirmed transaction is zapped and is no longer in the wallet. | ||||
self.stop_node(0) | self.restart_node(0, ["-zapwallettxes=2"]) | ||||
self.start_node(0, ["-zapwallettxes=2"]) | |||||
# tx1 is still be available because it was confirmed | # tx1 is still be available because it was confirmed | ||||
assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1) | assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1) | ||||
# This will raise an exception because the unconfirmed transaction has | # This will raise an exception because the unconfirmed transaction has | ||||
# been zapped | # been zapped | ||||
assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', | assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', | ||||
self.nodes[0].gettransaction, txid2) | self.nodes[0].gettransaction, txid2) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
ZapWalletTXesTest().main() | ZapWalletTXesTest().main() |