Add check that vpubs are not both nonzero and test it.

This commit is contained in:
Taylor Hornby
2016-04-13 16:52:24 -06:00
parent d16d5ef832
commit 6ad4db2253
3 changed files with 52 additions and 9 deletions

View File

@@ -0,0 +1,26 @@
#include <gtest/gtest.h>
#include "main.h"
#include "primitives/transaction.h"
#include "consensus/validation.h"
TEST(checktransaction_tests, check_vpub_not_both_nonzero) {
CMutableTransaction tx;
tx.nVersion = 2;
{
// Ensure that values within the pour are well-formed.
CMutableTransaction newTx(tx);
CValidationState state;
state.SetPerformPourVerification(false); // don't verify the snark
newTx.vpour.push_back(CPourTx());
CPourTx *pourtx = &newTx.vpour[0];
pourtx->vpub_old = 1;
pourtx->vpub_new = 1;
EXPECT_FALSE(CheckTransaction(newTx, state));
EXPECT_EQ(state.GetRejectReason(), "bad-txns-vpubs-both-nonzero");
}
}