diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2022-08-19 11:13:41 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2022-11-21 17:30:00 -0300 |
commit | ee7a984f85015b610be4929b7c35cb501c1fbf7c (patch) | |
tree | 5524e76c9617f91641a2c29a25312379618bacfb /src/wallet | |
parent | cc5a5e81217506ec6f9fff34056290f8f40a7396 (diff) | |
download | bitcoin-ee7a984f85015b610be4929b7c35cb501c1fbf7c.tar.xz |
refactor: unify test/util/wallet.h with wallet/test/util.h
files share the same purpose, and we shouldn't have wallet code
inside the test directory.
This later is needed to use wallet util functions in the bench
and test binaries without be forced to duplicate them.
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/test/util.cpp | 22 | ||||
-rw-r--r-- | src/wallet/test/util.h | 8 |
2 files changed, 24 insertions, 6 deletions
diff --git a/src/wallet/test/util.cpp b/src/wallet/test/util.cpp index ab72721f9d..fb15c1a451 100644 --- a/src/wallet/test/util.cpp +++ b/src/wallet/test/util.cpp @@ -11,8 +11,6 @@ #include <wallet/wallet.h> #include <wallet/walletdb.h> -#include <boost/test/unit_test.hpp> - #include <memory> namespace wallet { @@ -39,10 +37,22 @@ std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cc WalletRescanReserver reserver(*wallet); reserver.reserve(); CWallet::ScanResult result = wallet->ScanForWalletTransactions(cchain.Genesis()->GetBlockHash(), /*start_height=*/0, /*max_height=*/{}, reserver, /*fUpdate=*/false, /*save_progress=*/false); - BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS); - BOOST_CHECK_EQUAL(result.last_scanned_block, cchain.Tip()->GetBlockHash()); - BOOST_CHECK_EQUAL(*result.last_scanned_height, cchain.Height()); - BOOST_CHECK(result.last_failed_block.IsNull()); + assert(result.status == CWallet::ScanResult::SUCCESS); + assert(result.last_scanned_block == cchain.Tip()->GetBlockHash()); + assert(*result.last_scanned_height == cchain.Height()); + assert(result.last_failed_block.IsNull()); return wallet; } + +std::string getnewaddress(CWallet& w) +{ + constexpr auto output_type = OutputType::BECH32; + return EncodeDestination(getNewDestination(w, output_type)); +} + +CTxDestination getNewDestination(CWallet& w, OutputType output_type) +{ + return *Assert(w.GetNewDestination(output_type, "")); +} + } // namespace wallet diff --git a/src/wallet/test/util.h b/src/wallet/test/util.h index 712d0251cd..7fb496c82a 100644 --- a/src/wallet/test/util.h +++ b/src/wallet/test/util.h @@ -5,11 +5,13 @@ #ifndef BITCOIN_WALLET_TEST_UTIL_H #define BITCOIN_WALLET_TEST_UTIL_H +#include <script/standard.h> #include <memory> class ArgsManager; class CChain; class CKey; +enum class OutputType; namespace interfaces { class Chain; } // namespace interfaces @@ -18,6 +20,12 @@ namespace wallet { class CWallet; std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, ArgsManager& args, const CKey& key); + +/** Returns a new encoded destination from the wallet (hardcoded to BECH32) */ +std::string getnewaddress(CWallet& w); +/** Returns a new destination, of an specific type, from the wallet */ +CTxDestination getNewDestination(CWallet& w, OutputType output_type); + } // namespace wallet #endif // BITCOIN_WALLET_TEST_UTIL_H |