Bitcoin Core 29.99.0
P2P Digital Currency
Classes | Macros | Functions | Variables
script_tests.cpp File Reference
#include <test/data/script_tests.json.h>
#include <test/data/bip341_wallet_vectors.json.h>
#include <common/system.h>
#include <core_io.h>
#include <key.h>
#include <rpc/util.h>
#include <script/script.h>
#include <script/script_error.h>
#include <script/sigcache.h>
#include <script/sign.h>
#include <script/signingprovider.h>
#include <script/solver.h>
#include <streams.h>
#include <test/util/json.h>
#include <test/util/random.h>
#include <test/util/setup_common.h>
#include <test/util/transaction_utils.h>
#include <util/fs.h>
#include <util/strencodings.h>
#include <cstdint>
#include <fstream>
#include <string>
#include <vector>
#include <boost/test/unit_test.hpp>
#include <secp256k1.h>
#include <univalue.h>
Include dependency graph for script_tests.cpp:

Go to the source code of this file.

Classes

struct  ScriptErrorDesc
 
struct  ScriptTest
 

Macros

#define CHECK_SCRIPT_STATIC_SIZE(script, expected_size)
 
#define CHECK_SCRIPT_DYNAMIC_SIZE(script, expected_size, expected_extra)
 

Functions

unsigned int ParseScriptFlags (std::string strFlags)
 
std::string FormatScriptFlags (unsigned int flags)
 
static std::string FormatScriptError (ScriptError_t err)
 
static ScriptError_t ParseScriptError (const std::string &name)
 
static void NegateSignatureS (std::vector< unsigned char > &vchSig)
 
 BOOST_AUTO_TEST_CASE (script_build)
 
 BOOST_AUTO_TEST_CASE (script_json_test)
 
 BOOST_AUTO_TEST_CASE (script_PushData)
 
 BOOST_AUTO_TEST_CASE (script_cltv_truncated)
 
static CScript sign_multisig (const CScript &scriptPubKey, const std::vector< CKey > &keys, const CTransaction &transaction)
 
static CScript sign_multisig (const CScript &scriptPubKey, const CKey &key, const CTransaction &transaction)
 
 BOOST_AUTO_TEST_CASE (script_CHECKMULTISIG12)
 
 BOOST_AUTO_TEST_CASE (script_CHECKMULTISIG23)
 
static TxoutType GetTxoutType (const CScript &output_script)
 Return the TxoutType of a script without exposing Solver details. More...
 
 BOOST_AUTO_TEST_CASE (script_size_and_capacity_test)
 
SignatureData CombineSignatures (const CTxOut &txout, const CMutableTransaction &tx, const SignatureData &scriptSig1, const SignatureData &scriptSig2)
 
 BOOST_AUTO_TEST_CASE (script_combineSigs)
 
 BOOST_AUTO_TEST_CASE (sign_invalid_miniscript)
 Reproduction of an exception incorrectly raised when parsing a public key inside a TapMiniscript. More...
 
 BOOST_AUTO_TEST_CASE (sign_paytoanchor)
 
 BOOST_AUTO_TEST_CASE (script_standard_push)
 
 BOOST_AUTO_TEST_CASE (script_IsPushOnly_on_invalid_scripts)
 
 BOOST_AUTO_TEST_CASE (script_GetScriptAsm)
 
template<typename T >
CScript ToScript (const T &byte_container)
 
 BOOST_AUTO_TEST_CASE (script_byte_array_u8_vector_equivalence)
 
 BOOST_AUTO_TEST_CASE (script_FindAndDelete)
 
 BOOST_AUTO_TEST_CASE (script_HasValidOps)
 
 BOOST_AUTO_TEST_CASE (bip341_keypath_test_vectors)
 
 BOOST_AUTO_TEST_CASE (compute_tapbranch)
 
 BOOST_AUTO_TEST_CASE (compute_tapleaf)
 

Variables

static const unsigned int gFlags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC
 
static ScriptErrorDesc script_errors []
 

Macro Definition Documentation

◆ CHECK_SCRIPT_DYNAMIC_SIZE

#define CHECK_SCRIPT_DYNAMIC_SIZE (   script,
  expected_size,
  expected_extra 
)
Value:
do { \
BOOST_CHECK_EQUAL((script).size(), (expected_size)); \
BOOST_CHECK_EQUAL((script).capacity(), (expected_extra)); \
BOOST_CHECK_EQUAL((script).allocated_memory(), (expected_extra)); \
} while (0)

Definition at line 1168 of file script_tests.cpp.

◆ CHECK_SCRIPT_STATIC_SIZE

