parent
a12eaa2bf2
commit
7ac924cdb7
|
@ -6,6 +6,8 @@
|
||||||
#ifndef BITCOIN_CONSENSUS_CONSENSUS_H
|
#ifndef BITCOIN_CONSENSUS_CONSENSUS_H
|
||||||
#define BITCOIN_CONSENSUS_CONSENSUS_H
|
#define BITCOIN_CONSENSUS_CONSENSUS_H
|
||||||
|
|
||||||
|
/** The minimum allowed transaction version (network rule) */
|
||||||
|
static const int32_t MIN_TX_VERSION = 1;
|
||||||
/** The maximum allowed size for a serialized block, in bytes (network rule) */
|
/** The maximum allowed size for a serialized block, in bytes (network rule) */
|
||||||
static const unsigned int MAX_BLOCK_SIZE = 2000000;
|
static const unsigned int MAX_BLOCK_SIZE = 2000000;
|
||||||
/** The maximum allowed number of signature check operations in a block (network rule) */
|
/** The maximum allowed number of signature check operations in a block (network rule) */
|
||||||
|
|
|
@ -94,6 +94,16 @@ TEST(checktransaction_tests, valid_transaction) {
|
||||||
EXPECT_TRUE(CheckTransactionWithoutProofVerification(tx, state));
|
EXPECT_TRUE(CheckTransactionWithoutProofVerification(tx, state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(checktransaction_tests, BadVersionTooLow) {
|
||||||
|
CMutableTransaction mtx = GetValidTransaction();
|
||||||
|
mtx.nVersion = 0;
|
||||||
|
|
||||||
|
CTransaction tx(mtx);
|
||||||
|
MockCValidationState state;
|
||||||
|
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-version-too-low", false)).Times(1);
|
||||||
|
CheckTransactionWithoutProofVerification(tx, state);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(checktransaction_tests, bad_txns_vin_empty) {
|
TEST(checktransaction_tests, bad_txns_vin_empty) {
|
||||||
CMutableTransaction mtx = GetValidTransaction();
|
CMutableTransaction mtx = GetValidTransaction();
|
||||||
mtx.vjoinsplit.resize(0);
|
mtx.vjoinsplit.resize(0);
|
||||||
|
|
|
@ -851,6 +851,12 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
|
||||||
{
|
{
|
||||||
// Basic checks that don't depend on any context
|
// Basic checks that don't depend on any context
|
||||||
|
|
||||||
|
// Check transaction version
|
||||||
|
if (tx.nVersion < MIN_TX_VERSION) {
|
||||||
|
return state.DoS(100, error("CheckTransaction(): version too low"),
|
||||||
|
REJECT_INVALID, "bad-version-too-low");
|
||||||
|
}
|
||||||
|
|
||||||
// Transactions can contain empty `vin` and `vout` so long as
|
// Transactions can contain empty `vin` and `vout` so long as
|
||||||
// `vjoinsplit` is non-empty.
|
// `vjoinsplit` is non-empty.
|
||||||
if (tx.vin.empty() && tx.vjoinsplit.empty())
|
if (tx.vin.empty() && tx.vjoinsplit.empty())
|
||||||
|
|
Loading…
Reference in New Issue