39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
//
|
|
// Unit tests for block-chain checkpoints
|
|
//
|
|
|
|
#include "checkpoints.h"
|
|
|
|
#include "uint256.h"
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
using namespace std;
|
|
|
|
BOOST_AUTO_TEST_SUITE(Checkpoints_tests)
|
|
|
|
BOOST_AUTO_TEST_CASE(sanity)
|
|
{
|
|
uint256 p1500 = uint256("0x841a2965955dd288cfa707a755d05a54e45f8bd476835ec9af4402a2b59a2967");
|
|
uint256 p120000 = uint256("0xbd9d26924f05f6daa7f0155f32828ec89e8e29cee9e7121b026a7a3552ac6131");
|
|
BOOST_CHECK(Checkpoints::CheckBlock(1500, p1500));
|
|
BOOST_CHECK(Checkpoints::CheckBlock(120000, p120000));
|
|
|
|
|
|
// Wrong hashes at checkpoints should fail:
|
|
BOOST_CHECK(!Checkpoints::CheckBlock(1500, p120000));
|
|
BOOST_CHECK(!Checkpoints::CheckBlock(120000, p1500));
|
|
|
|
// ... but any hash not at a checkpoint should succeed:
|
|
BOOST_CHECK(Checkpoints::CheckBlock(1500+1, p120000));
|
|
BOOST_CHECK(Checkpoints::CheckBlock(120000+1, p1500));
|
|
|
|
BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 120000);
|
|
}
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|