Files
hush3/qa/rpc-tests/feature_walletfile.py
Duke Leto be16f80abc Hush Full Node is now GPLv3
Any projects which want to use Hush code from now on will need to be licensed as
GPLv3 or we will send the lawyers: https://www.softwarefreedom.org/

Notably, Komodo (KMD) is licensed as GPLv2 and is no longer compatible to receive
code changes, without causing legal issues. MIT projects, such as Zcash, also cannot pull
in changes from the Hush Full Node without permission from The Hush Developers,
which may in some circumstances grant an MIT license on a case-by-case basis.
2020-10-21 07:28:10 -04:00

52 lines
2.1 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright (c) 2017 The Bitcoin Core developers
# Copyright (c) 2019-2020 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
"""Test wallet file location."""
import os
from test_framework.util import start_node, stop_node, assert_start_raises_init_error
from test_framework.test_framework import BitcoinTestFramework
class WalletFileTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
def run_test(self):
# test default wallet location
assert os.path.isfile(os.path.join(self.options.tmpdir, "node0", "regtest", "wallet.dat"))
# test alternative wallet file name in datadir
stop_node(self.nodes[0], 0)
self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=altwallet.dat"])
assert os.path.isfile(os.path.join(self.options.tmpdir, "node0", "regtest", "altwallet.dat"))
# test wallet file outside datadir
tempname = os.path.join(self.options.tmpdir, "outsidewallet.dat")
stop_node(self.nodes[0], 0)
self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=%s" % tempname])
assert os.path.isfile(tempname)
# test the case where absolute path does not exist
assert not os.path.isdir("/this_directory_must_not_exist")
invalidpath = os.path.join("/this_directory_must_not_exist/", "foo.dat")
stop_node(self.nodes[0], 0)
assert_start_raises_init_error(0, "-wallet=%s" % invalidpath,
"Error: Absolute path %s does not exist")
# relative path does not exist
invalidpath = os.path.join("wallet", "foo.dat")
assert_start_raises_init_error(0, "-wallet=%s" % invalidpath,
"Error: Relative path %s does not exist")
# create dir and retry
os.mkdir(os.path.join(self.options.tmpdir, "node0", "regtest", "wallet"))
self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=%s" % invalidpath])
if __name__ == '__main__':
WalletFileTest().main()