2019-01-11 00:12:43 +00:00
|
|
|
#include <exit/context.hpp>
|
2019-01-14 21:46:07 +00:00
|
|
|
|
|
|
|
#include <router/router.hpp>
|
2019-07-02 21:28:28 +00:00
|
|
|
#include <exit/context.hpp>
|
2019-01-14 21:46:07 +00:00
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
2018-11-15 21:47:05 +00:00
|
|
|
|
|
|
|
struct ExitTest : public ::testing::Test
|
|
|
|
{
|
2019-07-02 21:28:28 +00:00
|
|
|
ExitTest() : r(nullptr, nullptr, nullptr), context(&r)
|
2018-11-15 21:47:05 +00:00
|
|
|
{
|
|
|
|
}
|
2019-07-02 21:28:28 +00:00
|
|
|
|
2018-12-10 16:26:46 +00:00
|
|
|
llarp::Router r;
|
2019-07-02 21:28:28 +00:00
|
|
|
llarp::exit::Context context;
|
2018-11-15 21:47:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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");
|
2019-07-02 21:28:28 +00:00
|
|
|
|
|
|
|
ASSERT_TRUE(context.AddExitEndpoint("test-exit", conf));
|
|
|
|
ASSERT_TRUE(context.ObtainNewExit(pk, firstPath, true));
|
|
|
|
ASSERT_TRUE(context.ObtainNewExit(pk, secondPath, true));
|
|
|
|
ASSERT_TRUE(context.FindEndpointForPath(firstPath)->LocalIP()
|
|
|
|
== context.FindEndpointForPath(secondPath)->LocalIP());
|
2019-04-25 23:21:19 +00:00
|
|
|
}
|