lokinet/test/routing/test_llarp_routing_obtainexitmessage.cpp

34 lines
714 B
C++
Raw Normal View History

2019-06-15 14:55:14 +00:00
#include <exit/exit_messages.hpp>
#include <crypto/crypto.hpp>
#include <crypto/crypto_libsodium.hpp>
2019-05-28 19:45:09 +00:00
#include <llarp_test.hpp>
2021-03-01 21:07:32 +00:00
#include <catch2/catch.hpp>
2019-05-28 19:45:09 +00:00
using namespace ::llarp;
2021-03-01 21:07:32 +00:00
using namespace ::llarp::test;
2019-05-28 19:45:09 +00:00
using ObtainExitMessage = routing::ObtainExitMessage;
void
fill(Signature& s)
{
s.Fill(0xFF);
}
2021-03-01 21:07:32 +00:00
TEST_CASE_METHOD(LlarpTest<>, "Sign-verify")
{
2021-03-03 13:33:20 +00:00
SecretKey alice{};
CryptoManager::instance()->identity_keygen(alice);
REQUIRE(not alice.IsZero());
ObtainExitMessage msg{};
2019-05-28 19:45:09 +00:00
msg.S = randint();
msg.T = randint();
2021-03-01 21:07:32 +00:00
CHECK(msg.Sign(alice));
CHECK(msg.Verify());
2021-03-03 13:33:20 +00:00
CHECK(msg.I == PubKey{seckey_topublic(alice)});
2021-03-01 21:07:32 +00:00
CHECK(msg.version == LLARP_PROTO_VERSION);
CHECK_FALSE(msg.Z.IsZero());
2019-04-25 23:21:19 +00:00
}