Fix RouterVersion::IsEmpty() and RouterVersion::Clear()

This commit is contained in:
Stephen Shelton 2020-01-31 13:31:00 -07:00
parent f0571a9f2c
commit cfabe72587
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C
2 changed files with 18 additions and 1 deletions

View File

@ -40,7 +40,7 @@ namespace llarp
RouterVersion::Clear()
{
m_Version.fill(0);
m_ProtoVersion = LLARP_PROTO_VERSION;
m_ProtoVersion = INVALID_VERSION;
assert(IsEmpty());
}

View File

@ -30,4 +30,21 @@ TEST_F(TestRouterVersion, TestEmptyCompatibility)
EXPECT_FALSE(v1.IsCompatableWith(llarp::emptyRouterVersion));
}
TEST_F(TestRouterVersion, TestIsEmpty)
{
llarp::RouterVersion notEmpty( {0, 0, 1}, LLARP_PROTO_VERSION);
EXPECT_FALSE(notEmpty.IsEmpty());
EXPECT_TRUE(llarp::emptyRouterVersion.IsEmpty());
}
TEST_F(TestRouterVersion, TestClear)
{
llarp::RouterVersion version( {0, 0, 1}, LLARP_PROTO_VERSION);
EXPECT_FALSE(version.IsEmpty());
version.Clear();
EXPECT_TRUE(version.IsEmpty());
}