Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/processor_tests.cpp
Show First 20 Lines • Show All 1,911 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(block_vote_finalization_tip) { | ||||
BOOST_CHECK(alttip->pprev == tip->pprev); | BOOST_CHECK(alttip->pprev == tip->pprev); | ||||
BOOST_CHECK(alttip->GetBlockHash() != tip->GetBlockHash()); | BOOST_CHECK(alttip->GetBlockHash() != tip->GetBlockHash()); | ||||
// Reconsider the previous tip valid, so we have concurrent tip candidates | // Reconsider the previous tip valid, so we have concurrent tip candidates | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
activeChainstate.ResetBlockFailureFlags(tip); | activeChainstate.ResetBlockFailureFlags(tip); | ||||
} | } | ||||
activeChainstate.ActivateBestChain(config, state); | activeChainstate.ActivateBestChain(state); | ||||
BOOST_CHECK(addToReconcile(tip)); | BOOST_CHECK(addToReconcile(tip)); | ||||
BOOST_CHECK(addToReconcile(alttip)); | BOOST_CHECK(addToReconcile(alttip)); | ||||
invs = getInvsForNextPoll(); | invs = getInvsForNextPoll(); | ||||
BOOST_CHECK_EQUAL(invs.size(), 12); | BOOST_CHECK_EQUAL(invs.size(), 12); | ||||
// Vote for the tip until it finalizes | // Vote for the tip until it finalizes | ||||
BlockHash tiphash = tip->GetBlockHash(); | BlockHash tiphash = tip->GetBlockHash(); | ||||
▲ Show 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(block_reconcile_initial_vote) { | ||||
// ActivateBestChain() interacts with g_avalanche, so make it happy | // ActivateBestChain() interacts with g_avalanche, so make it happy | ||||
g_avalanche = std::move(m_processor); | g_avalanche = std::move(m_processor); | ||||
// The block is not connected yet, and not added to the poll list yet | // The block is not connected yet, and not added to the poll list yet | ||||
BOOST_CHECK(AvalancheTest::getInvsForNextPoll(*g_avalanche).empty()); | BOOST_CHECK(AvalancheTest::getInvsForNextPoll(*g_avalanche).empty()); | ||||
BOOST_CHECK(!g_avalanche->isAccepted(blockindex)); | BOOST_CHECK(!g_avalanche->isAccepted(blockindex)); | ||||
// Call ActivateBestChain to connect the new block | // Call ActivateBestChain to connect the new block | ||||
BOOST_CHECK(chainstate.ActivateBestChain(config, state, block)); | BOOST_CHECK(chainstate.ActivateBestChain(state, block)); | ||||
// It is a valid block so the tip is updated | // It is a valid block so the tip is updated | ||||
BOOST_CHECK_EQUAL(chainstate.m_chain.Tip(), blockindex); | BOOST_CHECK_EQUAL(chainstate.m_chain.Tip(), blockindex); | ||||
// Check the block is added to the poll | // Check the block is added to the poll | ||||
auto invs = AvalancheTest::getInvsForNextPoll(*g_avalanche); | auto invs = AvalancheTest::getInvsForNextPoll(*g_avalanche); | ||||
BOOST_CHECK_EQUAL(invs.size(), 1); | BOOST_CHECK_EQUAL(invs.size(), 1); | ||||
BOOST_CHECK_EQUAL(invs[0].type, MSG_BLOCK); | BOOST_CHECK_EQUAL(invs[0].type, MSG_BLOCK); | ||||
BOOST_CHECK_EQUAL(invs[0].hash, blockhash); | BOOST_CHECK_EQUAL(invs[0].hash, blockhash); | ||||
▲ Show 20 Lines • Show All 303 Lines • Show Last 20 Lines |