Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/processor_tests.cpp
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | CNode *ConnectNode(ServiceFlags nServices) { | ||||
node->nVersion = 1; | node->nVersion = 1; | ||||
node->fSuccessfullyConnected = true; | node->fSuccessfullyConnected = true; | ||||
node->m_avalanche_state = std::make_unique<CNode::AvalancheState>(); | node->m_avalanche_state = std::make_unique<CNode::AvalancheState>(); | ||||
m_connman->AddNode(*node); | m_connman->AddNode(*node); | ||||
return node; | return node; | ||||
} | } | ||||
size_t next_coinbase = 0; | |||||
ProofRef GetProof() { | ProofRef GetProof() { | ||||
size_t current_coinbase = next_coinbase++; | const CKey key = CKey::MakeCompressedKey(); | ||||
const CTransaction &coinbase = *m_coinbase_txns[current_coinbase]; | const COutPoint outpoint{TxId(GetRandHash()), 0}; | ||||
CScript script = GetScriptForDestination(PKHash(key.GetPubKey())); | |||||
const Amount amount = PROOF_DUST_THRESHOLD; | |||||
const uint32_t height = 100; | |||||
LOCK(cs_main); | |||||
CCoinsViewCache &coins = | |||||
Assert(m_node.chainman)->ActiveChainstate().CoinsTip(); | |||||
coins.AddCoin(outpoint, Coin(CTxOut(amount, script), height, false), | |||||
false); | |||||
ProofBuilder pb(0, 0, masterpriv); | ProofBuilder pb(0, 0, masterpriv); | ||||
BOOST_CHECK(pb.addUTXO(COutPoint(coinbase.GetId(), 0), | BOOST_CHECK(pb.addUTXO(outpoint, amount, height, false, key)); | ||||
coinbase.vout[0].nValue, current_coinbase + 1, | |||||
true, coinbaseKey)); | |||||
return pb.build(); | return pb.build(); | ||||
} | } | ||||
bool addNode(NodeId nodeid, const ProofId &proofid) { | bool addNode(NodeId nodeid, const ProofId &proofid) { | ||||
return m_processor->withPeerManager([&](avalanche::PeerManager &pm) { | return m_processor->withPeerManager([&](avalanche::PeerManager &pm) { | ||||
return pm.addNode(nodeid, proofid); | return pm.addNode(nodeid, proofid); | ||||
}); | }); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,472 Lines • Show Last 20 Lines |