Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/processor_tests.cpp
Show First 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | CNode *ConnectNode(const Config &config, ServiceFlags nServices, | ||||
return node; | return node; | ||||
} | } | ||||
std::array<CNode *, 8> ConnectNodes(const Config &config, Processor &p, | std::array<CNode *, 8> ConnectNodes(const Config &config, Processor &p, | ||||
ServiceFlags nServices, | ServiceFlags nServices, | ||||
PeerLogicValidation &peerLogic, | PeerLogicValidation &peerLogic, | ||||
CConnmanTest *connman) { | CConnmanTest *connman) { | ||||
PeerManager &pm = AvalancheTest::getPeerManager(p); | PeerManager &pm = AvalancheTest::getPeerManager(p); | ||||
PeerId pid = pm.addPeer(100); | Proof proof(100); | ||||
std::array<CNode *, 8> nodes; | std::array<CNode *, 8> nodes; | ||||
for (CNode *&n : nodes) { | for (CNode *&n : nodes) { | ||||
n = ConnectNode(config, nServices, peerLogic, connman); | n = ConnectNode(config, nServices, peerLogic, connman); | ||||
BOOST_CHECK(pm.addNodeToPeer(pid, n->GetId(), CPubKey())); | BOOST_CHECK(pm.addNode(proof, n->GetId(), CPubKey())); | ||||
} | } | ||||
return nodes; | return nodes; | ||||
} | } | ||||
static Response next(Response &r) { | static Response next(Response &r) { | ||||
auto copy = r; | auto copy = r; | ||||
r = {r.getRound() + 1, r.getCooldown(), r.GetVotes()}; | r = {r.getRound() + 1, r.getCooldown(), r.GetVotes()}; | ||||
▲ Show 20 Lines • Show All 493 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(poll_inflight_count) { | ||||
auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | ||||
auto peerLogic = std::make_unique<PeerLogicValidation>( | auto peerLogic = std::make_unique<PeerLogicValidation>( | ||||
connman.get(), nullptr, *m_node.scheduler, false); | connman.get(), nullptr, *m_node.scheduler, false); | ||||
Processor p(connman.get()); | Processor p(connman.get()); | ||||
// Create enough nodes so that we run into the inflight request limit. | // Create enough nodes so that we run into the inflight request limit. | ||||
PeerManager &pm = AvalancheTest::getPeerManager(p); | PeerManager &pm = AvalancheTest::getPeerManager(p); | ||||
PeerId pid = pm.addPeer(100); | Proof proof(100); | ||||
std::array<CNode *, AVALANCHE_MAX_INFLIGHT_POLL + 1> nodes; | std::array<CNode *, AVALANCHE_MAX_INFLIGHT_POLL + 1> nodes; | ||||
for (auto &n : nodes) { | for (auto &n : nodes) { | ||||
n = ConnectNode(config, NODE_AVALANCHE, *peerLogic, connman.get()); | n = ConnectNode(config, NODE_AVALANCHE, *peerLogic, connman.get()); | ||||
BOOST_CHECK(pm.addNodeToPeer(pid, n->GetId(), CPubKey())); | BOOST_CHECK(pm.addNode(proof, n->GetId(), CPubKey())); | ||||
} | } | ||||
// 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 230 Lines • Show Last 20 Lines |