Changeset View
Changeset View
Standalone View
Standalone View
src/test/script_p2sh_tests.cpp
// Copyright (c) 2012-2019 The Bitcoin Core developers | // Copyright (c) 2012-2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <consensus/tx_verify.h> | #include <consensus/tx_verify.h> | ||||
#include <key.h> | #include <key.h> | ||||
#include <keystore.h> | #include <keystore.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <policy/settings.h> | #include <policy/settings.h> | ||||
#include <script/ismine.h> | |||||
#include <script/script.h> | #include <script/script.h> | ||||
#include <script/script_error.h> | #include <script/script_error.h> | ||||
#include <script/sign.h> | #include <script/sign.h> | ||||
#include <tinyformat.h> | #include <tinyformat.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <test/util/setup_common.h> | #include <test/util/setup_common.h> | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(sign) { | ||||
// Spending transactions | // Spending transactions | ||||
CMutableTransaction txTo[8]; | CMutableTransaction txTo[8]; | ||||
for (int i = 0; i < 8; i++) { | for (int i = 0; i < 8; i++) { | ||||
txTo[i].vin.resize(1); | txTo[i].vin.resize(1); | ||||
txTo[i].vout.resize(1); | txTo[i].vout.resize(1); | ||||
txTo[i].vin[0].prevout = COutPoint(txFrom.GetId(), i); | txTo[i].vin[0].prevout = COutPoint(txFrom.GetId(), i); | ||||
txTo[i].vout[0].nValue = SATOSHI; | txTo[i].vout[0].nValue = SATOSHI; | ||||
BOOST_CHECK_MESSAGE(IsMine(keystore, txFrom.vout[i].scriptPubKey), | |||||
strprintf("IsMine %d", i)); | |||||
} | } | ||||
for (int i = 0; i < 8; i++) { | for (int i = 0; i < 8; i++) { | ||||
BOOST_CHECK_MESSAGE(SignSignature(keystore, CTransaction(txFrom), | BOOST_CHECK_MESSAGE(SignSignature(keystore, CTransaction(txFrom), | ||||
txTo[i], 0, | txTo[i], 0, | ||||
SigHashType().withForkId()), | SigHashType().withForkId()), | ||||
strprintf("SignSignature %d", i)); | strprintf("SignSignature %d", i)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(set) { | ||||
// Spending transactions | // Spending transactions | ||||
CMutableTransaction txTo[4]; | CMutableTransaction txTo[4]; | ||||
for (int i = 0; i < 4; i++) { | for (int i = 0; i < 4; i++) { | ||||
txTo[i].vin.resize(1); | txTo[i].vin.resize(1); | ||||
txTo[i].vout.resize(1); | txTo[i].vout.resize(1); | ||||
txTo[i].vin[0].prevout = COutPoint(txFrom.GetId(), i); | txTo[i].vin[0].prevout = COutPoint(txFrom.GetId(), i); | ||||
txTo[i].vout[0].nValue = 1 * CENT; | txTo[i].vout[0].nValue = 1 * CENT; | ||||
txTo[i].vout[0].scriptPubKey = inner[i]; | txTo[i].vout[0].scriptPubKey = inner[i]; | ||||
BOOST_CHECK_MESSAGE(IsMine(keystore, txFrom.vout[i].scriptPubKey), | |||||
strprintf("IsMine %d", i)); | |||||
} | } | ||||
for (int i = 0; i < 4; i++) { | for (int i = 0; i < 4; i++) { | ||||
BOOST_CHECK_MESSAGE(SignSignature(keystore, CTransaction(txFrom), | BOOST_CHECK_MESSAGE(SignSignature(keystore, CTransaction(txFrom), | ||||
txTo[i], 0, | txTo[i], 0, | ||||
SigHashType().withForkId()), | SigHashType().withForkId()), | ||||
strprintf("SignSignature %d", i)); | strprintf("SignSignature %d", i)); | ||||
BOOST_CHECK_MESSAGE(IsStandardTx(CTransaction(txTo[i]), reason), | BOOST_CHECK_MESSAGE(IsStandardTx(CTransaction(txTo[i]), reason), | ||||
strprintf("txTo[%d].IsStandard", i)); | strprintf("txTo[%d].IsStandard", i)); | ||||
▲ Show 20 Lines • Show All 168 Lines • Show Last 20 Lines |