mirror of https://github.com/oxen-io/lokinet
base32 encoding and unit tests
parent
21a2ffdeaf
commit
6cb31ecb1a
@ -0,0 +1,24 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <llarp/aligned.hpp>
|
||||
#include <llarp/encode.hpp>
|
||||
#include <llarp/logger.hpp>
|
||||
|
||||
struct Base32Test : public ::testing::Test
|
||||
{
|
||||
Base32Test()
|
||||
{
|
||||
llarp_crypto_libsodium_init(&crypto);
|
||||
}
|
||||
|
||||
llarp_crypto crypto;
|
||||
};
|
||||
|
||||
TEST_F(Base32Test, Serialize)
|
||||
{
|
||||
llarp::AlignedBuffer< 32 > addr, otherAddr;
|
||||
addr.Randomize();
|
||||
char tmp[64] = {0};
|
||||
std::string encoded = llarp::Base32Encode(addr, tmp);
|
||||
ASSERT_TRUE(llarp::Base32Decode(tmp, otherAddr));
|
||||
ASSERT_TRUE(otherAddr == addr);
|
||||
};
|
@ -0,0 +1,43 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <llarp/service.hpp>
|
||||
|
||||
struct HiddenServiceTest : public ::testing::Test
|
||||
{
|
||||
llarp_crypto crypto;
|
||||
llarp::service::Identity ident;
|
||||
|
||||
HiddenServiceTest()
|
||||
{
|
||||
llarp_crypto_libsodium_init(&crypto);
|
||||
}
|
||||
|
||||
llarp_crypto*
|
||||
Crypto()
|
||||
{
|
||||
return &crypto;
|
||||
}
|
||||
|
||||
void
|
||||
SetUp()
|
||||
{
|
||||
ident.RegenerateKeys(Crypto());
|
||||
ident.pub.vanity.Randomize();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(HiddenServiceTest, TestGenerateIntroSet)
|
||||
{
|
||||
llarp::service::Address addr;
|
||||
ASSERT_TRUE(ident.pub.CalculateAddress(addr));
|
||||
llarp::service::IntroSet I;
|
||||
while(I.I.size() < 10)
|
||||
{
|
||||
llarp::service::Introduction intro;
|
||||
intro.expiresAt = 1000;
|
||||
intro.router.Randomize();
|
||||
intro.pathID.Randomize();
|
||||
I.I.insert(intro);
|
||||
}
|
||||
ASSERT_TRUE(ident.SignIntroSet(I, Crypto()));
|
||||
ASSERT_TRUE(I.VerifySignature(Crypto()));
|
||||
};
|
Loading…
Reference in New Issue