Changeset View
Changeset View
Standalone View
Standalone View
src/test/avalanche_tests.cpp
Show First 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | static AvalancheResponse next(AvalancheResponse &r) { | ||||
r = {r.getRound() + 1, r.getCooldown(), r.GetVotes()}; | r = {r.getRound() + 1, r.getCooldown(), r.GetVotes()}; | ||||
return copy; | return copy; | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(block_register) { | BOOST_AUTO_TEST_CASE(block_register) { | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | ||||
auto peerLogic = | auto peerLogic = std::make_unique<PeerLogicValidation>( | ||||
std::make_unique<PeerLogicValidation>(connman.get(), scheduler, false); | connman.get(), nullptr, scheduler, false); | ||||
AvalancheProcessor p(connman.get()); | AvalancheProcessor p(connman.get()); | ||||
std::vector<AvalancheBlockUpdate> updates; | std::vector<AvalancheBlockUpdate> updates; | ||||
CBlock block = CreateAndProcessBlock({}, CScript()); | CBlock block = CreateAndProcessBlock({}, CScript()); | ||||
const uint256 blockHash = block.GetHash(); | const uint256 blockHash = block.GetHash(); | ||||
const CBlockIndex *pindex = mapBlockIndex[blockHash]; | const CBlockIndex *pindex = mapBlockIndex[blockHash]; | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(block_register) { | ||||
connman->ClearNodes(); | connman->ClearNodes(); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(multi_block_register) { | BOOST_AUTO_TEST_CASE(multi_block_register) { | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | ||||
auto peerLogic = | auto peerLogic = std::make_unique<PeerLogicValidation>( | ||||
std::make_unique<PeerLogicValidation>(connman.get(), scheduler, false); | connman.get(), nullptr, scheduler, false); | ||||
AvalancheProcessor p(connman.get()); | AvalancheProcessor p(connman.get()); | ||||
CBlockIndex indexA, indexB; | CBlockIndex indexA, indexB; | ||||
std::vector<AvalancheBlockUpdate> updates; | std::vector<AvalancheBlockUpdate> updates; | ||||
// Create several nodes that support avalanche. | // Create several nodes that support avalanche. | ||||
auto avanodes = | auto avanodes = | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(multi_block_register) { | ||||
connman->ClearNodes(); | connman->ClearNodes(); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(poll_and_response) { | BOOST_AUTO_TEST_CASE(poll_and_response) { | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | ||||
auto peerLogic = | auto peerLogic = std::make_unique<PeerLogicValidation>( | ||||
std::make_unique<PeerLogicValidation>(connman.get(), scheduler, false); | connman.get(), nullptr, scheduler, false); | ||||
AvalancheProcessor p(connman.get()); | AvalancheProcessor p(connman.get()); | ||||
std::vector<AvalancheBlockUpdate> updates; | std::vector<AvalancheBlockUpdate> updates; | ||||
CBlock block = CreateAndProcessBlock({}, CScript()); | CBlock block = CreateAndProcessBlock({}, CScript()); | ||||
const uint256 blockHash = block.GetHash(); | const uint256 blockHash = block.GetHash(); | ||||
const CBlockIndex *pindex = mapBlockIndex[blockHash]; | const CBlockIndex *pindex = mapBlockIndex[blockHash]; | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | |||||
#else | #else | ||||
// TODO: Cleanup this branch when boost 1.58 is no longer supported. | // TODO: Cleanup this branch when boost 1.58 is no longer supported. | ||||
BOOST_AUTO_TEST_CASE(poll_inflight_timeout) { | BOOST_AUTO_TEST_CASE(poll_inflight_timeout) { | ||||
int64_t timeStart = GetTimeMillis(); | int64_t timeStart = GetTimeMillis(); | ||||
#endif | #endif | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | ||||
auto peerLogic = | auto peerLogic = std::make_unique<PeerLogicValidation>( | ||||
std::make_unique<PeerLogicValidation>(connman.get(), scheduler, false); | connman.get(), nullptr, scheduler, false); | ||||
AvalancheProcessor p(connman.get()); | AvalancheProcessor p(connman.get()); | ||||
std::vector<AvalancheBlockUpdate> updates; | std::vector<AvalancheBlockUpdate> updates; | ||||
CBlock block = CreateAndProcessBlock({}, CScript()); | CBlock block = CreateAndProcessBlock({}, CScript()); | ||||
const uint256 blockHash = block.GetHash(); | const uint256 blockHash = block.GetHash(); | ||||
const CBlockIndex *pindex = mapBlockIndex[blockHash]; | const CBlockIndex *pindex = mapBlockIndex[blockHash]; | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | #endif | ||||
connman->ClearNodes(); | connman->ClearNodes(); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(poll_inflight_count) { | BOOST_AUTO_TEST_CASE(poll_inflight_count) { | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | ||||
auto peerLogic = | auto peerLogic = std::make_unique<PeerLogicValidation>( | ||||
std::make_unique<PeerLogicValidation>(connman.get(), scheduler, false); | connman.get(), nullptr, scheduler, false); | ||||
AvalancheProcessor p(connman.get()); | AvalancheProcessor p(connman.get()); | ||||
// Create enough nodes so that we run into the inflight request limit. | // Create enough nodes so that we run into the inflight request limit. | ||||
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(config, NODE_AVALANCHE, *peerLogic, connman.get()); | n = ConnectNode(config, NODE_AVALANCHE, *peerLogic, connman.get()); | ||||
BOOST_CHECK(p.addPeer(n->GetId(), 0)); | BOOST_CHECK(p.addPeer(n->GetId(), 0)); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(poll_inflight_count) { | ||||
connman->ClearNodes(); | connman->ClearNodes(); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(quorum_diversity) { | BOOST_AUTO_TEST_CASE(quorum_diversity) { | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | ||||
auto peerLogic = | auto peerLogic = std::make_unique<PeerLogicValidation>( | ||||
std::make_unique<PeerLogicValidation>(connman.get(), scheduler, false); | connman.get(), nullptr, scheduler, false); | ||||
AvalancheProcessor p(connman.get()); | AvalancheProcessor p(connman.get()); | ||||
std::vector<AvalancheBlockUpdate> updates; | std::vector<AvalancheBlockUpdate> updates; | ||||
CBlock block = CreateAndProcessBlock({}, CScript()); | CBlock block = CreateAndProcessBlock({}, CScript()); | ||||
const uint256 blockHash = block.GetHash(); | const uint256 blockHash = block.GetHash(); | ||||
const CBlockIndex *pindex = mapBlockIndex[blockHash]; | const CBlockIndex *pindex = mapBlockIndex[blockHash]; | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(quorum_diversity) { | ||||
connman->ClearNodes(); | connman->ClearNodes(); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(event_loop) { | BOOST_AUTO_TEST_CASE(event_loop) { | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | ||||
auto peerLogic = | auto peerLogic = std::make_unique<PeerLogicValidation>( | ||||
std::make_unique<PeerLogicValidation>(connman.get(), scheduler, false); | connman.get(), nullptr, scheduler, false); | ||||
AvalancheProcessor p(connman.get()); | AvalancheProcessor p(connman.get()); | ||||
CScheduler s; | CScheduler s; | ||||
CBlock block = CreateAndProcessBlock({}, CScript()); | CBlock block = CreateAndProcessBlock({}, CScript()); | ||||
const uint256 blockHash = block.GetHash(); | const uint256 blockHash = block.GetHash(); | ||||
const CBlockIndex *pindex = mapBlockIndex[blockHash]; | const CBlockIndex *pindex = mapBlockIndex[blockHash]; | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |