Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/processor_tests.cpp
Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | struct AvalancheTestingSetup : public TestChain100Setup { | ||||
} | } | ||||
std::array<CNode *, 8> ConnectNodes() { | std::array<CNode *, 8> ConnectNodes() { | ||||
avalanche::PeerManager &pm = getPeerManager(); | avalanche::PeerManager &pm = getPeerManager(); | ||||
Proof proof = GetProof(); | Proof proof = GetProof(); | ||||
Delegation dg = DelegationBuilder(proof).build(); | Delegation dg = DelegationBuilder(proof).build(); | ||||
std::array<CNode *, 8> nodes; | std::array<CNode *, 8> nodes; | ||||
std::shared_ptr<Proof> shared_proof = | |||||
std::make_shared<Proof>(std::move(proof)); | |||||
for (CNode *&n : nodes) { | for (CNode *&n : nodes) { | ||||
n = ConnectNode(NODE_AVALANCHE); | n = ConnectNode(NODE_AVALANCHE); | ||||
BOOST_CHECK(pm.addNode(n->GetId(), proof, dg)); | BOOST_CHECK(pm.addNode(n->GetId(), shared_proof, dg)); | ||||
} | } | ||||
return nodes; | return nodes; | ||||
} | } | ||||
void runEventLoop() { AvalancheTest::runEventLoop(*m_processor); } | void runEventLoop() { AvalancheTest::runEventLoop(*m_processor); } | ||||
NodeId getSuitableNodeToQuery() { | NodeId getSuitableNodeToQuery() { | ||||
▲ Show 20 Lines • Show All 590 Lines • ▼ Show 20 Lines | |||||
BOOST_AUTO_TEST_CASE(poll_inflight_count) { | BOOST_AUTO_TEST_CASE(poll_inflight_count) { | ||||
// Create enough nodes so that we run into the inflight request limit. | // Create enough nodes so that we run into the inflight request limit. | ||||
avalanche::PeerManager &pm = getPeerManager(); | avalanche::PeerManager &pm = getPeerManager(); | ||||
Proof proof = GetProof(); | Proof proof = GetProof(); | ||||
Delegation dg = DelegationBuilder(proof).build(); | Delegation dg = DelegationBuilder(proof).build(); | ||||
std::array<CNode *, AVALANCHE_MAX_INFLIGHT_POLL + 1> nodes; | std::array<CNode *, AVALANCHE_MAX_INFLIGHT_POLL + 1> nodes; | ||||
std::shared_ptr<Proof> shared_proof = | |||||
std::make_shared<Proof>(std::move(proof)); | |||||
for (auto &n : nodes) { | for (auto &n : nodes) { | ||||
n = ConnectNode(NODE_AVALANCHE); | n = ConnectNode(NODE_AVALANCHE); | ||||
BOOST_CHECK(pm.addNode(n->GetId(), proof, dg)); | BOOST_CHECK(pm.addNode(n->GetId(), shared_proof, dg)); | ||||
} | } | ||||
// Add a block to poll | // Add a block to poll | ||||
CBlock block = CreateAndProcessBlock({}, CScript()); | CBlock block = CreateAndProcessBlock({}, CScript()); | ||||
const BlockHash blockHash = block.GetHash(); | const BlockHash blockHash = block.GetHash(); | ||||
const CBlockIndex *pindex; | const CBlockIndex *pindex; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
▲ Show 20 Lines • Show All 213 Lines • Show Last 20 Lines |