PIVX Core  5.6.99
P2P Digital Currency
Checkpoints_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin Core developers
2 // Copyright (c) 2017-2020 The PIVX Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 //
7 // Unit tests for block-chain checkpoints
8 //
9 
10 #include "checkpoints.h"
11 
12 #include "uint256.h"
13 #include "test_pivx.h"
14 
15 #include <boost/test/unit_test.hpp>
16 
17 
19 
21 {
22  uint256 p259201 = uint256S("0x1c9121bf9329a6234bfd1ea2d91515f19cd96990725265253f4b164283ade5dd");
23  uint256 p623933 = uint256S("0xc7aafa648a0f1450157dc93bd4d7448913a85b7448f803b4ab970d91fc2a7da7");
24  BOOST_CHECK(Checkpoints::CheckBlock(259201, p259201));
25  BOOST_CHECK(Checkpoints::CheckBlock(623933, p623933));
26 
27 
28  // Wrong hashes at checkpoints should fail:
29  BOOST_CHECK(!Checkpoints::CheckBlock(259201, p623933));
30  BOOST_CHECK(!Checkpoints::CheckBlock(623933, p259201));
31 
32  // ... but any hash not at a checkpoint should succeed:
33  BOOST_CHECK(Checkpoints::CheckBlock(259201+1, p623933));
34  BOOST_CHECK(Checkpoints::CheckBlock(623933+1, p259201));
35 
37 }
38 
BOOST_AUTO_TEST_CASE(sanity)
256-bit opaque blob.
Definition: uint256.h:138
BOOST_AUTO_TEST_SUITE_END()
bool CheckBlock(int nHeight, const uint256 &hash, bool fMatchesCheckpoint)
Returns true if block passes checkpoint checks.
Definition: checkpoints.cpp:29
int GetTotalBlocksEstimate()
Return conservative estimate of total number of blocks, 0 if unknown.
Definition: checkpoints.cpp:75
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
#define BOOST_CHECK(expr)
Definition: object.cpp:17
Basic testing setup.
Definition: test_pivx.h:51
uint256 uint256S(const char *str)
Definition: uint256.h:157