From d9ce2fe346d17dad993b18dbb96b538f15e52282 Mon Sep 17 00:00:00 2001 From: Alex Young Date: Wed, 25 Mar 2015 15:02:08 +0000 Subject: Add a timestamping test --- test/tc_mauve_udp_server.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/tc_mauve_udp_server.rb b/test/tc_mauve_udp_server.rb index 9a82de8..ecb981e 100644 --- a/test/tc_mauve_udp_server.rb +++ b/test/tc_mauve_udp_server.rb @@ -20,11 +20,16 @@ class TcMauveUdpServer < Mauve::UnitTest def test_listens update = generic_update() + before = Time.now t = Thread.new do @server.__send__(:main_loop) end sleep(0.2) sender.send(update) Timeout.timeout(2) do t.join end - assert_equal update, Proto::AlertUpdate.new.parse_from_string(Server.packet_pop[0]) + after = Time.now + data, addrinfo, received_at = Server.packet_pop + assert_equal update, Proto::AlertUpdate.new.parse_from_string(data) + assert addrinfo[3], "No client source address!" + assert received_at >= before && received_at <= after, "Received at time was wrong" end def test_closes -- cgit v1.2.1