Merge pull request #198 from michael-loki/rctest_fixup

Fix RCTest dependency ordering
pull/203/head
Ryan Tharp 6 years ago committed by GitHub
commit 1628f32720
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1543,7 +1543,8 @@ namespace llarp
"' you will run as a different network, good luck and "
"don't forget: something something MUH traffic shape "
"correlation !!!!");
llarp::NetID::DefaultValue = (const byte_t *)strdup(val);
llarp::NetID::DefaultValue() =
llarp::NetID(reinterpret_cast< const byte_t * >(strdup(val)));
// re set netid in our rc
self->_rc.netID = llarp::NetID();
}

@ -1,10 +1,11 @@
#include <router_contact.hpp>
#include <bencode.hpp>
#include <buffer.hpp>
#include <crypto.hpp>
#include <logger.hpp>
#include <mem.hpp>
#include <net.hpp>
#include <router_contact.hpp>
#include <time.hpp>
#include <version.hpp>
@ -12,8 +13,13 @@
namespace llarp
{
const byte_t *NetID::DefaultValue =
reinterpret_cast< const byte_t * >(Version::LLARP_NET_ID);
NetID &
NetID::DefaultValue()
{
static NetID defaultID(
reinterpret_cast< const byte_t * >(Version::LLARP_NET_ID));
return defaultID;
}
bool RouterContact::IgnoreBogons = false;
@ -25,11 +31,14 @@ namespace llarp
llarp_time_t RouterContact::Lifetime = 24 * 60 * 60 * 1000;
#endif
NetID::NetID() : AlignedBuffer< 8 >()
NetID::NetID(const byte_t *val) : AlignedBuffer< 8 >()
{
size_t len = strnlen(reinterpret_cast< const char * >(val), size());
std::copy(val, val + len, begin());
}
NetID::NetID() : NetID(DefaultValue().data())
{
size_t len =
strnlen(reinterpret_cast< const char * >(DefaultValue), size());
std::copy(DefaultValue, DefaultValue + len, begin());
}
bool

@ -17,10 +17,15 @@ namespace llarp
/// NetID
struct NetID final : public AlignedBuffer< 8 >
{
static const byte_t *DefaultValue;
static NetID &
DefaultValue();
NetID();
explicit NetID(const byte_t *val);
explicit NetID(const NetID &other) = default;
bool
operator==(const NetID &other) const;

@ -90,7 +90,7 @@ namespace llarp
if(key_itr->IsString())
{
keys.emplace_back();
if(!HexDecode(key_itr->GetString(), keys.back(), PUBKEYSIZE))
if(!HexDecode(key_itr->GetString(), keys.back().begin(), decltype(keys)::value_type::SIZE))
{
keys.pop_back();
}

@ -10,25 +10,21 @@ struct RCTest : public ::testing::Test
using RC_t = llarp::RouterContact;
using SecKey_t = llarp::SecretKey;
static void
SetUpTestCase()
{
llarp::NetID::DefaultValue = DEF_VALUE;
}
RCTest() : crypto(llarp::Crypto::sodium{}), oldval(llarp::NetID::DefaultValue)
RCTest()
: crypto(llarp::Crypto::sodium{}), oldval(llarp::NetID::DefaultValue())
{
llarp::NetID::DefaultValue() = llarp::NetID(DEF_VALUE);
rc.Clear();
}
~RCTest()
{
llarp::NetID::DefaultValue = oldval;
llarp::NetID::DefaultValue() = oldval;
}
RC_t rc;
llarp::Crypto crypto;
const byte_t* oldval;
const llarp::NetID oldval;
};
TEST_F(RCTest, TestSignVerify)

Loading…
Cancel
Save