diff options
author | Alex Young <alex@bytemark.co.uk> | 2015-03-25 15:02:08 +0000 |
---|---|---|
committer | Alex Young <alex@bytemark.co.uk> | 2015-03-25 15:02:08 +0000 |
commit | d9ce2fe346d17dad993b18dbb96b538f15e52282 (patch) | |
tree | c1adfaff9e6ea178ed9a4ee74b9c9d11bd0dfd48 /test | |
parent | a306e4a3dee7506893b31032f3c8c0426a7a1c42 (diff) |
Add a timestamping test
Diffstat (limited to 'test')
-rw-r--r-- | test/tc_mauve_udp_server.rb | 7 |
1 files changed, 6 insertions, 1 deletions
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 |