Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/processor_tests.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | struct AvalancheTest { | ||||
static uint32_t getMinQuorumScore(const Processor &p) { | static uint32_t getMinQuorumScore(const Processor &p) { | ||||
return p.minQuorumScore; | return p.minQuorumScore; | ||||
} | } | ||||
static double getMinQuorumConnectedScoreRatio(const Processor &p) { | static double getMinQuorumConnectedScoreRatio(const Processor &p) { | ||||
return p.minQuorumConnectedScoreRatio; | return p.minQuorumConnectedScoreRatio; | ||||
} | } | ||||
static int64_t getavaproofsNodeCounter(Processor &p) { | |||||
return p.avaproofsNodeCounter; | |||||
} | |||||
static void clearavaproofsNodeCounter(Processor &p) { | static void clearavaproofsNodeCounter(Processor &p) { | ||||
p.avaproofsNodeCounter = 0; | p.avaproofsNodeCounter = 0; | ||||
} | } | ||||
}; | }; | ||||
} // namespace | } // namespace | ||||
} // namespace avalanche | } // namespace avalanche | ||||
namespace { | namespace { | ||||
▲ Show 20 Lines • Show All 1,267 Lines • ▼ Show 20 Lines | auto checkMinAvaproofsMessages = [&](int64_t minAvaproofsMessages) { | ||||
BOOST_CHECK(pm.addNode(nodeid, proof->getId())); | BOOST_CHECK(pm.addNode(nodeid, proof->getId())); | ||||
}); | }); | ||||
}; | }; | ||||
for (int64_t i = 0; i < minAvaproofsMessages - 1; i++) { | for (int64_t i = 0; i < minAvaproofsMessages - 1; i++) { | ||||
addNode(i); | addNode(i); | ||||
processor->avaproofsSent(i); | processor->avaproofsSent(i); | ||||
BOOST_CHECK_EQUAL( | BOOST_CHECK_EQUAL(processor->getAvaproofsNodeCounter(), i + 1); | ||||
AvalancheTest::getavaproofsNodeCounter(*processor), i + 1); | |||||
// Receiving again on the same node does not increase the counter | // Receiving again on the same node does not increase the counter | ||||
processor->avaproofsSent(i); | processor->avaproofsSent(i); | ||||
BOOST_CHECK_EQUAL( | BOOST_CHECK_EQUAL(processor->getAvaproofsNodeCounter(), i + 1); | ||||
AvalancheTest::getavaproofsNodeCounter(*processor), i + 1); | |||||
BOOST_CHECK(!processor->isQuorumEstablished()); | BOOST_CHECK(!processor->isQuorumEstablished()); | ||||
} | } | ||||
addNode(minAvaproofsMessages); | addNode(minAvaproofsMessages); | ||||
processor->avaproofsSent(minAvaproofsMessages); | processor->avaproofsSent(minAvaproofsMessages); | ||||
BOOST_CHECK(processor->isQuorumEstablished()); | BOOST_CHECK(processor->isQuorumEstablished()); | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |