MCPcopy Create free account
hub / github.com/ElementsProject/elements / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

src/wallet/test/scriptpubkeyman_tests.cpp:18–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16// Test LegacyScriptPubKeyMan::CanProvide behavior, making sure it returns true
17// for recognized scripts even when keys may not be available for signing.
18BOOST_AUTO_TEST_CASE(CanProvide)
19{
20 // Set up wallet and keyman variables.
21 CWallet wallet(m_node.chain.get(), "", m_args, CreateDummyWalletDatabase());
22 LegacyScriptPubKeyMan& keyman = *wallet.GetOrCreateLegacyScriptPubKeyMan();
23
24 // Make a 1 of 2 multisig script
25 std::vector<CKey> keys(2);
26 std::vector<CPubKey> pubkeys;
27 for (CKey& key : keys) {
28 key.MakeNewKey(true);
29 pubkeys.emplace_back(key.GetPubKey());
30 }
31 CScript multisig_script = GetScriptForMultisig(1, pubkeys);
32 CScript p2sh_script = GetScriptForDestination(ScriptHash(multisig_script));
33 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 BOOST_CHECK(!keyman.CanProvide(p2sh_script, data));
38 keyman.AddCScript(multisig_script);
39 BOOST_CHECK(keyman.CanProvide(p2sh_script, data));
40}
41
42BOOST_AUTO_TEST_SUITE_END()
43} // namespace wallet

Callers

nothing calls this directly

Calls 11

GetScriptForMultisigFunction · 0.85
GetScriptForDestinationFunction · 0.85
ScriptHashClass · 0.85
MakeNewKeyMethod · 0.80
emplace_backMethod · 0.80
getMethod · 0.45
GetPubKeyMethod · 0.45
CanProvideMethod · 0.45
AddCScriptMethod · 0.45

Tested by

no test coverage detected