diff options
| author | selsta <selsta@sent.at> | 2026-06-03 17:20:11 +0200 |
|---|---|---|
| committer | selsta <selsta@sent.at> | 2026-06-03 17:24:27 +0200 |
| commit | 93d792e63c85baec6f8a3b8f9bbad3f803dd3a7e (patch) | |
| tree | 0fa01d79f92de66dfa086cb4a7b1fa899f92dbfb /tests | |
| parent | cb1b4b5321ce42bf1c51675398c97b70584b6a0c (diff) | |
| download | monzero-core-93d792e63c85baec6f8a3b8f9bbad3f803dd3a7e.tar.gz monzero-core-93d792e63c85baec6f8a3b8f9bbad3f803dd3a7e.tar.xz monzero-core-93d792e63c85baec6f8a3b8f9bbad3f803dd3a7e.zip | |
net: canonicalize Tor/I2P hosts during deserialization
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit_tests/net.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/unit_tests/net.cpp b/tests/unit_tests/net.cpp index 30e5f5589..79eacb710 100644 --- a/tests/unit_tests/net.cpp +++ b/tests/unit_tests/net.cpp @@ -327,6 +327,20 @@ TEST(tor_address, epee_serializev_v3) EXPECT_STREQ(v3_onion, command.tor.host_str()); EXPECT_EQ(10u, command.tor.port()); + // make sure tor_address::_load canonicalizes incoming hosts + { + epee::serialization::portable_storage stg{}; + stg.load_from_binary(epee::to_span(buffer)); + + EXPECT_TRUE(stg.set_value("host", std::string{v3_onion_upper}, stg.open_section("tor", nullptr, false))); + EXPECT_TRUE(command.load(stg)); + } + + EXPECT_FALSE(command.tor.is_unknown()); + EXPECT_NE(net::tor_address{}, command.tor); + EXPECT_STREQ(v3_onion, command.tor.host_str()); + EXPECT_EQ(10u, command.tor.port()); + // make sure that exceeding max buffer doesn't destroy tor_address::_load { epee::serialization::portable_storage stg{}; @@ -729,6 +743,20 @@ TEST(i2p_address, epee_serializev_b32) EXPECT_STREQ(b32_i2p, command.i2p.host_str()); EXPECT_EQ(1u, command.i2p.port()); + // make sure i2p_address::_load canonicalizes incoming hosts + { + epee::serialization::portable_storage stg{}; + stg.load_from_binary(epee::to_span(buffer)); + + EXPECT_TRUE(stg.set_value("host", std::string{b32_i2p_upper}, stg.open_section("i2p", nullptr, false))); + EXPECT_TRUE(command.load(stg)); + } + + EXPECT_FALSE(command.i2p.is_unknown()); + EXPECT_NE(net::i2p_address{}, command.i2p); + EXPECT_STREQ(b32_i2p, command.i2p.host_str()); + EXPECT_EQ(1u, command.i2p.port()); + // make sure that exceeding max buffer doesn't destroy i2p_address::_load { epee::serialization::portable_storage stg{}; |
