mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-24 13:45:52 +00:00
@@ -307,3 +307,37 @@ TEST_F(RPCHelpersTest, TraverseOwnedNodesWithUnexistingIndexMarker)
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCHelpersTest, EncodeCTID)
|
||||
{
|
||||
auto const ctid = encodeCTID(0x1234, 0x67, 0x89);
|
||||
ASSERT_TRUE(ctid);
|
||||
EXPECT_EQ(*ctid, "C000123400670089");
|
||||
EXPECT_FALSE(encodeCTID(0x1FFFFFFF, 0x67, 0x89));
|
||||
}
|
||||
|
||||
TEST_F(RPCHelpersTest, DecodeCTIDString)
|
||||
{
|
||||
auto const ctid = decodeCTID("C000123400670089");
|
||||
ASSERT_TRUE(ctid);
|
||||
EXPECT_EQ(*ctid, std::make_tuple(0x1234, 0x67, 0x89));
|
||||
EXPECT_FALSE(decodeCTID("F000123400670089"));
|
||||
EXPECT_FALSE(decodeCTID("F0001234006700"));
|
||||
EXPECT_FALSE(decodeCTID("F000123400*700"));
|
||||
}
|
||||
|
||||
TEST_F(RPCHelpersTest, DecodeCTIDInt)
|
||||
{
|
||||
uint64_t ctidStr = 0xC000123400670089;
|
||||
auto const ctid = decodeCTID(ctidStr);
|
||||
ASSERT_TRUE(ctid);
|
||||
EXPECT_EQ(*ctid, std::make_tuple(0x1234, 0x67, 0x89));
|
||||
ctidStr = 0xF000123400670089;
|
||||
EXPECT_FALSE(decodeCTID(ctidStr));
|
||||
}
|
||||
|
||||
TEST_F(RPCHelpersTest, DecodeInvalidCTID)
|
||||
{
|
||||
EXPECT_FALSE(decodeCTID('c'));
|
||||
EXPECT_FALSE(decodeCTID(true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user