Jack Grigg
8 years ago
4 changed files with 39 additions and 0 deletions
@ -0,0 +1,31 @@ |
|||
#include <gtest/gtest.h> |
|||
#include <gmock/gmock.h> |
|||
|
|||
#include "consensus/validation.h" |
|||
#include "main.h" |
|||
|
|||
class MockCValidationState : public CValidationState { |
|||
public: |
|||
MOCK_METHOD5(DoS, bool(int level, bool ret, |
|||
unsigned char chRejectCodeIn, std::string strRejectReasonIn, |
|||
bool corruptionIn)); |
|||
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(CheckBlock, VersionTooLow) { |
|||
CBlock block; |
|||
block.nVersion = 1; |
|||
|
|||
MockCValidationState state; |
|||
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "version-too-low", false)).Times(1); |
|||
EXPECT_FALSE(CheckBlock(block, state, false, false)); |
|||
} |
Loading…
Reference in new issue