Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/processor_tests.cpp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | CNode *ConnectNode(ServiceFlags nServices) { | ||||
node->nVersion = 1; | node->nVersion = 1; | ||||
node->fSuccessfullyConnected = true; | node->fSuccessfullyConnected = true; | ||||
m_connman->AddNode(*node); | m_connman->AddNode(*node); | ||||
return node; | return node; | ||||
} | } | ||||
size_t next_coinbase = 0; | size_t next_coinbase = 0; | ||||
Proof GetProof() { | std::shared_ptr<Proof> GetProof() { | ||||
size_t current_coinbase = next_coinbase++; | size_t current_coinbase = next_coinbase++; | ||||
const CTransaction &coinbase = *m_coinbase_txns[current_coinbase]; | const CTransaction &coinbase = *m_coinbase_txns[current_coinbase]; | ||||
ProofBuilder pb(0, 0, masterpriv.GetPubKey()); | ProofBuilder pb(0, 0, masterpriv.GetPubKey()); | ||||
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 std::make_shared<Proof>(pb.build()); | ||||
} | } | ||||
bool addNode(NodeId nodeid) { | bool addNode(NodeId nodeid) { | ||||
Proof proof = GetProof(); | auto proof = GetProof(); | ||||
return m_processor->addNode(nodeid, proof, | return m_processor->addNode(nodeid, *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(); | auto 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(), proof, dg)); | ||||
} | } | ||||
return nodes; | return nodes; | ||||
▲ Show 20 Lines • Show All 591 Lines • ▼ Show 20 Lines | for (int i = 0; i < 10; i++) { | ||||
BOOST_CHECK( | BOOST_CHECK( | ||||
!m_processor->registerVotes(avanodeid, next(resp), updates)); | !m_processor->registerVotes(avanodeid, next(resp), updates)); | ||||
} | } | ||||
} | } | ||||
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(); | auto 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(), proof, dg)); | ||||
} | } | ||||
// Add a block to poll | // Add a block to poll | ||||
▲ Show 20 Lines • Show All 218 Lines • Show Last 20 Lines |