2018-11-12 16:43:40 +00:00
|
|
|
#include <gtest/gtest.h>
|
2018-12-12 02:52:51 +00:00
|
|
|
|
|
|
|
#include <messages/exit.hpp>
|
2018-11-12 16:43:40 +00:00
|
|
|
|
|
|
|
using ObtainExitMessage = llarp::routing::ObtainExitMessage;
|
|
|
|
|
|
|
|
class ObtainExitTest : public ::testing::Test
|
|
|
|
{
|
|
|
|
public:
|
2018-12-11 00:53:11 +00:00
|
|
|
llarp::Crypto crypto;
|
2018-11-12 16:43:40 +00:00
|
|
|
llarp::SecretKey alice;
|
|
|
|
|
|
|
|
ObtainExitTest()
|
2018-12-11 00:53:11 +00:00
|
|
|
: crypto(llarp::Crypto::sodium{})
|
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();
|
2018-11-12 16:43:40 +00:00
|
|
|
ASSERT_TRUE(msg.Sign(&crypto, alice));
|
|
|
|
ASSERT_TRUE(msg.Verify(&crypto));
|
|
|
|
ASSERT_TRUE(msg.I == llarp::PubKey(llarp::seckey_topublic(alice)));
|
|
|
|
ASSERT_FALSE(msg.version != LLARP_PROTO_VERSION);
|
|
|
|
ASSERT_FALSE(msg.Z.IsZero());
|
2018-12-11 00:53:11 +00:00
|
|
|
};
|