|
|
@ -26,6 +26,8 @@ |
|
|
|
#include <libdevcrypto/Common.h> |
|
|
|
#include <libp2p/UDP.h> |
|
|
|
#include <libp2p/NodeTable.h> |
|
|
|
#include <test/TestHelper.h> |
|
|
|
|
|
|
|
using namespace std; |
|
|
|
using namespace dev; |
|
|
|
using namespace dev::p2p; |
|
|
@ -153,6 +155,9 @@ public: |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(requestTimeout) |
|
|
|
{ |
|
|
|
if (test::Options::get().nonetwork) |
|
|
|
return; |
|
|
|
|
|
|
|
using TimePoint = std::chrono::steady_clock::time_point; |
|
|
|
using RequestTimeout = std::pair<NodeId, TimePoint>; |
|
|
|
|
|
|
@ -220,6 +225,9 @@ BOOST_AUTO_TEST_CASE(isIPAddressType) |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(v2PingNodePacket) |
|
|
|
{ |
|
|
|
if (test::Options::get().nonetwork) |
|
|
|
return; |
|
|
|
|
|
|
|
// test old versino of pingNode packet w/new
|
|
|
|
RLPStream s; |
|
|
|
s.appendList(3); s << "1.1.1.1" << 30303 << std::chrono::duration_cast<std::chrono::seconds>((std::chrono::system_clock::now() + chrono::seconds(60)).time_since_epoch()).count(); |
|
|
@ -231,6 +239,9 @@ BOOST_AUTO_TEST_CASE(v2PingNodePacket) |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(neighboursPacketLength) |
|
|
|
{ |
|
|
|
if (test::Options::get().nonetwork) |
|
|
|
return; |
|
|
|
|
|
|
|
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); |
|
|
@ -256,6 +267,9 @@ BOOST_AUTO_TEST_CASE(neighboursPacketLength) |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(neighboursPacket) |
|
|
|
{ |
|
|
|
if (test::Options::get().nonetwork) |
|
|
|
return; |
|
|
|
|
|
|
|
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); |
|
|
@ -291,6 +305,9 @@ BOOST_AUTO_TEST_CASE(test_findnode_neighbours) |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(kademlia) |
|
|
|
{ |
|
|
|
if (test::Options::get().nonetwork) |
|
|
|
return; |
|
|
|
|
|
|
|
// Not yet a 'real' test.
|
|
|
|
TestNodeTableHost node(8); |
|
|
|
node.start(); |
|
|
@ -324,6 +341,9 @@ BOOST_AUTO_TEST_CASE(kademlia) |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(udpOnce) |
|
|
|
{ |
|
|
|
if (test::Options::get().nonetwork) |
|
|
|
return; |
|
|
|
|
|
|
|
UDPDatagram d(bi::udp::endpoint(boost::asio::ip::address::from_string("127.0.0.1"), 30300), bytes({65,65,65,65})); |
|
|
|
TestUDPSocket a; a.m_socket->connect(); a.start(); |
|
|
|
a.m_socket->send(d); |
|
|
@ -337,6 +357,9 @@ BOOST_AUTO_TEST_SUITE(netTypes) |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(unspecifiedNode) |
|
|
|
{ |
|
|
|
if (test::Options::get().nonetwork) |
|
|
|
return; |
|
|
|
|
|
|
|
Node n = UnspecifiedNode; |
|
|
|
BOOST_REQUIRE(!n); |
|
|
|
|
|
|
@ -350,6 +373,9 @@ BOOST_AUTO_TEST_CASE(unspecifiedNode) |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(nodeTableReturnsUnspecifiedNode) |
|
|
|
{ |
|
|
|
if (test::Options::get().nonetwork) |
|
|
|
return; |
|
|
|
|
|
|
|
ba::io_service io; |
|
|
|
NodeTable t(io, KeyPair::create(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30303, 30303)); |
|
|
|
if (Node n = t.node(NodeId())) |
|
|
|