You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/test/test_llarp_router_contact.cpp

40 lines
821 B
C++

6 years ago
#include <gtest/gtest.h>
#include <crypto/crypto.hpp>
6 years ago
#include <router_contact.hpp>
static const byte_t DEF_VALUE[] = "unittest";
6 years ago
struct RCTest : public ::testing::Test
{
using RC_t = llarp::RouterContact;
using SecKey_t = llarp::SecretKey;
RCTest()
: crypto(llarp::Crypto::sodium{}), oldval(llarp::NetID::DefaultValue())
6 years ago
{
llarp::NetID::DefaultValue() = llarp::NetID(DEF_VALUE);
6 years ago
rc.Clear();
}
~RCTest()
6 years ago
{
llarp::NetID::DefaultValue() = oldval;
6 years ago
}
RC_t rc;
llarp::Crypto crypto;
const llarp::NetID oldval;
6 years ago
};
TEST_F(RCTest, TestSignVerify)
{
SecKey_t encr;
SecKey_t sign;
crypto.encryption_keygen(encr);
crypto.identity_keygen(sign);
rc.enckey = encr.toPublic();
6 years ago
ASSERT_TRUE(rc.Sign(&crypto, sign));
ASSERT_TRUE(rc.Verify(&crypto, llarp::time_now_ms()));
}