Remove cpp test for wallet-utility
This commit is contained in:
parent
17a99d2e31
commit
ded1b77e42
|
@ -15,7 +15,9 @@ EXTRA_DIST += \
|
||||||
test/data/tx394b54bb.hex \
|
test/data/tx394b54bb.hex \
|
||||||
test/data/txcreate1.hex \
|
test/data/txcreate1.hex \
|
||||||
test/data/txcreate2.hex \
|
test/data/txcreate2.hex \
|
||||||
test/data/txcreatesign.hex
|
test/data/txcreatesign.hex \
|
||||||
|
test/wallet-utility.py \
|
||||||
|
test/data/wallet.dat
|
||||||
|
|
||||||
JSON_TEST_FILES = \
|
JSON_TEST_FILES = \
|
||||||
test/data/script_valid.json \
|
test/data/script_valid.json \
|
||||||
|
@ -107,8 +109,7 @@ if ENABLE_WALLET
|
||||||
BITCOIN_TESTS += \
|
BITCOIN_TESTS += \
|
||||||
test/accounting_tests.cpp \
|
test/accounting_tests.cpp \
|
||||||
wallet/test/wallet_tests.cpp \
|
wallet/test/wallet_tests.cpp \
|
||||||
test/rpc_wallet_tests.cpp \
|
test/rpc_wallet_tests.cpp
|
||||||
test/walletutil_tests.cpp
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
|
test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
|
||||||
|
@ -151,8 +152,10 @@ bitcoin_test_clean : FORCE
|
||||||
check-local:
|
check-local:
|
||||||
@echo "Running test/bitcoin-util-test.py..."
|
@echo "Running test/bitcoin-util-test.py..."
|
||||||
$(AM_V_at)srcdir=$(srcdir) PYTHONPATH=$(builddir)/test $(srcdir)/test/bitcoin-util-test.py
|
$(AM_V_at)srcdir=$(srcdir) PYTHONPATH=$(builddir)/test $(srcdir)/test/bitcoin-util-test.py
|
||||||
|
if ENABLE_WALLET
|
||||||
@echo "Running test/wallet-utility.py..."
|
@echo "Running test/wallet-utility.py..."
|
||||||
$(AM_V_at)srcdir=$(srcdir) PYTHONPATH=$(builddir)/test $(srcdir)/test/wallet-utility.py
|
$(AM_V_at)srcdir=$(srcdir) PYTHONPATH=$(builddir)/test $(srcdir)/test/wallet-utility.py
|
||||||
|
endif
|
||||||
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
|
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
|
||||||
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
|
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
|
||||||
|
|
||||||
|
|
|
@ -39,17 +39,6 @@ struct TestingSetup: public JoinSplitTestingSetup {
|
||||||
~TestingSetup();
|
~TestingSetup();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Wallet setup that configures a complete environment.
|
|
||||||
* Included are data directory, coins database, script check threads
|
|
||||||
* and wallet with 5 unused keys.
|
|
||||||
*/
|
|
||||||
struct WalletSetup: public BasicTestingSetup {
|
|
||||||
boost::filesystem::path pathTemp;
|
|
||||||
|
|
||||||
WalletSetup(CBaseChainParams::Network network = CBaseChainParams::MAIN);
|
|
||||||
~WalletSetup();
|
|
||||||
};
|
|
||||||
|
|
||||||
class CTxMemPoolEntry;
|
class CTxMemPoolEntry;
|
||||||
class CTxMemPool;
|
class CTxMemPool;
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,12 @@
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
from subprocess import check_output
|
import subprocess
|
||||||
import json
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
import buildenv
|
||||||
|
import shutil
|
||||||
|
|
||||||
def assert_equal(thing1, thing2):
|
def assert_equal(thing1, thing2):
|
||||||
if thing1 != thing2:
|
if thing1 != thing2:
|
||||||
|
@ -14,13 +16,46 @@ def assert_equal(thing1, thing2):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
datadir = os.environ["srcdir"] + "/test/data"
|
datadir = os.environ["srcdir"] + "/test/data"
|
||||||
command = os.environ["srcdir"] + "/wallet-utility"
|
execprog = './wallet-utility' + buildenv.exeext
|
||||||
|
execargs = '-datadir=' + datadir
|
||||||
|
execrun = execprog + ' ' + execargs
|
||||||
|
|
||||||
output = json.loads(check_output([command, "-datadir=" + datadir]))
|
proc = subprocess.Popen(execrun, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, shell=True)
|
||||||
|
try:
|
||||||
|
outs = proc.communicate()
|
||||||
|
except OSError:
|
||||||
|
print("OSError, Failed to execute " + execprog)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
assert_equal(output[0], "13EngsxkRi7SJPPqCyJsKf34U8FoX9E9Av");
|
output = json.loads(outs[0])
|
||||||
assert_equal(output[1], "1FKCLGTpPeYBUqfNxktck8k5nqxB8sjim8");
|
|
||||||
assert_equal(output[2], "13cdtE9tnNeXCZJ8KQ5WELgEmLSBLnr48F");
|
|
||||||
|
|
||||||
|
assert_equal(output[0], "13EngsxkRi7SJPPqCyJsKf34U8FoX9E9Av")
|
||||||
|
assert_equal(output[1], "1FKCLGTpPeYBUqfNxktck8k5nqxB8sjim8")
|
||||||
|
assert_equal(output[2], "13cdtE9tnNeXCZJ8KQ5WELgEmLSBLnr48F")
|
||||||
|
|
||||||
|
execargs = '-datadir=' + datadir + ' -dumppass'
|
||||||
|
execrun = execprog + ' ' + execargs
|
||||||
|
|
||||||
|
proc = subprocess.Popen(execrun, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, shell=True)
|
||||||
|
try:
|
||||||
|
outs = proc.communicate()
|
||||||
|
except OSError:
|
||||||
|
print("OSError, Failed to execute " + execprog)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
output = json.loads(outs[0])
|
||||||
|
|
||||||
|
assert_equal(output[0]['addr'], "13EngsxkRi7SJPPqCyJsKf34U8FoX9E9Av")
|
||||||
|
assert_equal(output[0]['pkey'], "5Jz5BWE2WQxp1hGqDZeisQFV1mRFR2AVBAgiXCbNcZyXNjD9aUd")
|
||||||
|
assert_equal(output[1]['addr'], "1FKCLGTpPeYBUqfNxktck8k5nqxB8sjim8")
|
||||||
|
assert_equal(output[1]['pkey'], "5HsX2b3v2GjngYQ5ZM4mLp2b2apw6aMNVaPELV1YmpiYR1S4jzc")
|
||||||
|
assert_equal(output[2]['addr'], "13cdtE9tnNeXCZJ8KQ5WELgEmLSBLnr48F")
|
||||||
|
assert_equal(output[2]['pkey'], "5KCWAs1wX2ESiL4PfDR8XYVSSETHFd2jaRGxt1QdanBFTit4XcH")
|
||||||
|
|
||||||
|
if os.path.exists(datadir + '/database'):
|
||||||
|
if os.path.isdir(datadir + '/database'):
|
||||||
|
shutil.rmtree(datadir + '/database')
|
||||||
|
|
||||||
|
if os.path.exists(datadir + '/db.log'):
|
||||||
|
os.remove(datadir + '/db.log')
|
||||||
|
sys.exit(0)
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
#include "main.h"
|
|
||||||
#include "test/test_bitcoin.h"
|
|
||||||
#include <boost/test/unit_test.hpp>
|
|
||||||
#include <boost/filesystem/fstream.hpp>
|
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
|
||||||
#include "wallet/db.h"
|
|
||||||
#include "wallet/wallet.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_SUITE(walletutil_tests, BasicTestingSetup)
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(walletutil_test)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* addresses and private keys in test/data/wallet.dat
|
|
||||||
*/
|
|
||||||
string expected_addr = "[ \"13EngsxkRi7SJPPqCyJsKf34U8FoX9E9Av\", \"1FKCLGTpPeYBUqfNxktck8k5nqxB8sjim8\", \"13cdtE9tnNeXCZJ8KQ5WELgEmLSBLnr48F\" ]\n";
|
|
||||||
string expected_addr_pkeys = "[ {\"addr\" : \"13EngsxkRi7SJPPqCyJsKf34U8FoX9E9Av\", \"pkey\" : \"5Jz5BWE2WQxp1hGqDZeisQFV1mRFR2AVBAgiXCbNcZyXNjD9aUd\"}, {\"addr\" : \"1FKCLGTpPeYBUqfNxktck8k5nqxB8sjim8\", \"pkey\" : \"5HsX2b3v2GjngYQ5ZM4mLp2b2apw6aMNVaPELV1YmpiYR1S4jzc\"}, {\"addr\" : \"13cdtE9tnNeXCZJ8KQ5WELgEmLSBLnr48F\", \"pkey\" : \"5KCWAs1wX2ESiL4PfDR8XYVSSETHFd2jaRGxt1QdanBFTit4XcH\"} ]\n";
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
string strCmd = "wallet-utility -datadir=test/data/ > test/data/op.txt";
|
|
||||||
#else
|
|
||||||
string strCmd = "./wallet-utility -datadir=test/data/ > test/data/op.txt";
|
|
||||||
#endif
|
|
||||||
int ret = system(strCmd.c_str());
|
|
||||||
BOOST_CHECK(ret == 0);
|
|
||||||
|
|
||||||
boost::filesystem::path opPath = "test/data/op.txt";
|
|
||||||
boost::filesystem::ifstream fIn;
|
|
||||||
fIn.open(opPath, std::ios::in);
|
|
||||||
|
|
||||||
if (!fIn)
|
|
||||||
{
|
|
||||||
std::cerr << "Could not open the output file" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
stringstream ss_addr;
|
|
||||||
ss_addr << fIn.rdbuf();
|
|
||||||
fIn.close();
|
|
||||||
boost::filesystem::remove(opPath);
|
|
||||||
|
|
||||||
string obtained = ss_addr.str();
|
|
||||||
BOOST_CHECK_EQUAL(obtained, expected_addr);
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
strCmd = "wallet-utility -datadir=test/data/ -dumppass > test/data/op.txt";
|
|
||||||
#else
|
|
||||||
strCmd = "./wallet-utility -datadir=test/data/ -dumppass > test/data/op.txt";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = system(strCmd.c_str());
|
|
||||||
BOOST_CHECK(ret == 0);
|
|
||||||
|
|
||||||
fIn.open(opPath, std::ios::in);
|
|
||||||
|
|
||||||
if (!fIn)
|
|
||||||
{
|
|
||||||
std::cerr << "Could not open the output file" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
stringstream ss_addr_pkeys;
|
|
||||||
ss_addr_pkeys << fIn.rdbuf();
|
|
||||||
fIn.close();
|
|
||||||
boost::filesystem::remove(opPath);
|
|
||||||
|
|
||||||
obtained = ss_addr_pkeys.str();
|
|
||||||
BOOST_CHECK_EQUAL(obtained, expected_addr_pkeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
|
Loading…
Reference in New Issue