Hush Full Node software. We were censored from Github, this is where all development happens now. https://hush.is
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.8 KiB

#include <gtest/gtest.h>
#include <gmock/gmock.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");
}
}
class MockCValidationState : public CValidationState {
public:
MOCK_METHOD5(DoS, bool(int level, bool ret,
unsigned char chRejectCodeIn, std::string strRejectReasonIn,
bool corruptionIn));
MOCK_METHOD1(SetPerformPourVerification, bool(bool pourVerifyIn));
MOCK_METHOD0(PerformPourVerification, bool());
MOCK_METHOD3(Invalid, bool(bool ret,
unsigned char _chRejectCode, std::string _strRejectReason));
MOCK_METHOD1(Error, bool(std::string strRejectReasonIn));
MOCK_CONST_METHOD0(IsValid, bool());
MOCK_CONST_METHOD0(IsInvalid, bool());
MOCK_CONST_METHOD0(IsError, bool());
MOCK_CONST_METHOD1(IsInvalid, bool(int &nDoSOut));
MOCK_CONST_METHOD0(CorruptionPossible, bool());
MOCK_CONST_METHOD0(GetRejectCode, unsigned char());
MOCK_CONST_METHOD0(GetRejectReason, std::string());
};
TEST(checktransaction_tests, mock_proof_of_concept) {
CTransaction tx;
MockCValidationState state;
EXPECT_CALL(state, DoS(10, false, REJECT_INVALID, "bad-txns-vin-empty", false)).Times(1);
CheckTransaction(tx, state);
}