| 1 | #include <base/types.h> |
| 2 | |
| 3 | #include <game/server/gamecontext.h> |
| 4 | |
| 5 | #include <gtest/gtest.h> |
| 6 | |
| 7 | static NETADDR TestAddr() |
| 8 | { |
| 9 | NETADDR Addr = {}; |
| 10 | Addr.type = NETTYPE_IPV4; |
| 11 | Addr.ip[0] = 127; |
| 12 | Addr.ip[3] = 1; |
| 13 | Addr.port = 12345; |
| 14 | return Addr; |
| 15 | } |
| 16 | |
| 17 | TEST(Mutes, RegularMuteAppliesWhenIgnoringInitialDelay) |
| 18 | { |
| 19 | CMutes Mutes("mutes_test" ); |
| 20 | const NETADDR Addr = TestAddr(); |
| 21 | ASSERT_TRUE(Mutes.Mute(&Addr, 60, "Spam protection" , "nameless tee" , false)); |
| 22 | EXPECT_TRUE(Mutes.IsMuted(&Addr, true).has_value()); |
| 23 | EXPECT_TRUE(Mutes.IsMuted(&Addr, false).has_value()); |
| 24 | } |
| 25 | |
| 26 | TEST(Mutes, InitialDelayMuteIgnoredWhenIgnoringInitialDelay) |
| 27 | { |
| 28 | CMutes Mutes("mutes_test" ); |
| 29 | const NETADDR Addr = TestAddr(); |
| 30 | ASSERT_TRUE(Mutes.Mute(&Addr, 60, "Initial chat delay" , "nameless tee" , true)); |
| 31 | EXPECT_TRUE(Mutes.IsMuted(&Addr, true).has_value()); |
| 32 | EXPECT_FALSE(Mutes.IsMuted(&Addr, false).has_value()); |
| 33 | } |
| 34 | |