Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/processor_tests.cpp
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | Proof GetProof() { | ||||
BOOST_CHECK(pb.addUTXO(COutPoint(coinbase.GetId(), 0), | BOOST_CHECK(pb.addUTXO(COutPoint(coinbase.GetId(), 0), | ||||
coinbase.vout[0].nValue, current_coinbase + 1, | coinbase.vout[0].nValue, current_coinbase + 1, | ||||
true, coinbaseKey)); | true, coinbaseKey)); | ||||
return pb.build(); | return pb.build(); | ||||
} | } | ||||
bool addNode(NodeId nodeid) { | bool addNode(NodeId nodeid) { | ||||
Proof proof = GetProof(); | Proof proof = GetProof(); | ||||
return m_processor->addNode(nodeid, proof, | return m_processor->addNode(nodeid, std::move(proof), | ||||
DelegationBuilder(proof).build()); | DelegationBuilder(proof).build()); | ||||
} | } | ||||
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; | ||||
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(), std::move(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 592 Lines • ▼ Show 20 Lines | 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; | ||||
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(), std::move(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 |