Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/peermanager_tests.cpp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | buildProofWithSequence(const CKey &key, | ||||
int64_t sequence) { | int64_t sequence) { | ||||
return buildProofWithOutpoints(key, outpoints, 10 * COIN, key, | return buildProofWithOutpoints(key, outpoints, 10 * COIN, key, | ||||
sequence); | sequence); | ||||
} | } | ||||
} // namespace | } // namespace | ||||
} // namespace avalanche | } // namespace avalanche | ||||
namespace { | namespace { | ||||
struct NoCoolDownFixture : public TestingSetup { | struct NoCoolDownFixture : public TestChain100Setup { | ||||
NoCoolDownFixture() { | NoCoolDownFixture() { | ||||
gArgs.ForceSetArg("-avalancheconflictingproofcooldown", "0"); | gArgs.ForceSetArg("-avalancheconflictingproofcooldown", "0"); | ||||
} | } | ||||
~NoCoolDownFixture() { | ~NoCoolDownFixture() { | ||||
gArgs.ClearForcedArg("-avalancheconflictingproofcooldown"); | gArgs.ClearForcedArg("-avalancheconflictingproofcooldown"); | ||||
} | } | ||||
}; | }; | ||||
} // namespace | } // namespace | ||||
BOOST_FIXTURE_TEST_SUITE(peermanager_tests, TestingSetup) | BOOST_FIXTURE_TEST_SUITE(peermanager_tests, TestChain100Setup) | ||||
BOOST_AUTO_TEST_CASE(select_peer_linear) { | BOOST_AUTO_TEST_CASE(select_peer_linear) { | ||||
// No peers. | // No peers. | ||||
BOOST_CHECK_EQUAL(selectPeerImpl({}, 0, 0), NO_PEER); | BOOST_CHECK_EQUAL(selectPeerImpl({}, 0, 0), NO_PEER); | ||||
BOOST_CHECK_EQUAL(selectPeerImpl({}, 1, 3), NO_PEER); | BOOST_CHECK_EQUAL(selectPeerImpl({}, 1, 3), NO_PEER); | ||||
// One peer | // One peer | ||||
const std::vector<Slot> oneslot = {{100, 100, 23}}; | const std::vector<Slot> oneslot = {{100, 100, 23}}; | ||||
▲ Show 20 Lines • Show All 559 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(orphan_proofs) { | ||||
auto key = CKey::MakeCompressedKey(); | auto key = CKey::MakeCompressedKey(); | ||||
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 = 100; | ||||
const int wrongHeight = 12345; | const int wrongHeight = 99; | ||||
const auto makeProof = [&](const COutPoint &outpoint, const int h) { | const auto makeProof = [&](const COutPoint &outpoint, const int h) { | ||||
return buildProofWithOutpoints(key, {outpoint}, v, key, 0, h); | return buildProofWithOutpoints(key, {outpoint}, v, key, 0, h); | ||||
}; | }; | ||||
auto proof1 = makeProof(outpoint1, height); | auto proof1 = makeProof(outpoint1, height); | ||||
auto proof2 = makeProof(outpoint2, height); | auto proof2 = makeProof(outpoint2, height); | ||||
auto proof3 = makeProof(outpoint3, wrongHeight); | auto proof3 = makeProof(outpoint3, wrongHeight); | ||||
▲ Show 20 Lines • Show All 1,124 Lines • Show Last 20 Lines |