LCOV - code coverage report
Current view: top level - src/test - script_standard_tests.cpp (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 267 267 100.0 %
Date: 2021-06-29 14:35:33 Functions: 6 6 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: 6 6 100.0 %

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2017-2020 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/script.h>
#       7                 :            : #include <script/signingprovider.h>
#       8                 :            : #include <script/standard.h>
#       9                 :            : #include <test/util/setup_common.h>
#      10                 :            : 
#      11                 :            : #include <boost/test/unit_test.hpp>
#      12                 :            : 
#      13                 :            : 
#      14                 :            : BOOST_FIXTURE_TEST_SUITE(script_standard_tests, BasicTestingSetup)
#      15                 :            : 
#      16                 :            : BOOST_AUTO_TEST_CASE(dest_default_is_no_dest)
#      17                 :          2 : {
#      18                 :          2 :     CTxDestination dest;
#      19                 :          2 :     BOOST_CHECK(!IsValidDestination(dest));
#      20                 :          2 : }
#      21                 :            : 
#      22                 :            : BOOST_AUTO_TEST_CASE(script_standard_Solver_success)
#      23                 :          2 : {
#      24                 :          2 :     CKey keys[3];
#      25                 :          2 :     CPubKey pubkeys[3];
#      26         [ +  + ]:          8 :     for (int i = 0; i < 3; i++) {
#      27                 :          6 :         keys[i].MakeNewKey(true);
#      28                 :          6 :         pubkeys[i] = keys[i].GetPubKey();
#      29                 :          6 :     }
#      30                 :            : 
#      31                 :          2 :     CScript s;
#      32                 :          2 :     std::vector<std::vector<unsigned char> > solutions;
#      33                 :            : 
#      34                 :            :     // TxoutType::PUBKEY
#      35                 :          2 :     s.clear();
#      36                 :          2 :     s << ToByteVector(pubkeys[0]) << OP_CHECKSIG;
#      37                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::PUBKEY);
#      38                 :          2 :     BOOST_CHECK_EQUAL(solutions.size(), 1U);
#      39                 :          2 :     BOOST_CHECK(solutions[0] == ToByteVector(pubkeys[0]));
#      40                 :            : 
#      41                 :            :     // TxoutType::PUBKEYHASH
#      42                 :          2 :     s.clear();
#      43                 :          2 :     s << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
#      44                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::PUBKEYHASH);
#      45                 :          2 :     BOOST_CHECK_EQUAL(solutions.size(), 1U);
#      46                 :          2 :     BOOST_CHECK(solutions[0] == ToByteVector(pubkeys[0].GetID()));
#      47                 :            : 
#      48                 :            :     // TxoutType::SCRIPTHASH
#      49                 :          2 :     CScript redeemScript(s); // initialize with leftover P2PKH script
#      50                 :          2 :     s.clear();
#      51                 :          2 :     s << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
#      52                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::SCRIPTHASH);
#      53                 :          2 :     BOOST_CHECK_EQUAL(solutions.size(), 1U);
#      54                 :          2 :     BOOST_CHECK(solutions[0] == ToByteVector(CScriptID(redeemScript)));
#      55                 :            : 
#      56                 :            :     // TxoutType::MULTISIG
#      57                 :          2 :     s.clear();
#      58                 :          2 :     s << OP_1 <<
#      59                 :          2 :         ToByteVector(pubkeys[0]) <<
#      60                 :          2 :         ToByteVector(pubkeys[1]) <<
#      61                 :          2 :         OP_2 << OP_CHECKMULTISIG;
#      62                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::MULTISIG);
#      63                 :          2 :     BOOST_CHECK_EQUAL(solutions.size(), 4U);
#      64                 :          2 :     BOOST_CHECK(solutions[0] == std::vector<unsigned char>({1}));
#      65                 :          2 :     BOOST_CHECK(solutions[1] == ToByteVector(pubkeys[0]));
#      66                 :          2 :     BOOST_CHECK(solutions[2] == ToByteVector(pubkeys[1]));
#      67                 :          2 :     BOOST_CHECK(solutions[3] == std::vector<unsigned char>({2}));
#      68                 :            : 
#      69                 :          2 :     s.clear();
#      70                 :          2 :     s << OP_2 <<
#      71                 :          2 :         ToByteVector(pubkeys[0]) <<
#      72                 :          2 :         ToByteVector(pubkeys[1]) <<
#      73                 :          2 :         ToByteVector(pubkeys[2]) <<
#      74                 :          2 :         OP_3 << OP_CHECKMULTISIG;
#      75                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::MULTISIG);
#      76                 :          2 :     BOOST_CHECK_EQUAL(solutions.size(), 5U);
#      77                 :          2 :     BOOST_CHECK(solutions[0] == std::vector<unsigned char>({2}));
#      78                 :          2 :     BOOST_CHECK(solutions[1] == ToByteVector(pubkeys[0]));
#      79                 :          2 :     BOOST_CHECK(solutions[2] == ToByteVector(pubkeys[1]));
#      80                 :          2 :     BOOST_CHECK(solutions[3] == ToByteVector(pubkeys[2]));
#      81                 :          2 :     BOOST_CHECK(solutions[4] == std::vector<unsigned char>({3}));
#      82                 :            : 
#      83                 :            :     // TxoutType::NULL_DATA
#      84                 :          2 :     s.clear();
#      85                 :          2 :     s << OP_RETURN <<
#      86                 :          2 :         std::vector<unsigned char>({0}) <<
#      87                 :          2 :         std::vector<unsigned char>({75}) <<
#      88                 :          2 :         std::vector<unsigned char>({255});
#      89                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NULL_DATA);
#      90                 :          2 :     BOOST_CHECK_EQUAL(solutions.size(), 0U);
#      91                 :            : 
#      92                 :            :     // TxoutType::WITNESS_V0_KEYHASH
#      93                 :          2 :     s.clear();
#      94                 :          2 :     s << OP_0 << ToByteVector(pubkeys[0].GetID());
#      95                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::WITNESS_V0_KEYHASH);
#      96                 :          2 :     BOOST_CHECK_EQUAL(solutions.size(), 1U);
#      97                 :          2 :     BOOST_CHECK(solutions[0] == ToByteVector(pubkeys[0].GetID()));
#      98                 :            : 
#      99                 :            :     // TxoutType::WITNESS_V0_SCRIPTHASH
#     100                 :          2 :     uint256 scriptHash;
#     101                 :          2 :     CSHA256().Write(redeemScript.data(), redeemScript.size())
#     102                 :          2 :         .Finalize(scriptHash.begin());
#     103                 :            : 
#     104                 :          2 :     s.clear();
#     105                 :          2 :     s << OP_0 << ToByteVector(scriptHash);
#     106                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::WITNESS_V0_SCRIPTHASH);
#     107                 :          2 :     BOOST_CHECK_EQUAL(solutions.size(), 1U);
#     108                 :          2 :     BOOST_CHECK(solutions[0] == ToByteVector(scriptHash));
#     109                 :            : 
#     110                 :            :     // TxoutType::WITNESS_V1_TAPROOT
#     111                 :          2 :     s.clear();
#     112                 :          2 :     s << OP_1 << ToByteVector(uint256::ZERO);
#     113                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::WITNESS_V1_TAPROOT);
#     114                 :          2 :     BOOST_CHECK_EQUAL(solutions.size(), 2U);
#     115                 :          2 :     BOOST_CHECK(solutions[0] == std::vector<unsigned char>{1});
#     116                 :          2 :     BOOST_CHECK(solutions[1] == ToByteVector(uint256::ZERO));
#     117                 :            : 
#     118                 :            :     // TxoutType::WITNESS_UNKNOWN
#     119                 :          2 :     s.clear();
#     120                 :          2 :     s << OP_16 << ToByteVector(uint256::ONE);
#     121                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::WITNESS_UNKNOWN);
#     122                 :          2 :     BOOST_CHECK_EQUAL(solutions.size(), 2U);
#     123                 :          2 :     BOOST_CHECK(solutions[0] == std::vector<unsigned char>{16});
#     124                 :          2 :     BOOST_CHECK(solutions[1] == ToByteVector(uint256::ONE));
#     125                 :            : 
#     126                 :            :     // TxoutType::NONSTANDARD
#     127                 :          2 :     s.clear();
#     128                 :          2 :     s << OP_9 << OP_ADD << OP_11 << OP_EQUAL;
#     129                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NONSTANDARD);
#     130                 :          2 : }
#     131                 :            : 
#     132                 :            : BOOST_AUTO_TEST_CASE(script_standard_Solver_failure)
#     133                 :          2 : {
#     134                 :          2 :     CKey key;
#     135                 :          2 :     CPubKey pubkey;
#     136                 :          2 :     key.MakeNewKey(true);
#     137                 :          2 :     pubkey = key.GetPubKey();
#     138                 :            : 
#     139                 :          2 :     CScript s;
#     140                 :          2 :     std::vector<std::vector<unsigned char> > solutions;
#     141                 :            : 
#     142                 :            :     // TxoutType::PUBKEY with incorrectly sized pubkey
#     143                 :          2 :     s.clear();
#     144                 :          2 :     s << std::vector<unsigned char>(30, 0x01) << OP_CHECKSIG;
#     145                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NONSTANDARD);
#     146                 :            : 
#     147                 :            :     // TxoutType::PUBKEYHASH with incorrectly sized key hash
#     148                 :          2 :     s.clear();
#     149                 :          2 :     s << OP_DUP << OP_HASH160 << ToByteVector(pubkey) << OP_EQUALVERIFY << OP_CHECKSIG;
#     150                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NONSTANDARD);
#     151                 :            : 
#     152                 :            :     // TxoutType::SCRIPTHASH with incorrectly sized script hash
#     153                 :          2 :     s.clear();
#     154                 :          2 :     s << OP_HASH160 << std::vector<unsigned char>(21, 0x01) << OP_EQUAL;
#     155                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NONSTANDARD);
#     156                 :            : 
#     157                 :            :     // TxoutType::MULTISIG 0/2
#     158                 :          2 :     s.clear();
#     159                 :          2 :     s << OP_0 << ToByteVector(pubkey) << OP_1 << OP_CHECKMULTISIG;
#     160                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NONSTANDARD);
#     161                 :            : 
#     162                 :            :     // TxoutType::MULTISIG 2/1
#     163                 :          2 :     s.clear();
#     164                 :          2 :     s << OP_2 << ToByteVector(pubkey) << OP_1 << OP_CHECKMULTISIG;
#     165                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NONSTANDARD);
#     166                 :            : 
#     167                 :            :     // TxoutType::MULTISIG n = 2 with 1 pubkey
#     168                 :          2 :     s.clear();
#     169                 :          2 :     s << OP_1 << ToByteVector(pubkey) << OP_2 << OP_CHECKMULTISIG;
#     170                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NONSTANDARD);
#     171                 :            : 
#     172                 :            :     // TxoutType::MULTISIG n = 1 with 0 pubkeys
#     173                 :          2 :     s.clear();
#     174                 :          2 :     s << OP_1 << OP_1 << OP_CHECKMULTISIG;
#     175                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NONSTANDARD);
#     176                 :            : 
#     177                 :            :     // TxoutType::NULL_DATA with other opcodes
#     178                 :          2 :     s.clear();
#     179                 :          2 :     s << OP_RETURN << std::vector<unsigned char>({75}) << OP_ADD;
#     180                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NONSTANDARD);
#     181                 :            : 
#     182                 :            :     // TxoutType::WITNESS_UNKNOWN with incorrect program size
#     183                 :          2 :     s.clear();
#     184                 :          2 :     s << OP_0 << std::vector<unsigned char>(19, 0x01);
#     185                 :          2 :     BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NONSTANDARD);
#     186                 :          2 : }
#     187                 :            : 
#     188                 :            : BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)
#     189                 :          2 : {
#     190                 :          2 :     CKey key;
#     191                 :          2 :     CPubKey pubkey;
#     192                 :          2 :     key.MakeNewKey(true);
#     193                 :          2 :     pubkey = key.GetPubKey();
#     194                 :            : 
#     195                 :          2 :     CScript s;
#     196                 :          2 :     CTxDestination address;
#     197                 :            : 
#     198                 :            :     // TxoutType::PUBKEY
#     199                 :          2 :     s.clear();
#     200                 :          2 :     s << ToByteVector(pubkey) << OP_CHECKSIG;
#     201                 :          2 :     BOOST_CHECK(ExtractDestination(s, address));
#     202                 :          2 :     BOOST_CHECK(std::get<PKHash>(address) == PKHash(pubkey));
#     203                 :            : 
#     204                 :            :     // TxoutType::PUBKEYHASH
#     205                 :          2 :     s.clear();
#     206                 :          2 :     s << OP_DUP << OP_HASH160 << ToByteVector(pubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
#     207                 :          2 :     BOOST_CHECK(ExtractDestination(s, address));
#     208                 :          2 :     BOOST_CHECK(std::get<PKHash>(address) == PKHash(pubkey));
#     209                 :            : 
#     210                 :            :     // TxoutType::SCRIPTHASH
#     211                 :          2 :     CScript redeemScript(s); // initialize with leftover P2PKH script
#     212                 :          2 :     s.clear();
#     213                 :          2 :     s << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
#     214                 :          2 :     BOOST_CHECK(ExtractDestination(s, address));
#     215                 :          2 :     BOOST_CHECK(std::get<ScriptHash>(address) == ScriptHash(redeemScript));
#     216                 :            : 
#     217                 :            :     // TxoutType::MULTISIG
#     218                 :          2 :     s.clear();
#     219                 :          2 :     s << OP_1 << ToByteVector(pubkey) << OP_1 << OP_CHECKMULTISIG;
#     220                 :          2 :     BOOST_CHECK(!ExtractDestination(s, address));
#     221                 :            : 
#     222                 :            :     // TxoutType::NULL_DATA
#     223                 :          2 :     s.clear();
#     224                 :          2 :     s << OP_RETURN << std::vector<unsigned char>({75});
#     225                 :          2 :     BOOST_CHECK(!ExtractDestination(s, address));
#     226                 :            : 
#     227                 :            :     // TxoutType::WITNESS_V0_KEYHASH
#     228                 :          2 :     s.clear();
#     229                 :          2 :     s << OP_0 << ToByteVector(pubkey.GetID());
#     230                 :          2 :     BOOST_CHECK(ExtractDestination(s, address));
#     231                 :          2 :     WitnessV0KeyHash keyhash;
#     232                 :          2 :     CHash160().Write(pubkey).Finalize(keyhash);
#     233                 :          2 :     BOOST_CHECK(std::get<WitnessV0KeyHash>(address) == keyhash);
#     234                 :            : 
#     235                 :            :     // TxoutType::WITNESS_V0_SCRIPTHASH
#     236                 :          2 :     s.clear();
#     237                 :          2 :     WitnessV0ScriptHash scripthash;
#     238                 :          2 :     CSHA256().Write(redeemScript.data(), redeemScript.size()).Finalize(scripthash.begin());
#     239                 :          2 :     s << OP_0 << ToByteVector(scripthash);
#     240                 :          2 :     BOOST_CHECK(ExtractDestination(s, address));
#     241                 :          2 :     BOOST_CHECK(std::get<WitnessV0ScriptHash>(address) == scripthash);
#     242                 :            : 
#     243                 :            :     // TxoutType::WITNESS_UNKNOWN with unknown version
#     244                 :          2 :     s.clear();
#     245                 :          2 :     s << OP_1 << ToByteVector(pubkey);
#     246                 :          2 :     BOOST_CHECK(ExtractDestination(s, address));
#     247                 :          2 :     WitnessUnknown unk;
#     248                 :          2 :     unk.length = 33;
#     249                 :          2 :     unk.version = 1;
#     250                 :          2 :     std::copy(pubkey.begin(), pubkey.end(), unk.program);
#     251                 :          2 :     BOOST_CHECK(std::get<WitnessUnknown>(address) == unk);
#     252                 :          2 : }
#     253                 :            : 
#     254                 :            : BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
#     255                 :          2 : {
#     256                 :          2 :     CKey keys[3];
#     257                 :          2 :     CPubKey pubkeys[3];
#     258         [ +  + ]:          8 :     for (int i = 0; i < 3; i++) {
#     259                 :          6 :         keys[i].MakeNewKey(true);
#     260                 :          6 :         pubkeys[i] = keys[i].GetPubKey();
#     261                 :          6 :     }
#     262                 :            : 
#     263                 :          2 :     CScript s;
#     264                 :          2 :     TxoutType whichType;
#     265                 :          2 :     std::vector<CTxDestination> addresses;
#     266                 :          2 :     int nRequired;
#     267                 :            : 
#     268                 :            :     // TxoutType::PUBKEY
#     269                 :          2 :     s.clear();
#     270                 :          2 :     s << ToByteVector(pubkeys[0]) << OP_CHECKSIG;
#     271                 :          2 :     BOOST_CHECK(ExtractDestinations(s, whichType, addresses, nRequired));
#     272                 :          2 :     BOOST_CHECK_EQUAL(whichType, TxoutType::PUBKEY);
#     273                 :          2 :     BOOST_CHECK_EQUAL(addresses.size(), 1U);
#     274                 :          2 :     BOOST_CHECK_EQUAL(nRequired, 1);
#     275                 :          2 :     BOOST_CHECK(std::get<PKHash>(addresses[0]) == PKHash(pubkeys[0]));
#     276                 :            : 
#     277                 :            :     // TxoutType::PUBKEYHASH
#     278                 :          2 :     s.clear();
#     279                 :          2 :     s << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
#     280                 :          2 :     BOOST_CHECK(ExtractDestinations(s, whichType, addresses, nRequired));
#     281                 :          2 :     BOOST_CHECK_EQUAL(whichType, TxoutType::PUBKEYHASH);
#     282                 :          2 :     BOOST_CHECK_EQUAL(addresses.size(), 1U);
#     283                 :          2 :     BOOST_CHECK_EQUAL(nRequired, 1);
#     284                 :          2 :     BOOST_CHECK(std::get<PKHash>(addresses[0]) == PKHash(pubkeys[0]));
#     285                 :            : 
#     286                 :            :     // TxoutType::SCRIPTHASH
#     287                 :          2 :     CScript redeemScript(s); // initialize with leftover P2PKH script
#     288                 :          2 :     s.clear();
#     289                 :          2 :     s << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
#     290                 :          2 :     BOOST_CHECK(ExtractDestinations(s, whichType, addresses, nRequired));
#     291                 :          2 :     BOOST_CHECK_EQUAL(whichType, TxoutType::SCRIPTHASH);
#     292                 :          2 :     BOOST_CHECK_EQUAL(addresses.size(), 1U);
#     293                 :          2 :     BOOST_CHECK_EQUAL(nRequired, 1);
#     294                 :          2 :     BOOST_CHECK(std::get<ScriptHash>(addresses[0]) == ScriptHash(redeemScript));
#     295                 :            : 
#     296                 :            :     // TxoutType::MULTISIG
#     297                 :          2 :     s.clear();
#     298                 :          2 :     s << OP_2 <<
#     299                 :          2 :         ToByteVector(pubkeys[0]) <<
#     300                 :          2 :         ToByteVector(pubkeys[1]) <<
#     301                 :          2 :         OP_2 << OP_CHECKMULTISIG;
#     302                 :          2 :     BOOST_CHECK(ExtractDestinations(s, whichType, addresses, nRequired));
#     303                 :          2 :     BOOST_CHECK_EQUAL(whichType, TxoutType::MULTISIG);
#     304                 :          2 :     BOOST_CHECK_EQUAL(addresses.size(), 2U);
#     305                 :          2 :     BOOST_CHECK_EQUAL(nRequired, 2);
#     306                 :          2 :     BOOST_CHECK(std::get<PKHash>(addresses[0]) == PKHash(pubkeys[0]));
#     307                 :          2 :     BOOST_CHECK(std::get<PKHash>(addresses[1]) == PKHash(pubkeys[1]));
#     308                 :            : 
#     309                 :            :     // TxoutType::NULL_DATA
#     310                 :          2 :     s.clear();
#     311                 :          2 :     s << OP_RETURN << std::vector<unsigned char>({75});
#     312                 :          2 :     BOOST_CHECK(!ExtractDestinations(s, whichType, addresses, nRequired));
#     313                 :          2 : }
#     314                 :            : 
#     315                 :            : BOOST_AUTO_TEST_CASE(script_standard_GetScriptFor_)
#     316                 :          2 : {
#     317                 :          2 :     CKey keys[3];
#     318                 :          2 :     CPubKey pubkeys[3];
#     319         [ +  + ]:          8 :     for (int i = 0; i < 3; i++) {
#     320                 :          6 :         keys[i].MakeNewKey(true);
#     321                 :          6 :         pubkeys[i] = keys[i].GetPubKey();
#     322                 :          6 :     }
#     323                 :            : 
#     324                 :          2 :     CScript expected, result;
#     325                 :            : 
#     326                 :            :     // PKHash
#     327                 :          2 :     expected.clear();
#     328                 :          2 :     expected << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
#     329                 :          2 :     result = GetScriptForDestination(PKHash(pubkeys[0]));
#     330                 :          2 :     BOOST_CHECK(result == expected);
#     331                 :            : 
#     332                 :            :     // CScriptID
#     333                 :          2 :     CScript redeemScript(result);
#     334                 :          2 :     expected.clear();
#     335                 :          2 :     expected << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
#     336                 :          2 :     result = GetScriptForDestination(ScriptHash(redeemScript));
#     337                 :          2 :     BOOST_CHECK(result == expected);
#     338                 :            : 
#     339                 :            :     // CNoDestination
#     340                 :          2 :     expected.clear();
#     341                 :          2 :     result = GetScriptForDestination(CNoDestination());
#     342                 :          2 :     BOOST_CHECK(result == expected);
#     343                 :            : 
#     344                 :            :     // GetScriptForRawPubKey
#     345                 :          2 :     expected.clear();
#     346                 :          2 :     expected << ToByteVector(pubkeys[0]) << OP_CHECKSIG;
#     347                 :          2 :     result = GetScriptForRawPubKey(pubkeys[0]);
#     348                 :          2 :     BOOST_CHECK(result == expected);
#     349                 :            : 
#     350                 :            :     // GetScriptForMultisig
#     351                 :          2 :     expected.clear();
#     352                 :          2 :     expected << OP_2 <<
#     353                 :          2 :         ToByteVector(pubkeys[0]) <<
#     354                 :          2 :         ToByteVector(pubkeys[1]) <<
#     355                 :          2 :         ToByteVector(pubkeys[2]) <<
#     356                 :          2 :         OP_3 << OP_CHECKMULTISIG;
#     357                 :          2 :     result = GetScriptForMultisig(2, std::vector<CPubKey>(pubkeys, pubkeys + 3));
#     358                 :          2 :     BOOST_CHECK(result == expected);
#     359                 :            : 
#     360                 :            :     // WitnessV0KeyHash
#     361                 :          2 :     expected.clear();
#     362                 :          2 :     expected << OP_0 << ToByteVector(pubkeys[0].GetID());
#     363                 :          2 :     result = GetScriptForDestination(WitnessV0KeyHash(Hash160(ToByteVector(pubkeys[0]))));
#     364                 :          2 :     BOOST_CHECK(result == expected);
#     365                 :          2 :     result = GetScriptForDestination(WitnessV0KeyHash(pubkeys[0].GetID()));
#     366                 :          2 :     BOOST_CHECK(result == expected);
#     367                 :            : 
#     368                 :            :     // WitnessV0ScriptHash (multisig)
#     369                 :          2 :     CScript witnessScript;
#     370                 :          2 :     witnessScript << OP_1 << ToByteVector(pubkeys[0]) << OP_1 << OP_CHECKMULTISIG;
#     371                 :            : 
#     372                 :          2 :     uint256 scriptHash;
#     373                 :          2 :     CSHA256().Write(witnessScript.data(), witnessScript.size())
#     374                 :          2 :         .Finalize(scriptHash.begin());
#     375                 :            : 
#     376                 :          2 :     expected.clear();
#     377                 :          2 :     expected << OP_0 << ToByteVector(scriptHash);
#     378                 :          2 :     result = GetScriptForDestination(WitnessV0ScriptHash(witnessScript));
#     379                 :          2 :     BOOST_CHECK(result == expected);
#     380                 :          2 : }
#     381                 :            : 
#     382                 :            : BOOST_AUTO_TEST_SUITE_END()

Generated by: LCOV version 1.14