Bitcoin Core  22.99.0
P2P Digital Currency
Typedefs | Functions | Variables
transaction_tests.cpp File Reference
#include <test/data/tx_invalid.json.h>
#include <test/data/tx_valid.json.h>
#include <test/util/setup_common.h>
#include <checkqueue.h>
#include <clientversion.h>
#include <consensus/tx_check.h>
#include <consensus/validation.h>
#include <core_io.h>
#include <key.h>
#include <policy/policy.h>
#include <policy/settings.h>
#include <script/script.h>
#include <script/script_error.h>
#include <script/sign.h>
#include <script/signingprovider.h>
#include <script/standard.h>
#include <streams.h>
#include <test/util/script.h>
#include <test/util/transaction_utils.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <validation.h>
#include <functional>
#include <map>
#include <string>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/test/unit_test.hpp>
#include <univalue.h>
Include dependency graph for transaction_tests.cpp:

Go to the source code of this file.

Typedefs

typedef std::vector< unsigned char > valtype
 

Functions

UniValue read_json (const std::string &jsondata)
 
unsigned int ParseScriptFlags (std::string strFlags)
 
bool CheckMapFlagNames ()
 
std::string FormatScriptFlags (unsigned int flags)
 
bool CheckTxScripts (const CTransaction &tx, const std::map< COutPoint, CScript > &map_prevout_scriptPubKeys, const std::map< COutPoint, int64_t > &map_prevout_values, unsigned int flags, const PrecomputedTransactionData &txdata, const std::string &strTest, bool expect_valid)
 
unsigned int TrimFlags (unsigned int flags)
 
unsigned int FillFlags (unsigned int flags)
 
std::set< unsigned int > ExcludeIndividualFlags (unsigned int flags)
 
 BOOST_AUTO_TEST_CASE (tx_valid)
 
 BOOST_AUTO_TEST_CASE (tx_invalid)
 
 BOOST_AUTO_TEST_CASE (basic_transaction_tests)
 
 BOOST_AUTO_TEST_CASE (test_Get)
 
static void CreateCreditAndSpend (const FillableSigningProvider &keystore, const CScript &outscript, CTransactionRef &output, CMutableTransaction &input, bool success=true)
 
static void CheckWithFlag (const CTransactionRef &output, const CMutableTransaction &input, uint32_t flags, bool success)
 
static CScript PushAll (const std::vector< valtype > &values)
 
static void ReplaceRedeemScript (CScript &script, const CScript &redeemScript)
 
 BOOST_AUTO_TEST_CASE (test_big_witness_transaction)
 
SignatureData CombineSignatures (const CMutableTransaction &input1, const CMutableTransaction &input2, const CTransactionRef tx)
 
 BOOST_AUTO_TEST_CASE (test_witness)
 
 BOOST_AUTO_TEST_CASE (test_IsStandard)
 

Variables

static std::map< std::string, unsigned int > mapFlagNames
 

Typedef Documentation

◆ valtype

typedef std::vector<unsigned char> valtype

Definition at line 39 of file transaction_tests.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/7]

BOOST_AUTO_TEST_CASE ( basic_transaction_tests  )

Definition at line 369 of file transaction_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/7]

BOOST_AUTO_TEST_CASE ( test_big_witness_transaction  )

Definition at line 483 of file transaction_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/7]

BOOST_AUTO_TEST_CASE ( test_Get  )

Definition at line 385 of file transaction_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/7]

BOOST_AUTO_TEST_CASE ( test_IsStandard  )

Definition at line 748 of file transaction_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/7]

BOOST_AUTO_TEST_CASE ( test_witness  )

Definition at line 568 of file transaction_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/7]

BOOST_AUTO_TEST_CASE ( tx_invalid  )

Definition at line 278 of file transaction_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/7]

BOOST_AUTO_TEST_CASE ( tx_valid  )

Definition at line 189 of file transaction_tests.cpp.

Here is the call graph for this function:

◆ CheckMapFlagNames()

bool CheckMapFlagNames ( )

Definition at line 86 of file transaction_tests.cpp.

Here is the caller graph for this function:

◆ CheckTxScripts()

bool CheckTxScripts ( const CTransaction tx,
const std::map< COutPoint, CScript > &  map_prevout_scriptPubKeys,
const std::map< COutPoint, int64_t > &  map_prevout_values,
unsigned int  flags,
const PrecomputedTransactionData txdata,
const std::string &  strTest,
bool  expect_valid 
)

Definition at line 114 of file transaction_tests.cpp.

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

◆ CheckWithFlag()

static void CheckWithFlag ( const CTransactionRef output,
const CMutableTransaction input,
uint32_t  flags,
bool  success 
)
static

Definition at line 449 of file transaction_tests.cpp.

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

◆ CombineSignatures()

SignatureData CombineSignatures ( const CMutableTransaction input1,
const CMutableTransaction input2,
const CTransactionRef  tx 
)

Definition at line 559 of file transaction_tests.cpp.

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

◆ CreateCreditAndSpend()

static void CreateCreditAndSpend ( const FillableSigningProvider keystore,
const CScript outscript,
CTransactionRef output,
CMutableTransaction input,
bool  success = true 
)
static

Definition at line 411 of file transaction_tests.cpp.

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

◆ ExcludeIndividualFlags()

std::set<unsigned int> ExcludeIndividualFlags ( unsigned int  flags)

Definition at line 175 of file transaction_tests.cpp.

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

◆ FillFlags()

unsigned int FillFlags ( unsigned int  flags)

Definition at line 160 of file transaction_tests.cpp.

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

◆ FormatScriptFlags()

std::string FormatScriptFlags ( unsigned int  flags)

Definition at line 95 of file transaction_tests.cpp.

◆ ParseScriptFlags()

