More cleanup and tests
This commit is contained in:
+23
-7
@@ -24,19 +24,35 @@ namespace p2pool {
|
||||
|
||||
TEST(i2p, decode_encode)
|
||||
{
|
||||
const std::string addr1 = "vxghq7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq.b32.i2p";
|
||||
const hash result1 = from_i2p_b32(addr1);
|
||||
|
||||
const hash expected1{
|
||||
const hash expected{
|
||||
0xad, 0xcc, 0x78, 0x7e, 0x8e, 0x46, 0xd9, 0xd4,
|
||||
0xd2, 0xa5, 0x56, 0x9d, 0x36, 0x5d, 0x67, 0xe4,
|
||||
0x0f, 0x60, 0xf3, 0x57, 0x18, 0x71, 0x32, 0x1e,
|
||||
0x60, 0x3c, 0x08, 0xa9, 0x38, 0x4b, 0x11, 0x27
|
||||
};
|
||||
EXPECT_EQ(result1, expected1);
|
||||
|
||||
const std::string result2 = to_i2p_b32(result1);
|
||||
EXPECT_EQ(result2, addr1);
|
||||
const std::string addr1 = "vxghq7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq.b32.i2p";
|
||||
const hash result1 = from_i2p_b32(addr1);
|
||||
|
||||
EXPECT_EQ(result1, expected);
|
||||
EXPECT_EQ(to_i2p_b32(result1), addr1);
|
||||
|
||||
// Uppercase
|
||||
const std::string addr2 = "VXGHQ7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq.b32.i2p";
|
||||
EXPECT_EQ(from_i2p_b32(addr2), expected);
|
||||
|
||||
// Invalid character
|
||||
const std::string addr3 = "1xghq7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq.b32.i2p";
|
||||
EXPECT_EQ(from_i2p_b32(addr3), hash());
|
||||
|
||||
// Too short
|
||||
EXPECT_EQ(from_i2p_b32(""), hash());
|
||||
|
||||
// No suffix
|
||||
EXPECT_EQ(from_i2p_b32("vxghq7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq"), hash());
|
||||
|
||||
// Too long
|
||||
EXPECT_EQ(from_i2p_b32("vxghq7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq2.b32.i2p"), hash());
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
|
||||
Reference in New Issue
Block a user