Changeset View
Changeset View
Standalone View
Standalone View
src/test/validation_block_tests.cpp
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | ProcessNewBlock(config, | ||||
std::make_shared<CBlock>(chainParams.GenesisBlock()), true, | std::make_shared<CBlock>(chainParams.GenesisBlock()), true, | ||||
&ignored); | &ignored); | ||||
SyncWithValidationInterfaceQueue(); | SyncWithValidationInterfaceQueue(); | ||||
// subscribe to events (this subscriber will validate event ordering) | // subscribe to events (this subscriber will validate event ordering) | ||||
const CBlockIndex *initial_tip = nullptr; | const CBlockIndex *initial_tip = nullptr; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
initial_tip = chainActive.Tip(); | initial_tip = ::ChainActive().Tip(); | ||||
} | } | ||||
TestSubscriber sub(initial_tip->GetBlockHash()); | TestSubscriber sub(initial_tip->GetBlockHash()); | ||||
RegisterValidationInterface(&sub); | RegisterValidationInterface(&sub); | ||||
// create a bunch of threads that repeatedly process a block generated above | // create a bunch of threads that repeatedly process a block generated above | ||||
// at random this will create parallelism and randomness inside validation - | // at random this will create parallelism and randomness inside validation - | ||||
// the ValidationInterface will subscribe to events generated during block | // the ValidationInterface will subscribe to events generated during block | ||||
// validation and assert on ordering invariance | // validation and assert on ordering invariance | ||||
Show All 23 Lines | for (auto &t : threads) { | ||||
t.join(); | t.join(); | ||||
} | } | ||||
while (GetMainSignals().CallbacksPending() > 0) { | while (GetMainSignals().CallbacksPending() > 0) { | ||||
MilliSleep(100); | MilliSleep(100); | ||||
} | } | ||||
UnregisterValidationInterface(&sub); | UnregisterValidationInterface(&sub); | ||||
BOOST_CHECK_EQUAL(sub.m_expected_tip, chainActive.Tip()->GetBlockHash()); | BOOST_CHECK_EQUAL(sub.m_expected_tip, | ||||
::ChainActive().Tip()->GetBlockHash()); | |||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |