lokinet/test/routing/test_llarp_routing_obtainexitmessage.cpp

32 lines
678 B
C++
Raw Normal View History

2023-01-09 17:47:41 +00:00
#include <llarp/exit/exit_messages.hpp>
#include <llarp/crypto/crypto.hpp>
#include <llarp/crypto/crypto_libsodium.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);
}
TEST_CASE("Sign-verify")
{
2021-03-03 13:33:20 +00:00
SecretKey alice{};
crypto::identity_keygen(alice);
2021-03-03 13:33:20 +00:00
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)});
2022-05-26 15:59:44 +00:00
CHECK(msg.version == llarp::constants::proto_version);
2021-03-01 21:07:32 +00:00
CHECK_FALSE(msg.Z.IsZero());
2019-04-25 23:21:19 +00:00
}