LCOV - code coverage report
Current view: top level - src/test - script_parse_tests.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 0 41 0.0 %
Date: 2023-10-05 12:38:51 Functions: 0 7 0.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 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 <core_io.h>
       6                 :            : #include <script/script.h>
       7                 :            : #include <util/strencodings.h>
       8                 :            : #include <test/util/setup_common.h>
       9                 :            : 
      10                 :            : #include <boost/test/unit_test.hpp>
      11                 :            : 
      12                 :          0 : BOOST_AUTO_TEST_SUITE(script_parse_tests)
      13                 :          0 : BOOST_AUTO_TEST_CASE(parse_script)
      14                 :            : {
      15                 :          0 :     const std::vector<std::pair<std::string,std::string>> IN_OUT{
      16                 :            :         // {IN: script string , OUT: hex string }
      17                 :          0 :         {"", ""},
      18                 :          0 :         {"0", "00"},
      19                 :          0 :         {"1", "51"},
      20                 :          0 :         {"2", "52"},
      21                 :          0 :         {"3", "53"},
      22                 :          0 :         {"4", "54"},
      23                 :          0 :         {"5", "55"},
      24                 :          0 :         {"6", "56"},
      25                 :          0 :         {"7", "57"},
      26                 :          0 :         {"8", "58"},
      27                 :          0 :         {"9", "59"},
      28                 :          0 :         {"10", "5a"},
      29                 :          0 :         {"11", "5b"},
      30                 :          0 :         {"12", "5c"},
      31                 :          0 :         {"13", "5d"},
      32                 :          0 :         {"14", "5e"},
      33                 :          0 :         {"15", "5f"},
      34                 :          0 :         {"16", "60"},
      35                 :          0 :         {"17", "0111"},
      36                 :          0 :         {"-9", "0189"},
      37                 :          0 :         {"0x17", "17"},
      38                 :          0 :         {"'17'", "023137"},
      39                 :          0 :         {"ELSE", "67"},
      40                 :          0 :         {"NOP10", "b9"},
      41                 :            :     };
      42                 :          0 :     std::string all_in;
      43                 :          0 :     std::string all_out;
      44                 :          0 :     for (const auto& [in, out] : IN_OUT) {
      45                 :          0 :         BOOST_CHECK_EQUAL(HexStr(ParseScript(in)), out);
      46                 :          0 :         all_in += " " + in + " ";
      47                 :          0 :         all_out += out;
      48                 :            :     }
      49                 :          0 :     BOOST_CHECK_EQUAL(HexStr(ParseScript(all_in)), all_out);
      50                 :            : 
      51                 :          0 :     BOOST_CHECK_EXCEPTION(ParseScript("11111111111111111111"), std::runtime_error, HasReason("script parse error: decimal numeric value only allowed in the range -0xFFFFFFFF...0xFFFFFFFF"));
      52                 :          0 :     BOOST_CHECK_EXCEPTION(ParseScript("11111111111"), std::runtime_error, HasReason("script parse error: decimal numeric value only allowed in the range -0xFFFFFFFF...0xFFFFFFFF"));
      53                 :          0 :     BOOST_CHECK_EXCEPTION(ParseScript("OP_CHECKSIGADD"), std::runtime_error, HasReason("script parse error: unknown opcode"));
      54                 :          0 : }
      55                 :          0 : BOOST_AUTO_TEST_SUITE_END()

Generated by: LCOV version 1.14