You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Checkpoints_tests.cpp 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (c) 2011-2013 The Bitcoin Core developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. //
  5. // Unit tests for block-chain checkpoints
  6. //
  7. #include "checkpoints.h"
  8. #include "uint256.h"
  9. #include "test/test_bitcoin.h"
  10. #include "chainparams.h"
  11. #include <boost/test/unit_test.hpp>
  12. using namespace std;
  13. BOOST_FIXTURE_TEST_SUITE(Checkpoints_tests, BasicTestingSetup)
  14. BOOST_AUTO_TEST_CASE(sanity)
  15. {
  16. const Checkpoints::CCheckpointData& checkpoints = Params(CBaseChainParams::MAIN).Checkpoints();
  17. uint256 p11111 = uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d");
  18. uint256 p134444 = uint256S("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe");
  19. BOOST_CHECK(Checkpoints::CheckBlock(checkpoints, 11111, p11111));
  20. BOOST_CHECK(Checkpoints::CheckBlock(checkpoints, 134444, p134444));
  21. // Wrong hashes at checkpoints should fail:
  22. BOOST_CHECK(!Checkpoints::CheckBlock(checkpoints, 11111, p134444));
  23. BOOST_CHECK(!Checkpoints::CheckBlock(checkpoints, 134444, p11111));
  24. // ... but any hash not at a checkpoint should succeed:
  25. BOOST_CHECK(Checkpoints::CheckBlock(checkpoints, 11111+1, p134444));
  26. BOOST_CHECK(Checkpoints::CheckBlock(checkpoints, 134444+1, p11111));
  27. BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate(checkpoints) >= 134444);
  28. }
  29. BOOST_AUTO_TEST_SUITE_END()