unsigned int ParseScriptFlags ( std::string  strFlags)

Definition at line 68 of file transaction_tests.cpp.

Here is the caller graph for this function:

◆ PushAll()

static CScript PushAll ( const std::vector< valtype > &  values)
static

Definition at line 457 of file transaction_tests.cpp.

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

◆ read_json()

UniValue read_json ( const std::string &  jsondata)

Definition at line 42 of file script_tests.cpp.

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

◆ ReplaceRedeemScript()

static void ReplaceRedeemScript ( CScript script,
const CScript redeemScript 
)
static

Definition at line 474 of file transaction_tests.cpp.

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

◆ TrimFlags()

unsigned int TrimFlags ( unsigned int  flags)

Definition at line 149 of file transaction_tests.cpp.

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

Variable Documentation

◆ mapFlagNames

std::map<std::string, unsigned int> mapFlagNames
static
Initial value:
= {
{std::string("P2SH"), (unsigned int)SCRIPT_VERIFY_P2SH},
{std::string("STRICTENC"), (unsigned int)SCRIPT_VERIFY_STRICTENC},
{std::string("DERSIG"), (unsigned int)SCRIPT_VERIFY_DERSIG},
{std::string("LOW_S"), (unsigned int)SCRIPT_VERIFY_LOW_S},
{std::string("SIGPUSHONLY"), (unsigned int)SCRIPT_VERIFY_SIGPUSHONLY},
{std::string("MINIMALDATA"), (unsigned int)SCRIPT_VERIFY_MINIMALDATA},
{std::string("NULLDUMMY"), (unsigned int)SCRIPT_VERIFY_NULLDUMMY},
{std::string("DISCOURAGE_UPGRADABLE_NOPS"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS},
{std::string("CLEANSTACK"), (unsigned int)SCRIPT_VERIFY_CLEANSTACK},
{std::string("MINIMALIF"), (unsigned int)SCRIPT_VERIFY_MINIMALIF},
{std::string("NULLFAIL"), (unsigned int)SCRIPT_VERIFY_NULLFAIL},
{std::string("CHECKLOCKTIMEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY},
{std::string("CHECKSEQUENCEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKSEQUENCEVERIFY},
{std::string("WITNESS"), (unsigned int)SCRIPT_VERIFY_WITNESS},
{std::string("DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM},
{std::string("WITNESS_PUBKEYTYPE"), (unsigned int)SCRIPT_VERIFY_WITNESS_PUBKEYTYPE},
{std::string("CONST_SCRIPTCODE"), (unsigned int)SCRIPT_VERIFY_CONST_SCRIPTCODE},
{std::string("TAPROOT"), (unsigned int)SCRIPT_VERIFY_TAPROOT},
{std::string("DISCOURAGE_UPGRADABLE_PUBKEYTYPE"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE},
{std::string("DISCOURAGE_OP_SUCCESS"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_OP_SUCCESS},
{std::string("DISCOURAGE_UPGRADABLE_TAPROOT_VERSION"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION},
}

Definition at line 44 of file transaction_tests.cpp.

SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM
@ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM
Definition: interpreter.h:109
SCRIPT_VERIFY_CLEANSTACK
@ SCRIPT_VERIFY_CLEANSTACK
Definition: interpreter.h:91
SCRIPT_VERIFY_MINIMALIF
@ SCRIPT_VERIFY_MINIMALIF
Definition: interpreter.h:115
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS
@ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS
Definition: interpreter.h:82
SCRIPT_VERIFY_TAPROOT
@ SCRIPT_VERIFY_TAPROOT
Definition: interpreter.h:131
SCRIPT_VERIFY_SIGPUSHONLY
@ SCRIPT_VERIFY_SIGPUSHONLY
Definition: interpreter.h:64
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION
@ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION
Definition: interpreter.h:135
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE
@ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE
Definition: interpreter.h:141
SCRIPT_VERIFY_NULLDUMMY
@ SCRIPT_VERIFY_NULLDUMMY
Definition: interpreter.h:61
SCRIPT_VERIFY_WITNESS
@ SCRIPT_VERIFY_WITNESS
Definition: interpreter.h:105
SCRIPT_VERIFY_CHECKSEQUENCEVERIFY
@ SCRIPT_VERIFY_CHECKSEQUENCEVERIFY
Definition: interpreter.h:101
SCRIPT_VERIFY_DISCOURAGE_OP_SUCCESS
@ SCRIPT_VERIFY_DISCOURAGE_OP_SUCCESS
Definition: interpreter.h:138
SCRIPT_VERIFY_MINIMALDATA
@ SCRIPT_VERIFY_MINIMALDATA
Definition: interpreter.h:70
SCRIPT_VERIFY_WITNESS_PUBKEYTYPE
@ SCRIPT_VERIFY_WITNESS_PUBKEYTYPE
Definition: interpreter.h:123
SCRIPT_VERIFY_LOW_S
@ SCRIPT_VERIFY_LOW_S
Definition: interpreter.h:58
SCRIPT_VERIFY_P2SH
@ SCRIPT_VERIFY_P2SH
Definition: interpreter.h:46
SCRIPT_VERIFY_DERSIG
@ SCRIPT_VERIFY_DERSIG
Definition: interpreter.h:54
SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY
@ SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY
Definition: interpreter.h:96
SCRIPT_VERIFY_CONST_SCRIPTCODE
@ SCRIPT_VERIFY_CONST_SCRIPTCODE
Definition: interpreter.h:127
SCRIPT_VERIFY_NULLFAIL
@ SCRIPT_VERIFY_NULLFAIL
Definition: interpreter.h:119
SCRIPT_VERIFY_STRICTENC
@ SCRIPT_VERIFY_STRICTENC
Definition: interpreter.h:51