aboutsummaryrefslogtreecommitdiffstats
path: root/net.cpp
diff options
context:
space:
mode:
authorsubtly <subtly@users.noreply.github.com>2015-04-16 06:38:17 +0800
committersubtly <subtly@users.noreply.github.com>2015-04-16 06:38:17 +0800
commit339836d3fbcd27d86b2fbac4d907b9fd5da479ff (patch)
treeb76e4ec36e0b65d96d12c5ce868f8f09e03e58a7 /net.cpp
parent4f68bb8d450f469375473647705c6cf5d32d4f54 (diff)
parent5469743891679267ea1fdad0cd68099101e43b19 (diff)
downloaddexon-solidity-339836d3fbcd27d86b2fbac4d907b9fd5da479ff.tar.gz
dexon-solidity-339836d3fbcd27d86b2fbac4d907b9fd5da479ff.tar.zst
dexon-solidity-339836d3fbcd27d86b2fbac4d907b9fd5da479ff.zip
Merge branch 'develop' into discoveryEndpoints
Diffstat (limited to 'net.cpp')
-rw-r--r--net.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/net.cpp b/net.cpp
index ef7227cb..28b4f428 100644
--- a/net.cpp
+++ b/net.cpp
@@ -229,6 +229,33 @@ BOOST_AUTO_TEST_CASE(v2PingNodePacket)
BOOST_REQUIRE(p.version == 2);
}
+BOOST_AUTO_TEST_CASE(neighboursPacketLength)
+{
+ KeyPair k = KeyPair::create();
+ std::vector<std::pair<KeyPair,unsigned>> testNodes(TestNodeTable::createTestNodes(16));
+ bi::udp::endpoint to(boost::asio::ip::address::from_string("127.0.0.1"), 30000);
+
+ // hash(32), signature(65), overhead: packet(2), type(1), nodeList(2), ts(9),
+ static unsigned const nlimit = (1280 - 111) / 87;
+ for (unsigned offset = 0; offset < testNodes.size(); offset += nlimit)
+ {
+ Neighbours out(to);
+
+ auto limit = nlimit ? std::min(testNodes.size(), (size_t)(offset + nlimit)) : testNodes.size();
+ for (auto i = offset; i < limit; i++)
+ {
+ Neighbours::Node node;
+ node.ipAddress = boost::asio::ip::address::from_string("200.200.200.200").to_string();
+ node.port = testNodes[i].second;
+ node.node = testNodes[i].first.pub();
+ out.nodes.push_back(node);
+ }
+
+ out.sign(k.sec());
+ BOOST_REQUIRE_LE(out.data.size(), 1280);
+ }
+}
+
BOOST_AUTO_TEST_CASE(test_neighbours_packet)
{
KeyPair k = KeyPair::create();