Bitcoin Core 28.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
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 <univalue.h>
Include dependency graph for script_tests.cpp:

Go to the source code of this file.

Classes

struct  ScriptErrorDesc
 

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)
 
void DoTest (const CScript &scriptPubKey, const CScript &scriptSig, const CScriptWitness &scriptWitness, uint32_t flags, const std::string &message, int scriptError, CAmount nValue=0)
 
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)
 
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.
 
 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)
 
static CScript ScriptFromHex (const std::string &str)
 
 BOOST_AUTO_TEST_CASE (script_FindAndDelete)
 
 BOOST_AUTO_TEST_CASE (script_HasValidOps)
 
static CMutableTransaction TxFromHex (const std::string &str)
 
static std::vector< CTxOutTxOutsFromJSON (const UniValue &univalue)
 
static CScriptWitness ScriptWitnessFromJSON (const UniValue &univalue)
 
static std::vector< unsigned int > AllConsensusFlags ()
 
static void AssetTest (const UniValue &test, SignatureCache &signature_cache)
 
 BOOST_AUTO_TEST_CASE (script_assets_test)
 
 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 []
 
static const std::vector< unsigned int > ALL_CONSENSUS_FLAGS = AllConsensusFlags()
 Precomputed list of all valid combinations of consensus-relevant script validation flags.
 

Function Documentation

◆ AllConsensusFlags()

static std::vector< unsigned int > AllConsensusFlags ( )
static

Definition at line 1514 of file script_tests.cpp.

◆ AssetTest()

static void AssetTest ( const UniValue & test,
SignatureCache & signature_cache )
static

Definition at line 1542 of file script_tests.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [1/18]

BOOST_AUTO_TEST_CASE ( bip341_keypath_test_vectors )

Definition at line 1619 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/18]

BOOST_AUTO_TEST_CASE ( compute_tapbranch )

Definition at line 1693 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/18]

BOOST_AUTO_TEST_CASE ( compute_tapleaf )

Definition at line 1701 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/18]

BOOST_AUTO_TEST_CASE ( script_assets_test )

Definition at line 1589 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/18]

BOOST_AUTO_TEST_CASE ( script_build )

Definition at line 428 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/18]

BOOST_AUTO_TEST_CASE ( script_CHECKMULTISIG12 )

Definition at line 1032 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/18]

BOOST_AUTO_TEST_CASE ( script_CHECKMULTISIG23 )

Definition at line 1061 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [8/18]

BOOST_AUTO_TEST_CASE ( script_cltv_truncated )

Definition at line 990 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [9/18]

BOOST_AUTO_TEST_CASE ( script_combineSigs )

Definition at line 1139 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [10/18]

BOOST_AUTO_TEST_CASE ( script_FindAndDelete )

Definition at line 1361 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [11/18]

BOOST_AUTO_TEST_CASE ( script_GetScriptAsm )

Definition at line 1325 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [12/18]

BOOST_AUTO_TEST_CASE ( script_HasValidOps )

Definition at line 1470 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [13/18]

BOOST_AUTO_TEST_CASE ( script_IsPushOnly_on_invalid_scripts )

Definition at line 1314 of file script_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [14/18]

BOOST_AUTO_TEST_CASE ( script_json_test )

Definition at line 905 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [15/18]

BOOST_AUTO_TEST_CASE ( script_PushData )

Definition at line 948 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [16/18]

BOOST_AUTO_TEST_CASE ( script_standard_push )

Definition at line 1293 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [17/18]

BOOST_AUTO_TEST_CASE ( sign_invalid_miniscript )

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

Definition at line 1260 of file script_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [18/18]

BOOST_AUTO_TEST_CASE ( sign_paytoanchor )

Definition at line 1281 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 1130 of file script_tests.cpp.

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

◆ DoTest()

void DoTest ( const CScript & scriptPubKey,
const CScript & scriptSig,
const CScriptWitness & scriptWitness,
uint32_t flags,
const std::string & message,
int scriptError,
CAmount nValue = 0 )

Definition at line 115 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 95 of file script_tests.cpp.

Here is the caller graph for this function:

◆ FormatScriptFlags()

std::string FormatScriptFlags ( unsigned int flags)

Definition at line 99 of file transaction_tests.cpp.

◆ NegateSignatureS()

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

Definition at line 140 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 104 of file script_tests.cpp.

Here is the caller graph for this function:

◆ ParseScriptFlags()

unsigned int ParseScriptFlags ( std::string strFlags)

Definition at line 74 of file transaction_tests.cpp.

Here is the caller graph for this function:

◆ ScriptFromHex()

static CScript ScriptFromHex ( const std::string & str)
static

Definition at line 1355 of file script_tests.cpp.

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

◆ ScriptWitnessFromJSON()

static CScriptWitness ScriptWitnessFromJSON ( const UniValue & univalue)
static

Definition at line 1503 of file script_tests.cpp.

Here is the call graph for this function:
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 1025 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 1001 of file script_tests.cpp.

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

◆ TxFromHex()

static CMutableTransaction TxFromHex ( const std::string & str)
static

Definition at line 1484 of file script_tests.cpp.

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

◆ TxOutsFromJSON()

static std::vector< CTxOut > TxOutsFromJSON ( const UniValue & univalue)
static

Definition at line 1491 of file script_tests.cpp.

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

Variable Documentation

◆ ALL_CONSENSUS_FLAGS

const std::vector<unsigned int> ALL_CONSENSUS_FLAGS = AllConsensusFlags()
static

Precomputed list of all valid combinations of consensus-relevant script validation flags.

Definition at line 1540 of file script_tests.cpp.

◆ gFlags

const unsigned int gFlags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC
static

Definition at line 38 of file script_tests.cpp.

◆ script_errors

ScriptErrorDesc script_errors[]
static

Definition at line 49 of file script_tests.cpp.