aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/mempool_persist.py4
-rw-r--r--test/functional/test_framework/netutil.py3
-rwxr-xr-xtest/functional/wallet_dump.py24
3 files changed, 19 insertions, 12 deletions
diff --git a/test/functional/mempool_persist.py b/test/functional/mempool_persist.py
index 17f0967219..53748df915 100755
--- a/test/functional/mempool_persist.py
+++ b/test/functional/mempool_persist.py
@@ -66,7 +66,9 @@ class MempoolPersistTest(BitcoinTestFramework):
self.log.debug("Stop-start the nodes. Verify that node0 has the transactions in its mempool and node1 does not. Verify that node2 calculates its balance correctly after loading wallet transactions.")
self.stop_nodes()
- self.start_node(1) # Give this one a head-start, so we can be "extra-sure" that it didn't load anything later
+ # Give this node a head-start, so we can be "extra-sure" that it didn't load anything later
+ # Also don't store the mempool, to keep the datadir clean
+ self.start_node(1, extra_args=["-persistmempool=0"])
self.start_node(0)
self.start_node(2)
# Give bitcoind a second to reload the mempool
diff --git a/test/functional/test_framework/netutil.py b/test/functional/test_framework/netutil.py
index 96fe283347..36d1a2f856 100644
--- a/test/functional/test_framework/netutil.py
+++ b/test/functional/test_framework/netutil.py
@@ -9,7 +9,6 @@ Roughly based on http://voorloopnul.com/blog/a-python-netstat-in-less-than-100-l
import sys
import socket
-import fcntl
import struct
import array
import os
@@ -90,6 +89,8 @@ def all_interfaces():
'''
Return all interfaces that are up
'''
+ import fcntl # Linux only, so only import when required
+
is_64bits = sys.maxsize > 2**32
struct_size = 40 if is_64bits else 32
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
diff --git a/test/functional/wallet_dump.py b/test/functional/wallet_dump.py
index e171a26002..94fd6baf04 100755
--- a/test/functional/wallet_dump.py
+++ b/test/functional/wallet_dump.py
@@ -7,7 +7,10 @@
import os
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import (assert_equal, assert_raises_rpc_error)
+from test_framework.util import (
+ assert_equal,
+ assert_raises_rpc_error,
+)
def read_dump(file_name, addrs, script_addrs, hd_master_addr_old):
@@ -88,7 +91,8 @@ class WalletDumpTest(BitcoinTestFramework):
self.start_nodes()
def run_test (self):
- tmpdir = self.options.tmpdir
+ wallet_unenc_dump = os.path.join(self.nodes[0].datadir, "wallet.unencrypted.dump")
+ wallet_enc_dump = os.path.join(self.nodes[0].datadir, "wallet.encrypted.dump")
# generate 20 addresses to compare against the dump
# but since we add a p2sh-p2wpkh address for the first pubkey in the
@@ -108,11 +112,11 @@ class WalletDumpTest(BitcoinTestFramework):
script_addrs = [witness_addr, multisig_addr]
# dump unencrypted wallet
- result = self.nodes[0].dumpwallet(tmpdir + "/node0/wallet.unencrypted.dump")
- assert_equal(result['filename'], os.path.abspath(tmpdir + "/node0/wallet.unencrypted.dump"))
+ result = self.nodes[0].dumpwallet(wallet_unenc_dump)
+ assert_equal(result['filename'], wallet_unenc_dump)
found_addr, found_script_addr, found_addr_chg, found_addr_rsv, hd_master_addr_unenc, witness_addr_ret = \
- read_dump(tmpdir + "/node0/wallet.unencrypted.dump", addrs, script_addrs, None)
+ read_dump(wallet_unenc_dump, addrs, script_addrs, None)
assert_equal(found_addr, test_addr_count) # all keys must be in the dump
assert_equal(found_script_addr, 2) # all scripts must be in the dump
assert_equal(found_addr_chg, 50) # 50 blocks where mined
@@ -125,10 +129,10 @@ class WalletDumpTest(BitcoinTestFramework):
self.nodes[0].walletpassphrase('test', 10)
# Should be a no-op:
self.nodes[0].keypoolrefill()
- self.nodes[0].dumpwallet(tmpdir + "/node0/wallet.encrypted.dump")
+ self.nodes[0].dumpwallet(wallet_enc_dump)
found_addr, found_script_addr, found_addr_chg, found_addr_rsv, _, witness_addr_ret = \
- read_dump(tmpdir + "/node0/wallet.encrypted.dump", addrs, script_addrs, hd_master_addr_unenc)
+ read_dump(wallet_enc_dump, addrs, script_addrs, hd_master_addr_unenc)
assert_equal(found_addr, test_addr_count)
assert_equal(found_script_addr, 2)
assert_equal(found_addr_chg, 90*2 + 50) # old reserve keys are marked as change now
@@ -136,7 +140,7 @@ class WalletDumpTest(BitcoinTestFramework):
assert_equal(witness_addr_ret, witness_addr)
# Overwriting should fail
- assert_raises_rpc_error(-8, "already exists", self.nodes[0].dumpwallet, tmpdir + "/node0/wallet.unencrypted.dump")
+ assert_raises_rpc_error(-8, "already exists", lambda: self.nodes[0].dumpwallet(wallet_enc_dump))
# Restart node with new wallet, and test importwallet
self.stop_node(0)
@@ -146,11 +150,11 @@ class WalletDumpTest(BitcoinTestFramework):
result = self.nodes[0].getaddressinfo(multisig_addr)
assert(result['ismine'] == False)
- self.nodes[0].importwallet(os.path.abspath(tmpdir + "/node0/wallet.unencrypted.dump"))
+ self.nodes[0].importwallet(wallet_unenc_dump)
# Now check IsMine is true
result = self.nodes[0].getaddressinfo(multisig_addr)
assert(result['ismine'] == True)
if __name__ == '__main__':
- WalletDumpTest().main ()
+ WalletDumpTest().main()