From 09bc76d8aebd97bca2f5fa9c6898e45f24c9adcd Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 26 Mar 2014 16:09:31 +0000 Subject: [PATCH] add test vector from bep40 to test_peer_priority --- test/test_peer_priority.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_peer_priority.cpp b/test/test_peer_priority.cpp index b12d45783..0c35702fd 100644 --- a/test/test_peer_priority.cpp +++ b/test/test_peer_priority.cpp @@ -75,6 +75,17 @@ int test_main() , tcp::endpoint(address::from_string("230.12.123.3"), 0x12c)); TEST_EQUAL(p, hash_buffer("\xe6\x0c\x51\x01\xe6\x78\x15\x01", 8)); + // test vectors from BEP 40 + TEST_EQUAL(peer_priority( + tcp::endpoint(address::from_string("123.213.32.10"), 0) + , tcp::endpoint(address::from_string("98.76.54.32"), 0)) + , 0xec2d7224); + + TEST_EQUAL(peer_priority( + tcp::endpoint(address::from_string("123.213.32.10"), 0) + , tcp::endpoint(address::from_string("123.213.32.234"), 0)) + , 0x99568189); + if (supports_ipv6()) { // IPv6 has a twice as wide mask, and we only care about the top 64 bits