LCOV - code coverage report
Current view: top level - src/wallet/test - scriptpubkeyman_tests.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 0 34 0.0 %
Date: 2023-10-05 12:38:51 Functions: 0 18 0.0 %
Branches: 0 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 <test/util/setup_common.h>
       7                 :            : #include <script/solver.h>
       8                 :            : #include <wallet/scriptpubkeyman.h>
       9                 :            : #include <wallet/wallet.h>
      10                 :            : #include <wallet/test/util.h>
      11                 :            : 
      12                 :            : #include <boost/test/unit_test.hpp>
      13                 :            : 
      14                 :            : namespace wallet {
      15                 :          0 : BOOST_FIXTURE_TEST_SUITE(scriptpubkeyman_tests, BasicTestingSetup)
      16                 :            : 
      17                 :          0 : // Test LegacyScriptPubKeyMan::CanProvide behavior, making sure it returns true
      18                 :          0 : // for recognized scripts even when keys may not be available for signing.
      19                 :          0 : BOOST_AUTO_TEST_CASE(CanProvide)
      20                 :            : {
      21                 :            :     // Set up wallet and keyman variables.
      22                 :          0 :     CWallet wallet(m_node.chain.get(), "", CreateMockableWalletDatabase());
      23                 :          0 :     LegacyScriptPubKeyMan& keyman = *wallet.GetOrCreateLegacyScriptPubKeyMan();
      24                 :            : 
      25                 :            :     // Make a 1 of 2 multisig script
      26                 :          0 :     std::vector<CKey> keys(2);
      27                 :          0 :     std::vector<CPubKey> pubkeys;
      28                 :          0 :     for (CKey& key : keys) {
      29                 :          0 :         key.MakeNewKey(true);
      30                 :          0 :         pubkeys.emplace_back(key.GetPubKey());
      31                 :            :     }
      32                 :          0 :     CScript multisig_script = GetScriptForMultisig(1, pubkeys);
      33                 :          0 :     CScript p2sh_script = GetScriptForDestination(ScriptHash(multisig_script));
      34                 :          0 :     SignatureData data;
      35                 :          0 : 
      36                 :            :     // Verify the p2sh(multisig) script is not recognized until the multisig
      37                 :            :     // script is added to the keystore to make it solvable
      38                 :          0 :     BOOST_CHECK(!keyman.CanProvide(p2sh_script, data));
      39                 :          0 :     keyman.AddCScript(multisig_script);
      40                 :          0 :     BOOST_CHECK(keyman.CanProvide(p2sh_script, data));
      41                 :          0 : }
      42                 :            : 
      43                 :          0 : BOOST_AUTO_TEST_SUITE_END()
      44                 :            : } // namespace wallet

Generated by: LCOV version 1.14