Changeset View
Changeset View
Standalone View
Standalone View
src/test/checkpoints_tests.cpp
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | // Headers A and AA should be accepted | ||||
pindex = nullptr; | pindex = nullptr; | ||||
} | } | ||||
// Header B should be rejected | // Header B should be rejected | ||||
{ | { | ||||
BlockValidationState state; | BlockValidationState state; | ||||
BOOST_CHECK(!ProcessNewBlockHeaders(config, {headerB}, state, &pindex)); | BOOST_CHECK(!ProcessNewBlockHeaders(config, {headerB}, state, &pindex)); | ||||
BOOST_CHECK(state.IsInvalid()); | BOOST_CHECK(state.IsInvalid()); | ||||
BOOST_CHECK(state.GetRejectCode() == REJECT_CHECKPOINT); | |||||
BOOST_CHECK(state.GetRejectReason() == "bad-fork-prior-to-checkpoint"); | BOOST_CHECK(state.GetRejectReason() == "bad-fork-prior-to-checkpoint"); | ||||
BOOST_CHECK(pindex == nullptr); | BOOST_CHECK(pindex == nullptr); | ||||
} | } | ||||
// Sanity check to ensure header was not saved in memory | // Sanity check to ensure header was not saved in memory | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
BOOST_CHECK(LookupBlockIndex(headerB.GetHash()) == nullptr); | BOOST_CHECK(LookupBlockIndex(headerB.GetHash()) == nullptr); | ||||
} | } | ||||
// Header AB should be rejected | // Header AB should be rejected | ||||
{ | { | ||||
BlockValidationState state; | BlockValidationState state; | ||||
BOOST_CHECK( | BOOST_CHECK( | ||||
!ProcessNewBlockHeaders(config, {headerAB}, state, &pindex)); | !ProcessNewBlockHeaders(config, {headerAB}, state, &pindex)); | ||||
BOOST_CHECK(state.IsInvalid()); | BOOST_CHECK(state.IsInvalid()); | ||||
BOOST_CHECK(state.GetRejectCode() == REJECT_CHECKPOINT); | |||||
BOOST_CHECK(state.GetRejectReason() == "checkpoint mismatch"); | BOOST_CHECK(state.GetRejectReason() == "checkpoint mismatch"); | ||||
BOOST_CHECK(pindex == nullptr); | BOOST_CHECK(pindex == nullptr); | ||||
} | } | ||||
// Sanity check to ensure header was not saved in memory | // Sanity check to ensure header was not saved in memory | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
BOOST_CHECK(LookupBlockIndex(headerAB.GetHash()) == nullptr); | BOOST_CHECK(LookupBlockIndex(headerAB.GetHash()) == nullptr); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |