2019-01-26 15:40:58 +00:00
|
|
|
#include <messages/exit.hpp>
|
2018-12-12 02:52:51 +00:00
|
|
|
|
2019-01-13 16:30:07 +00:00
|
|
|
#include <crypto/crypto.hpp>
|
2019-01-26 15:40:58 +00:00
|
|
|
#include <crypto/crypto_libsodium.hpp>
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
2018-11-12 16:43:40 +00:00
|
|
|
|
|
|
|
using ObtainExitMessage = llarp::routing::ObtainExitMessage;
|
|
|
|
|
|
|
|
class ObtainExitTest : public ::testing::Test
|
|
|
|
{
|
|
|
|
public:
|
2019-01-26 15:40:58 +00:00
|
|
|
llarp::sodium::CryptoLibSodium crypto;
|
2018-11-12 16:43:40 +00:00
|
|
|
llarp::SecretKey alice;
|
|
|
|
|
2019-01-26 15:40:58 +00:00
|
|
|
ObtainExitTest()
|
2018-11-12 16:43:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~ObtainExitTest()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetUp()
|
|
|
|
{
|
|
|
|
crypto.identity_keygen(alice);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(ObtainExitTest, TestSignVerify)
|
|
|
|
{
|
|
|
|
ObtainExitMessage msg;
|
|
|
|
msg.Z.Zero();
|
2018-12-11 00:53:11 +00:00
|
|
|
msg.S = llarp::randint();
|
|
|
|
msg.T = llarp::randint();
|
2019-01-02 01:04:04 +00:00
|
|
|
EXPECT_TRUE(msg.Sign(&crypto, alice));
|
|
|
|
EXPECT_TRUE(msg.Verify(&crypto));
|
|
|
|
EXPECT_TRUE(msg.I == llarp::PubKey(llarp::seckey_topublic(alice)));
|
|
|
|
EXPECT_FALSE(msg.version != LLARP_PROTO_VERSION);
|
|
|
|
EXPECT_FALSE(msg.Z.IsZero());
|
2018-12-11 00:53:11 +00:00
|
|
|
};
|