mirror of https://github.com/oxen-io/lokinet
that's dumb af, use std::unique_ptr
parent
d6c42c4a30
commit
17297837d9
@ -0,0 +1,33 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <llarp/aligned.hpp>
|
||||
|
||||
using Buffer_t = llarp::AlignedBuffer< 32 >;
|
||||
using Map_t = std::unordered_map< Buffer_t, int, Buffer_t::Hash >;
|
||||
|
||||
struct AlignedBufferTest : public ::testing::Test
|
||||
{
|
||||
AlignedBufferTest()
|
||||
{
|
||||
llarp_crypto_init(&crypto);
|
||||
}
|
||||
|
||||
llarp_crypto crypto;
|
||||
};
|
||||
|
||||
TEST_F(AlignedBufferTest, TestHash)
|
||||
{
|
||||
Buffer_t k, other_k;
|
||||
k.Randomize();
|
||||
other_k.Randomize();
|
||||
Map_t m;
|
||||
ASSERT_TRUE(m.empty());
|
||||
ASSERT_TRUE(m.emplace(k, 1).second);
|
||||
ASSERT_TRUE(m.find(k) != m.end());
|
||||
ASSERT_TRUE(m[k] == 1);
|
||||
ASSERT_FALSE(m.find(other_k) != m.end());
|
||||
ASSERT_TRUE(m.size() == 1);
|
||||
Buffer_t k_copy = k;
|
||||
ASSERT_FALSE(m.emplace(k_copy, 2).second);
|
||||
ASSERT_FALSE(m[k_copy] == 2);
|
||||
ASSERT_TRUE(m[k_copy] == 1);
|
||||
};
|
@ -0,0 +1,30 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <llarp/exit.hpp>
|
||||
#include "router.hpp"
|
||||
|
||||
struct ExitTest : public ::testing::Test
|
||||
{
|
||||
ExitTest()
|
||||
{
|
||||
llarp_crypto_init(&r.crypto);
|
||||
}
|
||||
llarp_router r;
|
||||
};
|
||||
|
||||
TEST_F(ExitTest, AddMultipleIP)
|
||||
{
|
||||
llarp::PubKey pk;
|
||||
pk.Randomize();
|
||||
llarp::PathID_t firstPath, secondPath;
|
||||
firstPath.Randomize();
|
||||
secondPath.Randomize();
|
||||
llarp::exit::Context::Config_t conf;
|
||||
conf.emplace("exit", "true");
|
||||
conf.emplace("type", "null");
|
||||
conf.emplace("ifaddr", "10.0.0.1/24");
|
||||
ASSERT_TRUE(r.exitContext.AddExitEndpoint("test-exit", conf));
|
||||
ASSERT_TRUE(r.exitContext.ObtainNewExit(pk, firstPath, true));
|
||||
ASSERT_TRUE(r.exitContext.ObtainNewExit(pk, secondPath, true));
|
||||
ASSERT_TRUE(r.exitContext.FindEndpointForPath(firstPath)->LocalIP()
|
||||
== r.exitContext.FindEndpointForPath(secondPath)->LocalIP());
|
||||
};
|
Loading…
Reference in New Issue