2019-06-15 14:55:14 +00:00
|
|
|
#include <exit/exit_messages.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>
|
2019-05-28 19:45:09 +00:00
|
|
|
#include <llarp_test.hpp>
|
2019-01-26 15:40:58 +00:00
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
2019-05-28 19:45:09 +00:00
|
|
|
#include <gmock/gmock.h>
|
2018-11-12 16:43:40 +00:00
|
|
|
|
2019-05-28 19:45:09 +00:00
|
|
|
using namespace ::testing;
|
|
|
|
using namespace ::llarp;
|
2018-11-12 16:43:40 +00:00
|
|
|
|
2019-05-28 19:45:09 +00:00
|
|
|
using ObtainExitMessage = routing::ObtainExitMessage;
|
|
|
|
|
|
|
|
class ObtainExitTest : public test::LlarpTest<>
|
2018-11-12 16:43:40 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-05-28 19:45:09 +00:00
|
|
|
SecretKey alice;
|
2018-11-12 16:43:40 +00:00
|
|
|
|
2019-05-28 19:45:09 +00:00
|
|
|
ObtainExitTest()
|
2018-11-12 16:43:40 +00:00
|
|
|
{
|
2019-05-28 19:45:09 +00:00
|
|
|
// m_crypto.identity_keygen(alice);
|
2018-11-12 16:43:40 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-05-28 19:45:09 +00:00
|
|
|
void
|
|
|
|
fill(Signature& s)
|
|
|
|
{
|
|
|
|
s.Fill(0xFF);
|
|
|
|
}
|
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
TEST_F(ObtainExitTest, TestSignVerify)
|
|
|
|
{
|
2019-05-28 19:45:09 +00:00
|
|
|
EXPECT_CALL(m_crypto, sign(_, alice, _))
|
|
|
|
.WillOnce(DoAll(WithArg< 0 >(Invoke(&fill)), Return(true)));
|
|
|
|
EXPECT_CALL(m_crypto, verify(_, _, _)).WillOnce(Return(true));
|
2018-11-12 16:43:40 +00:00
|
|
|
ObtainExitMessage msg;
|
|
|
|
msg.Z.Zero();
|
2019-05-28 19:45:09 +00:00
|
|
|
msg.S = randint();
|
|
|
|
msg.T = randint();
|
2019-05-28 19:45:08 +00:00
|
|
|
EXPECT_TRUE(msg.Sign(alice));
|
|
|
|
EXPECT_TRUE(msg.Verify());
|
2019-05-28 19:45:09 +00:00
|
|
|
EXPECT_TRUE(msg.I == PubKey(seckey_topublic(alice)));
|
2019-01-02 01:04:04 +00:00
|
|
|
EXPECT_FALSE(msg.version != LLARP_PROTO_VERSION);
|
|
|
|
EXPECT_FALSE(msg.Z.IsZero());
|
2019-04-25 23:21:19 +00:00
|
|
|
}
|