LCOV - code coverage report
Current view: top level - src/wallet/test - scriptpubkeyman_tests.cpp (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 16 16 100.0 %
Date: 2022-04-21 14:51:19 Functions: 1 1 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 2 2 100.0 %

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2020-2021 The Bitcoin Core developers
#       2                 :            : // Distributed under the MIT software license, see the accompanying
#       3                 :            : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#       4                 :            : 
#       5                 :            : #include <key.h>
#       6                 :            : #include <script/standard.h>
#       7                 :            : #include <test/util/setup_common.h>
#       8                 :            : #include <wallet/scriptpubkeyman.h>
#       9                 :            : #include <wallet/wallet.h>
#      10                 :            : 
#      11                 :            : #include <boost/test/unit_test.hpp>
#      12                 :            : 
#      13                 :            : namespace wallet {
#      14                 :            : BOOST_FIXTURE_TEST_SUITE(scriptpubkeyman_tests, BasicTestingSetup)
#      15                 :            : 
#      16                 :            : // Test LegacyScriptPubKeyMan::CanProvide behavior, making sure it returns true
#      17                 :            : // for recognized scripts even when keys may not be available for signing.
#      18                 :            : BOOST_AUTO_TEST_CASE(CanProvide)
#      19                 :          1 : {
#      20                 :            :     // Set up wallet and keyman variables.
#      21                 :          1 :     CWallet wallet(m_node.chain.get(), "", m_args, CreateDummyWalletDatabase());
#      22                 :          1 :     LegacyScriptPubKeyMan& keyman = *wallet.GetOrCreateLegacyScriptPubKeyMan();
#      23                 :            : 
#      24                 :            :     // Make a 1 of 2 multisig script
#      25                 :          1 :     std::vector<CKey> keys(2);
#      26                 :          1 :     std::vector<CPubKey> pubkeys;
#      27         [ +  + ]:          2 :     for (CKey& key : keys) {
#      28                 :          2 :         key.MakeNewKey(true);
#      29                 :          2 :         pubkeys.emplace_back(key.GetPubKey());
#      30                 :          2 :     }
#      31                 :          1 :     CScript multisig_script = GetScriptForMultisig(1, pubkeys);
#      32                 :          1 :     CScript p2sh_script = GetScriptForDestination(ScriptHash(multisig_script));
#      33                 :          1 :     SignatureData data;
#      34                 :            : 
#      35                 :            :     // Verify the p2sh(multisig) script is not recognized until the multisig
#      36                 :            :     // script is added to the keystore to make it solvable
#      37                 :          1 :     BOOST_CHECK(!keyman.CanProvide(p2sh_script, data));
#      38                 :          1 :     keyman.AddCScript(multisig_script);
#      39                 :          1 :     BOOST_CHECK(keyman.CanProvide(p2sh_script, data));
#      40                 :          1 : }
#      41                 :            : 
#      42                 :            : BOOST_AUTO_TEST_SUITE_END()
#      43                 :            : } // namespace wallet

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a