aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests/ban.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_tests/ban.cpp')
-rw-r--r--tests/unit_tests/ban.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit_tests/ban.cpp b/tests/unit_tests/ban.cpp
index eb1ee8932..0b267172f 100644
--- a/tests/unit_tests/ban.cpp
+++ b/tests/unit_tests/ban.cpp
@@ -192,5 +192,21 @@ TEST(ban, add)
ASSERT_TRUE(t >= 4);
}
+TEST(ban, limit)
+{
+ test_core pr_core;
+ cryptonote::t_cryptonote_protocol_handler<test_core> cprotocol(pr_core, NULL);
+ Server server(cprotocol);
+ cprotocol.set_p2p_endpoint(&server);
+
+ // starts empty
+ ASSERT_TRUE(server.get_blocked_hosts().empty());
+ ASSERT_FALSE(is_blocked(server,MAKE_IPV4_ADDRESS(1,2,3,4)));
+ ASSERT_TRUE(server.block_host(MAKE_IPV4_ADDRESS(1,2,3,4), std::numeric_limits<time_t>::max() - 1));
+ ASSERT_TRUE(is_blocked(server,MAKE_IPV4_ADDRESS(1,2,3,4)));
+ ASSERT_TRUE(server.block_host(MAKE_IPV4_ADDRESS(1,2,3,4), 1));
+ ASSERT_TRUE(is_blocked(server,MAKE_IPV4_ADDRESS(1,2,3,4)));
+}
+
namespace nodetool { template class node_server<cryptonote::t_cryptonote_protocol_handler<test_core>>; }
namespace cryptonote { template class t_cryptonote_protocol_handler<test_core>; }