2018-07-06 16:08:30 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <llarp/service.hpp>
|
|
|
|
|
|
|
|
struct HiddenServiceTest : public ::testing::Test
|
|
|
|
{
|
|
|
|
llarp_crypto crypto;
|
|
|
|
llarp::service::Identity ident;
|
|
|
|
|
|
|
|
HiddenServiceTest()
|
|
|
|
{
|
2018-09-02 18:25:42 +00:00
|
|
|
llarp_crypto_init(&crypto);
|
2018-07-06 16:08:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
llarp_crypto*
|
|
|
|
Crypto()
|
|
|
|
{
|
|
|
|
return &crypto;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetUp()
|
|
|
|
{
|
|
|
|
ident.RegenerateKeys(Crypto());
|
2018-08-10 21:34:11 +00:00
|
|
|
ident.pub.RandomizeVanity();
|
2018-08-02 00:48:43 +00:00
|
|
|
ident.pub.UpdateAddr();
|
2018-07-06 16:08:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(HiddenServiceTest, TestGenerateIntroSet)
|
|
|
|
{
|
|
|
|
llarp::service::Address addr;
|
2018-08-10 21:34:11 +00:00
|
|
|
ASSERT_TRUE(ident.pub.CalculateAddress(addr.data()));
|
2018-07-06 16:08:30 +00:00
|
|
|
llarp::service::IntroSet I;
|
|
|
|
while(I.I.size() < 10)
|
|
|
|
{
|
|
|
|
llarp::service::Introduction intro;
|
|
|
|
intro.expiresAt = 1000;
|
|
|
|
intro.router.Randomize();
|
|
|
|
intro.pathID.Randomize();
|
2018-07-20 04:50:28 +00:00
|
|
|
I.I.push_back(intro);
|
2018-07-06 16:08:30 +00:00
|
|
|
}
|
|
|
|
ASSERT_TRUE(ident.SignIntroSet(I, Crypto()));
|
|
|
|
ASSERT_TRUE(I.VerifySignature(Crypto()));
|
2018-08-02 00:48:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(HiddenServiceTest, TestAddressToFromString)
|
|
|
|
{
|
|
|
|
auto str = ident.pub.Addr().ToString();
|
|
|
|
llarp::service::Address addr;
|
|
|
|
ASSERT_TRUE(addr.FromString(str));
|
|
|
|
ASSERT_TRUE(addr == ident.pub.Addr());
|
2018-09-02 18:25:42 +00:00
|
|
|
}
|