mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-26 01:32:26 +01:00
test: refactor: move CreateDescriptor
helper to wallet test util module
Can be reviewed via `--color-moved=dimmed-zebra`.
This commit is contained in:
parent
493656763f
commit
62a95f5af9
@ -20,26 +20,6 @@ using namespace util::hex_literals;
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(ismine_tests, BasicTestingSetup)
|
||||
|
||||
wallet::ScriptPubKeyMan* CreateDescriptor(CWallet& keystore, const std::string& desc_str, const bool success)
|
||||
{
|
||||
keystore.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
||||
|
||||
FlatSigningProvider keys;
|
||||
std::string error;
|
||||
auto parsed_descs = Parse(desc_str, keys, error, false);
|
||||
BOOST_CHECK(success == (!parsed_descs.empty()));
|
||||
if (!success) return nullptr;
|
||||
auto& desc = parsed_descs.at(0);
|
||||
|
||||
const int64_t range_start = 0, range_end = 1, next_index = 0, timestamp = 1;
|
||||
|
||||
WalletDescriptor w_desc(std::move(desc), timestamp, range_start, range_end, next_index);
|
||||
|
||||
LOCK(keystore.cs_wallet);
|
||||
|
||||
return Assert(keystore.AddWalletDescriptor(w_desc, keys,/*label=*/"", /*internal=*/false));
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
{
|
||||
CKey keys[2];
|
||||
|
@ -192,4 +192,24 @@ MockableDatabase& GetMockableDatabase(CWallet& wallet)
|
||||
{
|
||||
return dynamic_cast<MockableDatabase&>(wallet.GetDatabase());
|
||||
}
|
||||
|
||||
wallet::ScriptPubKeyMan* CreateDescriptor(CWallet& keystore, const std::string& desc_str, const bool success)
|
||||
{
|
||||
keystore.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
||||
|
||||
FlatSigningProvider keys;
|
||||
std::string error;
|
||||
auto parsed_descs = Parse(desc_str, keys, error, false);
|
||||
Assert(success == (!parsed_descs.empty()));
|
||||
if (!success) return nullptr;
|
||||
auto& desc = parsed_descs.at(0);
|
||||
|
||||
const int64_t range_start = 0, range_end = 1, next_index = 0, timestamp = 1;
|
||||
|
||||
WalletDescriptor w_desc(std::move(desc), timestamp, range_start, range_end, next_index);
|
||||
|
||||
LOCK(keystore.cs_wallet);
|
||||
|
||||
return Assert(keystore.AddWalletDescriptor(w_desc, keys,/*label=*/"", /*internal=*/false));
|
||||
};
|
||||
} // namespace wallet
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <addresstype.h>
|
||||
#include <wallet/db.h>
|
||||
#include <wallet/scriptpubkeyman.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -127,8 +128,9 @@ public:
|
||||
};
|
||||
|
||||
std::unique_ptr<WalletDatabase> CreateMockableWalletDatabase(MockableData records = {});
|
||||
|
||||
MockableDatabase& GetMockableDatabase(CWallet& wallet);
|
||||
|
||||
ScriptPubKeyMan* CreateDescriptor(CWallet& keystore, const std::string& desc_str, const bool success);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_TEST_UTIL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user