Browse Source

update tests (v4 endpoint)

cl-refactor
subtly 10 years ago
parent
commit
0850c7ac72
  1. 22
      test/libp2p/net.cpp

22
test/libp2p/net.cpp

@ -82,7 +82,7 @@ struct TestNodeTable: public NodeTable
bi::address ourIp = bi::address::from_string("127.0.0.1"); bi::address ourIp = bi::address::from_string("127.0.0.1");
for (auto& n: _testNodes) for (auto& n: _testNodes)
{ {
ping(bi::udp::endpoint(ourIp, n.second)); ping(NodeIPEndpoint(ourIp, n.second, n.second));
this_thread::sleep_for(chrono::milliseconds(2)); this_thread::sleep_for(chrono::milliseconds(2));
} }
} }
@ -244,11 +244,9 @@ BOOST_AUTO_TEST_CASE(neighboursPacketLength)
auto limit = nlimit ? std::min(testNodes.size(), (size_t)(offset + nlimit)) : testNodes.size(); auto limit = nlimit ? std::min(testNodes.size(), (size_t)(offset + nlimit)) : testNodes.size();
for (auto i = offset; i < limit; i++) for (auto i = offset; i < limit; i++)
{ {
Neighbours::Node node; Node n(testNodes[i].first.pub(), NodeIPEndpoint(boost::asio::ip::address::from_string("200.200.200.200"), testNodes[i].second, testNodes[i].second));
node.ipAddress = boost::asio::ip::address::from_string("200.200.200.200").to_string(); Neighbours::Neighbour neighbour(n);
node.udpPort = testNodes[i].second; out.neighbours.push_back(neighbour);
node.node = testNodes[i].first.pub();
out.nodes.push_back(node);
} }
out.sign(k.sec()); out.sign(k.sec());
@ -265,11 +263,9 @@ BOOST_AUTO_TEST_CASE(test_neighbours_packet)
Neighbours out(to); Neighbours out(to);
for (auto n: testNodes) for (auto n: testNodes)
{ {
Neighbours::Node node; Node node(n.first.pub(), NodeIPEndpoint(boost::asio::ip::address::from_string("200.200.200.200"), n.second, n.second));
node.ipAddress = boost::asio::ip::address::from_string("127.0.0.1").to_string(); Neighbours::Neighbour neighbour(node);
node.udpPort = n.second; out.neighbours.push_back(neighbour);
node.node = n.first.pub();
out.nodes.push_back(node);
} }
out.sign(k.sec()); out.sign(k.sec());
@ -277,9 +273,9 @@ BOOST_AUTO_TEST_CASE(test_neighbours_packet)
bytesConstRef rlpBytes(packet.cropped(h256::size + Signature::size + 1)); bytesConstRef rlpBytes(packet.cropped(h256::size + Signature::size + 1));
Neighbours in = Neighbours::fromBytesConstRef(to, rlpBytes); Neighbours in = Neighbours::fromBytesConstRef(to, rlpBytes);
int count = 0; int count = 0;
for (auto n: in.nodes) for (auto n: in.neighbours)
{ {
BOOST_REQUIRE_EQUAL(testNodes[count].second, n.udpPort); BOOST_REQUIRE_EQUAL(testNodes[count].second, n.endpoint.udpPort);
BOOST_REQUIRE_EQUAL(testNodes[count].first.pub(), n.node); BOOST_REQUIRE_EQUAL(testNodes[count].first.pub(), n.node);
BOOST_REQUIRE_EQUAL(sha3(testNodes[count].first.pub()), sha3(n.node)); BOOST_REQUIRE_EQUAL(sha3(testNodes[count].first.pub()), sha3(n.node));
count++; count++;

Loading…
Cancel
Save