Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/peermanager_tests.cpp
Show First 20 Lines • Show All 453 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(node_binding) { | ||||
} | } | ||||
BOOST_CHECK(pm.verify()); | BOOST_CHECK(pm.verify()); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(node_binding_reorg) { | BOOST_AUTO_TEST_CASE(node_binding_reorg) { | ||||
avalanche::PeerManager pm; | avalanche::PeerManager pm; | ||||
ProofBuilder pb(0, 0, CPubKey()); | ProofBuilder pb(0, 0, CPubKey()); | ||||
CKey key; | auto key = CKey::MakeCompressedKey(); | ||||
key.MakeNewKey(true); | |||||
const CScript script = GetScriptForDestination(PKHash(key.GetPubKey())); | const CScript script = GetScriptForDestination(PKHash(key.GetPubKey())); | ||||
COutPoint utxo(TxId(GetRandHash()), 0); | COutPoint utxo(TxId(GetRandHash()), 0); | ||||
Amount amount = 1 * COIN; | Amount amount = 1 * COIN; | ||||
const int height = 1234; | const int height = 1234; | ||||
pb.addUTXO(utxo, amount, height, false, key); | pb.addUTXO(utxo, amount, height, false, key); | ||||
auto proof = std::make_shared<Proof>(pb.build()); | auto proof = std::make_shared<Proof>(pb.build()); | ||||
const ProofId &proofid = proof->getId(); | const ProofId &proofid = proof->getId(); | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(node_binding_reorg) { | ||||
for (int i = 0; i < 10; i++) { | for (int i = 0; i < 10; i++) { | ||||
BOOST_CHECK(!TestPeerManager::isNodePending(pm, i)); | BOOST_CHECK(!TestPeerManager::isNodePending(pm, i)); | ||||
BOOST_CHECK(TestPeerManager::nodeBelongToPeer(pm, i, peerid)); | BOOST_CHECK(TestPeerManager::nodeBelongToPeer(pm, i, peerid)); | ||||
} | } | ||||
BOOST_CHECK(pm.verify()); | BOOST_CHECK(pm.verify()); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(proof_conflict) { | BOOST_AUTO_TEST_CASE(proof_conflict) { | ||||
CKey key; | auto key = CKey::MakeCompressedKey(); | ||||
key.MakeNewKey(true); | |||||
const CScript script = GetScriptForDestination(PKHash(key.GetPubKey())); | const CScript script = GetScriptForDestination(PKHash(key.GetPubKey())); | ||||
TxId txid1(GetRandHash()); | TxId txid1(GetRandHash()); | ||||
TxId txid2(GetRandHash()); | TxId txid2(GetRandHash()); | ||||
BOOST_CHECK(txid1 != txid2); | BOOST_CHECK(txid1 != txid2); | ||||
const Amount v = 5 * COIN; | const Amount v = 5 * COIN; | ||||
const int height = 1234; | const int height = 1234; | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(proof_conflict) { | ||||
// Mutliple inputs, collision on both inputs. | // Mutliple inputs, collision on both inputs. | ||||
BOOST_CHECK_EQUAL(getPeerId({COutPoint(txid1, 0), COutPoint(txid2, 2)}), | BOOST_CHECK_EQUAL(getPeerId({COutPoint(txid1, 0), COutPoint(txid2, 2)}), | ||||
NO_PEER); | NO_PEER); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(orphan_proofs) { | BOOST_AUTO_TEST_CASE(orphan_proofs) { | ||||
avalanche::PeerManager pm; | avalanche::PeerManager pm; | ||||
CKey key; | auto key = CKey::MakeCompressedKey(); | ||||
key.MakeNewKey(true); | |||||
const CScript script = GetScriptForDestination(PKHash(key.GetPubKey())); | const CScript script = GetScriptForDestination(PKHash(key.GetPubKey())); | ||||
COutPoint outpoint1 = COutPoint(TxId(GetRandHash()), 0); | COutPoint outpoint1 = COutPoint(TxId(GetRandHash()), 0); | ||||
COutPoint outpoint2 = COutPoint(TxId(GetRandHash()), 0); | COutPoint outpoint2 = COutPoint(TxId(GetRandHash()), 0); | ||||
COutPoint outpoint3 = COutPoint(TxId(GetRandHash()), 0); | COutPoint outpoint3 = COutPoint(TxId(GetRandHash()), 0); | ||||
const Amount v = 5 * COIN; | const Amount v = 5 * COIN; | ||||
const int height = 1234; | const int height = 1234; | ||||
▲ Show 20 Lines • Show All 184 Lines • Show Last 20 Lines |