File tree Expand file tree Collapse file tree 8 files changed +426
-3
lines changed Expand file tree Collapse file tree 8 files changed +426
-3
lines changed Original file line number Diff line number Diff line change 12
12
BITCOIND_BIN =$(top_builddir ) /src/bitcoind$(EXEEXT )
13
13
BITCOIN_QT_BIN =$(top_builddir ) /src/qt/bitcoin-qt$(EXEEXT )
14
14
BITCOIN_CLI_BIN =$(top_builddir ) /src/bitcoin-cli$(EXEEXT )
15
+ WALLET_UTILITY_BIN =$(top_builddir ) /src/wallet-utility$(EXEEXT )
15
16
BITCOIN_WIN_INSTALLER =$(PACKAGE ) -$(PACKAGE_VERSION ) -win$(WINDOWS_BITS ) -setup$(EXEEXT )
16
17
17
18
OSX_APP =Bitcoin-Qt.app
@@ -63,6 +64,7 @@ $(BITCOIN_WIN_INSTALLER): all-recursive
63
64
STRIPPROG=" $( STRIP) " $(INSTALL_STRIP_PROGRAM ) $(BITCOIND_BIN ) $(top_builddir ) /release
64
65
STRIPPROG=" $( STRIP) " $(INSTALL_STRIP_PROGRAM ) $(BITCOIN_QT_BIN ) $(top_builddir ) /release
65
66
STRIPPROG=" $( STRIP) " $(INSTALL_STRIP_PROGRAM ) $(BITCOIN_CLI_BIN ) $(top_builddir ) /release
67
+ STRIPPROG=" $( STRIP) " $(INSTALL_STRIP_PROGRAM ) $(WALLET_UTILITY_BIN ) $(top_builddir ) /release
66
68
@test -f $(MAKENSIS ) && $(MAKENSIS ) -V2 $(top_builddir ) /share/setup.nsi || \
67
69
echo error: could not build $@
68
70
@echo built $@
@@ -145,6 +147,9 @@ $(BITCOIND_BIN): FORCE
145
147
$(BITCOIN_CLI_BIN ) : FORCE
146
148
$(MAKE ) -C src $(@F )
147
149
150
+ $(WALLET_UTILITY_BIN ) : FORCE
151
+ $(MAKE ) -C src $(@F )
152
+
148
153
if USE_LCOV
149
154
150
155
baseline.info :
Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
191
191
192
192
AC_ARG_WITH ( [ utils] ,
193
193
[ AS_HELP_STRING ( [ --with-utils] ,
194
- [ build bitcoin-cli bitcoin-tx (default=yes)] ) ] ,
194
+ [ build bitcoin-cli bitcoin-tx wallet-utility (default=yes)] ) ] ,
195
195
[ build_bitcoin_utils=$withval] ,
196
196
[ build_bitcoin_utils=yes] )
197
197
@@ -766,7 +766,7 @@ AC_MSG_CHECKING([whether to build bitcoind])
766
766
AM_CONDITIONAL([ BUILD_BITCOIND] , [ test x$build_bitcoind = xyes] )
767
767
AC_MSG_RESULT ( $build_bitcoind )
768
768
769
- AC_MSG_CHECKING ( [ whether to build utils (bitcoin-cli bitcoin-tx)] )
769
+ AC_MSG_CHECKING ( [ whether to build utils (bitcoin-cli bitcoin-tx wallet-utility )] )
770
770
AM_CONDITIONAL([ BUILD_BITCOIN_UTILS] , [ test x$build_bitcoin_utils = xyes] )
771
771
AC_MSG_RESULT ( $build_bitcoin_utils )
772
772
Original file line number Diff line number Diff line change 74
74
75
75
if BUILD_BITCOIN_UTILS
76
76
bin_PROGRAMS += bitcoin-cli bitcoin-tx
77
+ if ENABLE_WALLET
78
+ bin_PROGRAMS += wallet-utility
79
+ endif
77
80
endif
78
81
79
82
.PHONY : FORCE check-symbols check-security
@@ -367,6 +370,14 @@ bitcoin_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS)
367
370
bitcoin_cli_CXXFLAGS = $(AM_CXXFLAGS ) $(PIE_FLAGS )
368
371
bitcoin_cli_LDFLAGS = $(RELDFLAGS ) $(AM_LDFLAGS ) $(LIBTOOL_APP_LDFLAGS )
369
372
373
+ # wallet-utility binary #
374
+ if ENABLE_WALLET
375
+ wallet_utility_SOURCES = wallet-utility.cpp
376
+ wallet_utility_CPPFLAGS = $(AM_CPPFLAGS ) $(BITCOIN_INCLUDES ) $(EVENT_CFLAG )
377
+ wallet_utility_CXXFLAGS = $(AM_CXXFLAGS ) $(PIE_FLAGS )
378
+ wallet_utility_LDFLAGS = $(RELDFLAGS ) $(AM_LDFLAGS ) $(LIBTOOL_APP_LDFLAGS )
379
+ endif
380
+
370
381
if TARGET_WINDOWS
371
382
bitcoin_cli_SOURCES += bitcoin-cli-res.rc
372
383
endif
@@ -377,6 +388,10 @@ bitcoin_cli_LDADD = \
377
388
$(LIBBITCOIN_UTIL )
378
389
379
390
bitcoin_cli_LDADD += $(BOOST_LIBS ) $(SSL_LIBS ) $(CRYPTO_LIBS ) $(EVENT_LIBS )
391
+ if ENABLE_WALLET
392
+ wallet_utility_LDADD = libbitcoin_wallet.a $(LIBBITCOIN_COMMON ) $(LIBBITCOIN_CRYPTO ) $(LIBSECP256K1 ) $(LIBBITCOIN_UTIL ) $(BOOST_LIBS ) $(BDB_LIBS ) $(CRYPTO_LIBS )
393
+ endif
394
+
380
395
#
381
396
382
397
# bitcoin-tx binary #
Original file line number Diff line number Diff line change @@ -92,7 +92,8 @@ if ENABLE_WALLET
92
92
BITCOIN_TESTS += \
93
93
test/accounting_tests.cpp \
94
94
wallet/test/wallet_tests.cpp \
95
- test/rpc_wallet_tests.cpp
95
+ test/rpc_wallet_tests.cpp \
96
+ test/walletutil_tests.cpp
96
97
endif
97
98
98
99
test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
Original file line number Diff line number Diff line change @@ -96,6 +96,41 @@ TestingSetup::~TestingSetup()
96
96
boost::filesystem::remove_all (pathTemp);
97
97
}
98
98
99
+ WalletSetup::WalletSetup (const std::string& chainName) : BasicTestingSetup(chainName)
100
+ {
101
+ ClearDatadirCache ();
102
+ pathTemp = GetTempPath () / strprintf (" test_bitcoin_%lu_%i" , (unsigned long )GetTime (), (int )(GetRand (100000 )));
103
+ boost::filesystem::create_directories (pathTemp);
104
+ mapArgs[" -datadir" ] = pathTemp.string ();
105
+ #ifdef ENABLE_WALLET
106
+ bool fFirstRun ;
107
+ pwalletMain = new CWallet (" wallet.dat" );
108
+ pwalletMain->LoadWallet (fFirstRun );
109
+ pwalletMain->TopUpKeyPool (5 );
110
+ RegisterValidationInterface (pwalletMain);
111
+ #endif
112
+ }
113
+
114
+ WalletSetup::~WalletSetup ()
115
+ {
116
+ #ifdef ENABLE_WALLET
117
+ UnregisterValidationInterface (pwalletMain);
118
+ delete pwalletMain;
119
+ pwalletMain = NULL ;
120
+ bitdb.Flush (true );
121
+ bitdb.Reset ();
122
+ #endif
123
+
124
+ /*
125
+ * Attempting to remove Berkeley DB related files in windows
126
+ * errors while running wallet tests. Delete only on
127
+ * non windows platforms for now (files are created in tmp)
128
+ */
129
+ #ifndef WIN32
130
+ boost::filesystem::remove_all (pathTemp);
131
+ #endif
132
+ }
133
+
99
134
TestChain100Setup::TestChain100Setup () : TestingSetup(CBaseChainParams::REGTEST)
100
135
{
101
136
// Generate a 100-block chain:
Original file line number Diff line number Diff line change @@ -33,6 +33,17 @@ struct TestingSetup: public BasicTestingSetup {
33
33
~TestingSetup ();
34
34
};
35
35
36
+ /* * Wallet setup that configures a complete environment.
37
+ * Included are data directory, coins database, script check threads
38
+ * and wallet with 5 unused keys.
39
+ */
40
+ struct WalletSetup : public BasicTestingSetup {
41
+ boost::filesystem::path pathTemp;
42
+
43
+ WalletSetup (const std::string& chainName = CBaseChainParams::MAIN);
44
+ ~WalletSetup ();
45
+ };
46
+
36
47
class CBlock ;
37
48
struct CMutableTransaction ;
38
49
class CScript ;
Original file line number Diff line number Diff line change
1
+ #include " main.h"
2
+ #include " test/test_bitcoin.h"
3
+ #include < boost/test/unit_test.hpp>
4
+
5
+ #ifdef ENABLE_WALLET
6
+ #include " wallet/db.h"
7
+ #include " wallet/wallet.h"
8
+ extern CWallet* pwalletMain;
9
+ #endif
10
+
11
+ using namespace std ;
12
+
13
+ BOOST_FIXTURE_TEST_SUITE (walletutil_tests, WalletSetup)
14
+
15
+ BOOST_AUTO_TEST_CASE(walletutil_test)
16
+ {
17
+ #ifdef WIN32
18
+ string strCmd = " wallet-utility -datadir=" +mapArgs[" -datadir" ];
19
+ #else
20
+ string strCmd = " ./wallet-utility -datadir=" +mapArgs[" -datadir" ];
21
+ #endif
22
+ int ret = system (strCmd.c_str ());
23
+ BOOST_CHECK (ret == 0 );
24
+
25
+ strCmd += " -dumppass" ;
26
+ ret = system (strCmd.c_str ());
27
+ BOOST_CHECK (ret == 0 );
28
+ }
29
+
30
+ BOOST_AUTO_TEST_SUITE_END ()
You can’t perform that action at this time.
0 commit comments