2014-03-18 10:11:00 +01:00
|
|
|
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2014-03-18 10:11:00 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2011-09-08 22:50:58 +02:00
|
|
|
//
|
|
|
|
// Unit tests for block-chain checkpoints
|
|
|
|
//
|
|
|
|
|
2013-04-13 07:13:08 +02:00
|
|
|
#include "checkpoints.h"
|
|
|
|
|
|
|
|
#include "uint256.h"
|
|
|
|
|
|
|
|
#include <boost/test/unit_test.hpp>
|
2011-09-08 22:50:58 +02:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE(Checkpoints_tests)
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(sanity)
|
|
|
|
{
|
2014-12-16 14:50:05 +01:00
|
|
|
uint256 p11111 = uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d");
|
|
|
|
uint256 p134444 = uint256S("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe");
|
2011-09-08 22:50:58 +02:00
|
|
|
BOOST_CHECK(Checkpoints::CheckBlock(11111, p11111));
|
2012-06-19 21:48:29 +02:00
|
|
|
BOOST_CHECK(Checkpoints::CheckBlock(134444, p134444));
|
2011-09-08 22:50:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
// Wrong hashes at checkpoints should fail:
|
2012-06-19 21:48:29 +02:00
|
|
|
BOOST_CHECK(!Checkpoints::CheckBlock(11111, p134444));
|
|
|
|
BOOST_CHECK(!Checkpoints::CheckBlock(134444, p11111));
|
2011-09-08 22:50:58 +02:00
|
|
|
|
|
|
|
// ... but any hash not at a checkpoint should succeed:
|
2012-06-19 21:48:29 +02:00
|
|
|
BOOST_CHECK(Checkpoints::CheckBlock(11111+1, p134444));
|
|
|
|
BOOST_CHECK(Checkpoints::CheckBlock(134444+1, p11111));
|
2011-09-08 22:50:58 +02:00
|
|
|
|
2012-06-19 21:48:29 +02:00
|
|
|
BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 134444);
|
2011-09-08 22:50:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|