Projects : bitcoin : bitcoin_dumpblock_no_losers

bitcoin/src/test/Checkpoints_tests.cpp

Dir - Raw

1//
2// Unit tests for block-chain checkpoints
3//
4#include <boost/assign/list_of.hpp> // for 'map_list_of()'
5#include <boost/test/unit_test.hpp>
6#include <boost/foreach.hpp>
7
8#include "../checkpoints.h"
9#include "../util.h"
10
11using namespace std;
12
13BOOST_AUTO_TEST_SUITE(Checkpoints_tests)
14
15BOOST_AUTO_TEST_CASE(sanity)
16{
17 uint256 p11111 = uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d");
18 uint256 p140700 = uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd");
19 BOOST_CHECK(Checkpoints::CheckBlock(11111, p11111));
20 BOOST_CHECK(Checkpoints::CheckBlock(140700, p140700));
21
22
23 // Wrong hashes at checkpoints should fail:
24 BOOST_CHECK(!Checkpoints::CheckBlock(11111, p140700));
25 BOOST_CHECK(!Checkpoints::CheckBlock(140700, p11111));
26
27 // ... but any hash not at a checkpoint should succeed:
28 BOOST_CHECK(Checkpoints::CheckBlock(11111+1, p140700));
29 BOOST_CHECK(Checkpoints::CheckBlock(140700+1, p11111));
30
31 BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 140700);
32}
33
34BOOST_AUTO_TEST_SUITE_END()