|
|
@ -5,6 +5,7 @@
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
#include "peerstats/types.hpp"
|
|
|
|
#include "peerstats/types.hpp"
|
|
|
|
#include "router_contact.hpp"
|
|
|
|
#include "router_contact.hpp"
|
|
|
|
|
|
|
|
#include "util/logging/logger.hpp"
|
|
|
|
#include "util/time.hpp"
|
|
|
|
#include "util/time.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("Test PeerDb PeerStats memory storage", "[PeerDb]")
|
|
|
|
TEST_CASE("Test PeerDb PeerStats memory storage", "[PeerDb]")
|
|
|
@ -40,6 +41,7 @@ TEST_CASE("Test PeerDb flush before load", "[PeerDb]")
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("Test PeerDb load twice", "[PeerDb]")
|
|
|
|
TEST_CASE("Test PeerDb load twice", "[PeerDb]")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
llarp::LogSilencer shutup;
|
|
|
|
llarp::PeerDb db;
|
|
|
|
llarp::PeerDb db;
|
|
|
|
CHECK_NOTHROW(db.loadDatabase(std::nullopt));
|
|
|
|
CHECK_NOTHROW(db.loadDatabase(std::nullopt));
|
|
|
|
CHECK_THROWS_WITH(db.loadDatabase(std::nullopt), "Reloading database not supported");
|
|
|
|
CHECK_THROWS_WITH(db.loadDatabase(std::nullopt), "Reloading database not supported");
|
|
|
@ -47,6 +49,7 @@ TEST_CASE("Test PeerDb load twice", "[PeerDb]")
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("Test PeerDb nukes stats on load", "[PeerDb]")
|
|
|
|
TEST_CASE("Test PeerDb nukes stats on load", "[PeerDb]")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
llarp::LogSilencer shutup;
|
|
|
|
const llarp::RouterID id = llarp::test::makeBuf<llarp::RouterID>(0x01);
|
|
|
|
const llarp::RouterID id = llarp::test::makeBuf<llarp::RouterID>(0x01);
|
|
|
|
|
|
|
|
|
|
|
|
llarp::PeerDb db;
|
|
|
|
llarp::PeerDb db;
|
|
|
@ -64,6 +67,7 @@ TEST_CASE("Test PeerDb nukes stats on load", "[PeerDb]")
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("Test PeerDb file-backed database reloads properly", "[PeerDb]")
|
|
|
|
TEST_CASE("Test PeerDb file-backed database reloads properly", "[PeerDb]")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
llarp::LogSilencer shutup;
|
|
|
|
const std::string filename = "/tmp/peerdb_test_tmp2.db.sqlite";
|
|
|
|
const std::string filename = "/tmp/peerdb_test_tmp2.db.sqlite";
|
|
|
|
const llarp::RouterID id = llarp::test::makeBuf<llarp::RouterID>(0x02);
|
|
|
|
const llarp::RouterID id = llarp::test::makeBuf<llarp::RouterID>(0x02);
|
|
|
|
|
|
|
|
|
|
|
@ -93,6 +97,7 @@ TEST_CASE("Test PeerDb file-backed database reloads properly", "[PeerDb]")
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("Test PeerDb modifyPeerStats", "[PeerDb]")
|
|
|
|
TEST_CASE("Test PeerDb modifyPeerStats", "[PeerDb]")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
llarp::LogSilencer shutup;
|
|
|
|
const llarp::RouterID id = llarp::test::makeBuf<llarp::RouterID>(0xF2);
|
|
|
|
const llarp::RouterID id = llarp::test::makeBuf<llarp::RouterID>(0xF2);
|
|
|
|
|
|
|
|
|
|
|
|
int numTimesCalled = 0;
|
|
|
|
int numTimesCalled = 0;
|
|
|
@ -117,6 +122,7 @@ TEST_CASE("Test PeerDb modifyPeerStats", "[PeerDb]")
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("Test PeerDb handleGossipedRC", "[PeerDb]")
|
|
|
|
TEST_CASE("Test PeerDb handleGossipedRC", "[PeerDb]")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
llarp::LogSilencer shutup;
|
|
|
|
const llarp::RouterID id = llarp::test::makeBuf<llarp::RouterID>(0xCA);
|
|
|
|
const llarp::RouterID id = llarp::test::makeBuf<llarp::RouterID>(0xCA);
|
|
|
|
|
|
|
|
|
|
|
|
auto rcLifetime = llarp::RouterContact::Lifetime;
|
|
|
|
auto rcLifetime = llarp::RouterContact::Lifetime;
|
|
|
@ -156,6 +162,7 @@ TEST_CASE("Test PeerDb handleGossipedRC", "[PeerDb]")
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("Test PeerDb handleGossipedRC expiry calcs", "[PeerDb]")
|
|
|
|
TEST_CASE("Test PeerDb handleGossipedRC expiry calcs", "[PeerDb]")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
llarp::LogSilencer shutup;
|
|
|
|
const llarp::RouterID id = llarp::test::makeBuf<llarp::RouterID>(0xF9);
|
|
|
|
const llarp::RouterID id = llarp::test::makeBuf<llarp::RouterID>(0xF9);
|
|
|
|
|
|
|
|
|
|
|
|
// see comments in peer_db.cpp above PeerDb::handleGossipedRC() for some context around these
|
|
|
|
// see comments in peer_db.cpp above PeerDb::handleGossipedRC() for some context around these
|
|
|
|