Changeset View
Changeset View
Standalone View
Standalone View
src/test/transaction_tests.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Copyright (c) 2017-2018 The Bitcoin 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 "data/tx_invalid.json.h" | #include "data/tx_invalid.json.h" | ||||
#include "data/tx_valid.json.h" | #include "data/tx_valid.json.h" | ||||
#include "test/test_bitcoin.h" | #include "test/test_bitcoin.h" | ||||
#include "chainparams.h" // For CChainParams | |||||
#include "checkqueue.h" | #include "checkqueue.h" | ||||
#include "clientversion.h" | #include "clientversion.h" | ||||
#include "config.h" | |||||
#include "consensus/validation.h" | #include "consensus/validation.h" | ||||
#include "core_io.h" | #include "core_io.h" | ||||
#include "key.h" | #include "key.h" | ||||
#include "keystore.h" | #include "keystore.h" | ||||
#include "policy/policy.h" | #include "policy/policy.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 "script/standard.h" | #include "script/standard.h" | ||||
#include "test/jsonutil.h" | #include "test/jsonutil.h" | ||||
#include "test/scriptflags.h" | #include "test/scriptflags.h" | ||||
#include "utilstrencodings.h" | #include "utilstrencodings.h" | ||||
#include "validation.h" // For CheckRegularTransaction | #include "validation.h" // For CheckRegularTransaction and ContextualCheckTransaction | ||||
#include <map> | #include <map> | ||||
#include <string> | #include <string> | ||||
#include <boost/range/adaptor/reversed.hpp> | #include <boost/range/adaptor/reversed.hpp> | ||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
#include <univalue.h> | #include <univalue.h> | ||||
▲ Show 20 Lines • Show All 720 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(test_IsStandard) { | ||||
t.vout[1].scriptPubKey = CScript() << OP_RETURN; | t.vout[1].scriptPubKey = CScript() << OP_RETURN; | ||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason)); | BOOST_CHECK(!IsStandardTx(CTransaction(t), reason)); | ||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN; | t.vout[0].scriptPubKey = CScript() << OP_RETURN; | ||||
t.vout[1].scriptPubKey = CScript() << OP_RETURN; | t.vout[1].scriptPubKey = CScript() << OP_RETURN; | ||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason)); | BOOST_CHECK(!IsStandardTx(CTransaction(t), reason)); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(txsize_test) { | |||||
const Config &config = GetConfig(); | |||||
const int64_t magneticAnomalyActivationTime = | |||||
config.GetChainParams().GetConsensus().magneticAnomalyActivationTime; | |||||
// A minimaly sized transction. | |||||
CTransaction minTx; | |||||
CValidationState state; | |||||
BOOST_CHECK(ContextualCheckTransaction(config, minTx, state, 1234, 5678, | |||||
magneticAnomalyActivationTime - 1)); | |||||
BOOST_CHECK(!ContextualCheckTransaction(config, minTx, state, 1234, 5678, | |||||
magneticAnomalyActivationTime)); | |||||
BOOST_CHECK_EQUAL(state.GetRejectCode(), REJECT_INVALID); | |||||
BOOST_CHECK_EQUAL(state.GetRejectReason(), "bad-txns-undersize"); | |||||
} | |||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |