forked from zcash/zcash
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes zcash#1556
- Loading branch information
Showing
4 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters