aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_zapwallettxes.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-01-24 20:42:46 -0500
committerMarcoFalke <falke.marco@gmail.com>2018-01-24 20:43:13 -0500
commit6970b30c6f1d2be7947295fe18f2390649b17a4b (patch)
tree6d8c8226f05a765483eff94aedfccd8cf483cf55 /test/functional/wallet_zapwallettxes.py
parentf359afcc410432ed5d30001acda0c66741ee8935 (diff)
parent6f881cc8809e2c0d0150c47494bc37f2eb05ec66 (diff)
downloadbitcoin-6970b30c6f1d2be7947295fe18f2390649b17a4b.tar.xz
Merge #11774: [tests] Rename functional tests
6f881cc880 [tests] Remove EXPECTED_VIOLATION_COUNT (Anthony Towns) 3150b3fea7 [tests] Rename misc functional tests. (Anthony Towns) 81b79f2c39 [tests] Rename rpc_* functional tests. (Anthony Towns) 61b8f7f273 [tests] Rename p2p_* functional tests. (Anthony Towns) 90600bc7db [tests] Rename wallet_* functional tests. (Anthony Towns) ca6523d0c8 [tests] Rename feature_* functional tests. (Anthony Towns) Pull request description: This PR changes the functional tests to have a consistent naming scheme: tests for individual RPC methods are named rpc_... tests for interfaces (REST, ZMQ, RPC features) are named interface_... tests that explicitly test the p2p interface are named p2p_... tests for wallet features are named wallet_... tests for mining features are named mining_... tests for mempool behaviour are named mempool_... tests for full features that aren't wallet/mining/mempool are named feature_... Rationale: it's sometimes difficult for new contributors to know what's already covered by existing tests and where new tests should be added. Naming in a consistent fashion makes it easier to see what's already covered at a glance. Tree-SHA512: 4246790552d42bbd95f6d5bdf67702b81b3b2c583ce7eaf1fe6d8e254721279b47315973c6e9ae82dad6e4c747f12188160764bf2624c0f8f3b4d39330ec8b16
Diffstat (limited to 'test/functional/wallet_zapwallettxes.py')
-rwxr-xr-xtest/functional/wallet_zapwallettxes.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/functional/wallet_zapwallettxes.py b/test/functional/wallet_zapwallettxes.py
new file mode 100755
index 0000000000..08afb87894
--- /dev/null
+++ b/test/functional/wallet_zapwallettxes.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python3
+# Copyright (c) 2014-2017 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+"""Test the zapwallettxes functionality.
+
+- start two bitcoind nodes
+- create two transactions on node 0 - one is confirmed and one is unconfirmed.
+- restart node 0 and verify that both the confirmed and the unconfirmed
+ transactions are still available.
+- restart node 0 with zapwallettxes and persistmempool, and verify that both
+ the confirmed and the unconfirmed transactions are still available.
+- restart node 0 with just zapwallettxes and verify that the confirmed
+ transactions are still available, but that the unconfirmed transaction has
+ been zapped.
+"""
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import (
+ assert_equal,
+ assert_raises_rpc_error,
+ wait_until,
+)
+
+class ZapWalletTXesTest (BitcoinTestFramework):
+ def set_test_params(self):
+ self.setup_clean_chain = True
+ self.num_nodes = 2
+
+ def run_test(self):
+ self.log.info("Mining blocks...")
+ self.nodes[0].generate(1)
+ self.sync_all()
+ self.nodes[1].generate(100)
+ self.sync_all()
+
+ # This transaction will be confirmed
+ txid1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 10)
+
+ self.nodes[0].generate(1)
+ self.sync_all()
+
+ # This transaction will not be confirmed
+ txid2 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 20)
+
+ # Confirmed and unconfirmed transactions are now in the wallet.
+ assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
+ assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2)
+
+ # Stop-start node0. Both confirmed and unconfirmed transactions remain in the wallet.
+ self.stop_node(0)
+ self.start_node(0)
+
+ assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
+ assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2)
+
+ # Stop node0 and restart with zapwallettxes and persistmempool. The unconfirmed
+ # transaction is zapped from the wallet, but is re-added when the mempool is reloaded.
+ self.stop_node(0)
+ self.start_node(0, ["-persistmempool=1", "-zapwallettxes=2"])
+
+ wait_until(lambda: self.nodes[0].getmempoolinfo()['size'] == 1, timeout=3)
+
+ assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
+ assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2)
+
+ # Stop node0 and restart with zapwallettxes, but not persistmempool.
+ # The unconfirmed transaction is zapped and is no longer in the wallet.
+ self.stop_node(0)
+ self.start_node(0, ["-zapwallettxes=2"])
+
+ # tx1 is still be available because it was confirmed
+ assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
+
+ # This will raise an exception because the unconfirmed transaction has been zapped
+ assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', self.nodes[0].gettransaction, txid2)
+
+if __name__ == '__main__':
+ ZapWalletTXesTest().main()