Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/peermanager_tests.cpp
Show First 20 Lines • Show All 674 Lines • ▼ Show 20 Lines | for (int i = 0; i < 10; i++) { | ||||
BOOST_CHECK(!TestPeerManager::isNodePending(pm, i)); | BOOST_CHECK(!TestPeerManager::isNodePending(pm, i)); | ||||
BOOST_CHECK(TestPeerManager::nodeBelongToPeer(pm, i, peerid)); | BOOST_CHECK(TestPeerManager::nodeBelongToPeer(pm, i, peerid)); | ||||
} | } | ||||
// Make the proof immature by reorging to a shorter chain | // Make the proof immature by reorging to a shorter chain | ||||
{ | { | ||||
BlockValidationState state; | BlockValidationState state; | ||||
chainman.ActiveChainstate().InvalidateBlock( | chainman.ActiveChainstate().InvalidateBlock( | ||||
GetConfig(), state, | state, WITH_LOCK(chainman.GetMutex(), return chainman.ActiveTip())); | ||||
WITH_LOCK(chainman.GetMutex(), return chainman.ActiveTip())); | |||||
BOOST_CHECK_EQUAL( | BOOST_CHECK_EQUAL( | ||||
WITH_LOCK(chainman.GetMutex(), return chainman.ActiveHeight()), 99); | WITH_LOCK(chainman.GetMutex(), return chainman.ActiveHeight()), 99); | ||||
} | } | ||||
pm.updatedBlockTip(); | pm.updatedBlockTip(); | ||||
BOOST_CHECK(pm.isImmature(proofid)); | BOOST_CHECK(pm.isImmature(proofid)); | ||||
BOOST_CHECK(!pm.isBoundToPeer(proofid)); | BOOST_CHECK(!pm.isBoundToPeer(proofid)); | ||||
for (int i = 0; i < 10; i++) { | for (int i = 0; i < 10; i++) { | ||||
▲ Show 20 Lines • Show All 436 Lines • ▼ Show 20 Lines | auto proof30 = buildProofWithOutpoints(key, {matureOutpoint}, | ||||
PROOF_DUST_THRESHOLD, key, 30, 99); | PROOF_DUST_THRESHOLD, key, 30, 99); | ||||
BOOST_CHECK(pm.registerProof(proof30)); | BOOST_CHECK(pm.registerProof(proof30)); | ||||
BOOST_CHECK(pm.isBoundToPeer(proof30->getId())); | BOOST_CHECK(pm.isBoundToPeer(proof30->getId())); | ||||
// Reorg to a shorter chain to make proof30 immature | // Reorg to a shorter chain to make proof30 immature | ||||
{ | { | ||||
BlockValidationState state; | BlockValidationState state; | ||||
active_chainstate.InvalidateBlock( | active_chainstate.InvalidateBlock( | ||||
GetConfig(), state, | state, WITH_LOCK(chainman.GetMutex(), return chainman.ActiveTip())); | ||||
WITH_LOCK(chainman.GetMutex(), return chainman.ActiveTip())); | |||||
BOOST_CHECK_EQUAL( | BOOST_CHECK_EQUAL( | ||||
WITH_LOCK(chainman.GetMutex(), return chainman.ActiveHeight()), 99); | WITH_LOCK(chainman.GetMutex(), return chainman.ActiveHeight()), 99); | ||||
} | } | ||||
// Check that a rescan will also select the preferred immature proof, in | // Check that a rescan will also select the preferred immature proof, in | ||||
// this case proof30 will replace immature20. | // this case proof30 will replace immature20. | ||||
pm.updatedBlockTip(); | pm.updatedBlockTip(); | ||||
▲ Show 20 Lines • Show All 1,903 Lines • Show Last 20 Lines |