#define CHECK_SCRIPT_STATIC_SIZE (   script,
  expected_size 
)
Value:
do { \
BOOST_CHECK_EQUAL((script).size(), (expected_size)); \
BOOST_CHECK_EQUAL((script).capacity(), CScriptBase::STATIC_SIZE); \
BOOST_CHECK_EQUAL((script).allocated_memory(), 0); \
} while (0)
static constexpr unsigned int STATIC_SIZE
Definition: prevector.h:41

Definition at line 1161 of file script_tests.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/19]

BOOST_AUTO_TEST_CASE ( bip341_keypath_test_vectors  )

Definition at line 1618 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/19]

BOOST_AUTO_TEST_CASE ( compute_tapbranch  )

Definition at line 1691 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/19]

BOOST_AUTO_TEST_CASE ( compute_tapleaf  )

Definition at line 1699 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/19]

BOOST_AUTO_TEST_CASE ( script_build  )

Definition at line 424 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/19]

BOOST_AUTO_TEST_CASE ( script_byte_array_u8_vector_equivalence  )

Definition at line 1488 of file script_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [6/19]

BOOST_AUTO_TEST_CASE ( script_CHECKMULTISIG12  )

Definition at line 1057 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/19]

BOOST_AUTO_TEST_CASE ( script_CHECKMULTISIG23  )

Definition at line 1086 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [8/19]

BOOST_AUTO_TEST_CASE ( script_cltv_truncated  )

Definition at line 1015 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [9/19]

BOOST_AUTO_TEST_CASE ( script_combineSigs  )

Definition at line 1265 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [10/19]

BOOST_AUTO_TEST_CASE ( script_FindAndDelete  )

Definition at line 1495 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [11/19]

BOOST_AUTO_TEST_CASE ( script_GetScriptAsm  )

Definition at line 1451 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [12/19]

BOOST_AUTO_TEST_CASE ( script_HasValidOps  )

Definition at line 1604 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [13/19]

BOOST_AUTO_TEST_CASE ( script_IsPushOnly_on_invalid_scripts  )

Definition at line 1440 of file script_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [14/19]

BOOST_AUTO_TEST_CASE ( script_json_test  )

Definition at line 901 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [15/19]

BOOST_AUTO_TEST_CASE ( script_PushData  )

Definition at line 973 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [16/19]

BOOST_AUTO_TEST_CASE ( script_size_and_capacity_test  )

Definition at line 1175 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [17/19]

BOOST_AUTO_TEST_CASE ( script_standard_push  )

Definition at line 1419 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [18/19]

BOOST_AUTO_TEST_CASE ( sign_invalid_miniscript  )

Reproduction of an exception incorrectly raised when parsing a public key inside a TapMiniscript.

Definition at line 1386 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [19/19]

BOOST_AUTO_TEST_CASE ( sign_paytoanchor  )

Definition at line 1407 of file script_tests.cpp.

Here is the call graph for this function:

◆ CombineSignatures()

SignatureData CombineSignatures ( const CTxOut txout,
const CMutableTransaction tx,
const SignatureData scriptSig1,
const SignatureData scriptSig2 
)

Definition at line 1256 of file script_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FormatScriptError()

static std::string FormatScriptError ( ScriptError_t  err)
static

Definition at line 98 of file script_tests.cpp.

Here is the caller graph for this function:

◆ FormatScriptFlags()

std::string FormatScriptFlags ( unsigned int  flags)

Definition at line 101 of file transaction_tests.cpp.

◆ GetTxoutType()

static TxoutType GetTxoutType ( const CScript output_script)
static

Return the TxoutType of a script without exposing Solver details.

Definition at line 1155 of file script_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NegateSignatureS()

static void NegateSignatureS ( std::vector< unsigned char > &  vchSig)
static

Definition at line 142 of file script_tests.cpp.

Here is the call graph for this function:

◆ ParseScriptError()

static ScriptError_t ParseScriptError ( const std::string &  name)
static

Definition at line 107 of file script_tests.cpp.

Here is the caller graph for this function:

◆ ParseScriptFlags()

unsigned int ParseScriptFlags ( std::string  strFlags)

Definition at line 76 of file transaction_tests.cpp.

Here is the caller graph for this function:

◆ sign_multisig() [1/2]

static CScript sign_multisig ( const CScript scriptPubKey,
const CKey key,
const CTransaction transaction 
)
static

Definition at line 1050 of file script_tests.cpp.

Here is the call graph for this function:

◆ sign_multisig() [2/2]

static CScript sign_multisig ( const CScript scriptPubKey,
const std::vector< CKey > &  keys,
const CTransaction transaction 
)
static

Definition at line 1026 of file script_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToScript()

template<typename T >
CScript ToScript ( const T &  byte_container)

Definition at line 1482 of file script_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ gFlags

const unsigned int gFlags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC
static

Definition at line 41 of file script_tests.cpp.

◆ script_errors

ScriptErrorDesc script_errors[]
static

Definition at line 52 of file script_tests.cpp.