Browse Source

test ports changed

cl-refactor
Vlad Gluhovsky 10 years ago
parent
commit
e19825f8d3
  1. 14
      test/libp2p/peer.cpp
  2. 4
      test/libwhisper/whisperDB.cpp
  3. 39
      test/libwhisper/whisperTopic.cpp

14
test/libp2p/peer.cpp

@ -44,8 +44,8 @@ BOOST_AUTO_TEST_CASE(host)
return; return;
VerbosityHolder setTemporaryLevel(10); VerbosityHolder setTemporaryLevel(10);
NetworkPreferences host1prefs("127.0.0.1", 30311, false); NetworkPreferences host1prefs("127.0.0.1", 30321, false);
NetworkPreferences host2prefs("127.0.0.1", 30312, false); NetworkPreferences host2prefs("127.0.0.1", 30322, false);
Host host1("Test", host1prefs); Host host1("Test", host1prefs);
Host host2("Test", host2prefs); Host host2("Test", host2prefs);
host1.start(); host1.start();
@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(saveNodes)
for (unsigned i = 0; i < c_nodes; ++i) for (unsigned i = 0; i < c_nodes; ++i)
{ {
Host* h = new Host("Test", NetworkPreferences("127.0.0.1", 30300 + i, false)); Host* h = new Host("Test", NetworkPreferences("127.0.0.1", 30325 + i, false));
h->setIdealPeerCount(10); h->setIdealPeerCount(10);
// starting host is required so listenport is available // starting host is required so listenport is available
h->start(); h->start();
@ -155,8 +155,8 @@ BOOST_AUTO_TEST_CASE(requirePeer)
VerbosityHolder reduceVerbosity(10); VerbosityHolder reduceVerbosity(10);
const char* const localhost = "127.0.0.1"; const char* const localhost = "127.0.0.1";
NetworkPreferences prefs1(localhost, 30301, false); NetworkPreferences prefs1(localhost, 30323, false);
NetworkPreferences prefs2(localhost, 30302, false); NetworkPreferences prefs2(localhost, 30324, false);
Host host1("Test", prefs1); Host host1("Test", prefs1);
host1.start(); host1.start();
@ -229,9 +229,9 @@ BOOST_AUTO_TEST_SUITE_END()
int peerTest(int argc, char** argv) int peerTest(int argc, char** argv)
{ {
Public remoteAlias; Public remoteAlias;
short listenPort = 30303; short listenPort = 30304;
string remoteHost; string remoteHost;
short remotePort = 30303; short remotePort = 30304;
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)
{ {

4
test/libwhisper/whisperDB.cpp

@ -224,7 +224,7 @@ BOOST_AUTO_TEST_CASE(filters)
db.saveTopicsToDB(*wh, persistID); db.saveTopicsToDB(*wh, persistID);
} }
short unsigned port1 = 30313; uint16_t port1 = 30308;
unsigned const step = 10; unsigned const step = 10;
bool host1Ready = false; bool host1Ready = false;
bool sent = false; bool sent = false;
@ -265,7 +265,7 @@ BOOST_AUTO_TEST_CASE(filters)
} }
}); });
Host host2("Test", NetworkPreferences("127.0.0.1", 30314, false)); Host host2("Test", NetworkPreferences("127.0.0.1", 30309, false));
host2.setIdealPeerCount(1); host2.setIdealPeerCount(1);
auto whost2 = host2.registerCapability(new WhisperHost()); auto whost2 = host2.registerCapability(new WhisperHost());
host2.start(); host2.start();

39
test/libwhisper/whisperTopic.cpp

@ -49,7 +49,8 @@ BOOST_AUTO_TEST_CASE(topic)
cnote << "Testing Whisper..."; cnote << "Testing Whisper...";
VerbosityHolder setTemporaryLevel(0); VerbosityHolder setTemporaryLevel(0);
Host host1("Test", NetworkPreferences("127.0.0.1", 30303, false)); uint16_t port1 = 30311;
Host host1("Test", NetworkPreferences("127.0.0.1", port1, false));
host1.setIdealPeerCount(1); host1.setIdealPeerCount(1);
auto whost1 = host1.registerCapability(new WhisperHost()); auto whost1 = host1.registerCapability(new WhisperHost());
host1.start(); host1.start();
@ -80,14 +81,14 @@ BOOST_AUTO_TEST_CASE(topic)
} }
}); });
Host host2("Test", NetworkPreferences("127.0.0.1", 30300, false)); Host host2("Test", NetworkPreferences("127.0.0.1", 30310, false));
host1.setIdealPeerCount(1); host1.setIdealPeerCount(1);
auto whost2 = host2.registerCapability(new WhisperHost()); auto whost2 = host2.registerCapability(new WhisperHost());
host2.start(); host2.start();
while (!host1.haveNetwork()) while (!host1.haveNetwork())
this_thread::sleep_for(chrono::milliseconds(5)); this_thread::sleep_for(chrono::milliseconds(5));
host2.addNode(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30303, 30303)); host2.addNode(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), port1, port1));
// wait for nodes to connect // wait for nodes to connect
this_thread::sleep_for(chrono::milliseconds(1000)); this_thread::sleep_for(chrono::milliseconds(1000));
@ -115,7 +116,8 @@ BOOST_AUTO_TEST_CASE(forwarding)
VerbosityHolder setTemporaryLevel(0); VerbosityHolder setTemporaryLevel(0);
// Host must be configured not to share peers. // Host must be configured not to share peers.
Host host1("Listner", NetworkPreferences("127.0.0.1", 30303, false)); uint16_t port1 = 30312;
Host host1("Listner", NetworkPreferences("127.0.0.1", port1, false));
host1.setIdealPeerCount(1); host1.setIdealPeerCount(1);
auto whost1 = host1.registerCapability(new WhisperHost()); auto whost1 = host1.registerCapability(new WhisperHost());
host1.start(); host1.start();
@ -150,7 +152,8 @@ BOOST_AUTO_TEST_CASE(forwarding)
// Host must be configured not to share peers. // Host must be configured not to share peers.
Host host2("Forwarder", NetworkPreferences("127.0.0.1", 30305, false)); uint16_t port2 = 30313;
Host host2("Forwarder", NetworkPreferences("127.0.0.1", port2, false));
host2.setIdealPeerCount(1); host2.setIdealPeerCount(1);
auto whost2 = host2.registerCapability(new WhisperHost()); auto whost2 = host2.registerCapability(new WhisperHost());
host2.start(); host2.start();
@ -167,7 +170,7 @@ BOOST_AUTO_TEST_CASE(forwarding)
this_thread::sleep_for(chrono::milliseconds(50)); this_thread::sleep_for(chrono::milliseconds(50));
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
host2.addNode(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30303, 30303)); host2.addNode(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), port1, port1));
startedForwarder = true; startedForwarder = true;
@ -188,11 +191,11 @@ BOOST_AUTO_TEST_CASE(forwarding)
while (!startedForwarder) while (!startedForwarder)
this_thread::sleep_for(chrono::milliseconds(50)); this_thread::sleep_for(chrono::milliseconds(50));
Host ph("Sender", NetworkPreferences("127.0.0.1", 30300, false)); Host ph("Sender", NetworkPreferences("127.0.0.1", 30314, false));
ph.setIdealPeerCount(1); ph.setIdealPeerCount(1);
shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost()); shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost());
ph.start(); ph.start();
ph.addNode(host2.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30305, 30305)); ph.addNode(host2.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), port2, port2));
while (!ph.haveNetwork()) while (!ph.haveNetwork())
this_thread::sleep_for(chrono::milliseconds(10)); this_thread::sleep_for(chrono::milliseconds(10));
@ -221,7 +224,8 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
bool done = false; bool done = false;
// Host must be configured not to share peers. // Host must be configured not to share peers.
Host host1("Forwarder", NetworkPreferences("127.0.0.1", 30305, false)); uint16_t port1 = 30315;
Host host1("Forwarder", NetworkPreferences("127.0.0.1", port1, false));
host1.setIdealPeerCount(1); host1.setIdealPeerCount(1);
auto whost1 = host1.registerCapability(new WhisperHost()); auto whost1 = host1.registerCapability(new WhisperHost());
host1.start(); host1.start();
@ -250,14 +254,14 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
this_thread::sleep_for(chrono::milliseconds(2)); this_thread::sleep_for(chrono::milliseconds(2));
{ {
Host host2("Sender", NetworkPreferences("127.0.0.1", 30300, false)); Host host2("Sender", NetworkPreferences("127.0.0.1", 30316, false));
host2.setIdealPeerCount(1); host2.setIdealPeerCount(1);
shared_ptr<WhisperHost> whost2 = host2.registerCapability(new WhisperHost()); shared_ptr<WhisperHost> whost2 = host2.registerCapability(new WhisperHost());
host2.start(); host2.start();
while (!host2.haveNetwork()) while (!host2.haveNetwork())
this_thread::sleep_for(chrono::milliseconds(2)); this_thread::sleep_for(chrono::milliseconds(2));
host2.requirePeer(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30305, 30305)); host2.requirePeer(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), port1, port1));
while (!host2.peerCount() || !host1.peerCount()) while (!host2.peerCount() || !host1.peerCount())
this_thread::sleep_for(chrono::milliseconds(5)); this_thread::sleep_for(chrono::milliseconds(5));
@ -267,7 +271,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
} }
{ {
Host ph("Listener", NetworkPreferences("127.0.0.1", 30300, false)); Host ph("Listener", NetworkPreferences("127.0.0.1", 30317, false));
ph.setIdealPeerCount(1); ph.setIdealPeerCount(1);
shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost()); shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost());
ph.start(); ph.start();
@ -275,7 +279,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
this_thread::sleep_for(chrono::milliseconds(2)); this_thread::sleep_for(chrono::milliseconds(2));
auto w = wh->installWatch(BuildTopicMask("test")); // only interested in odd packets auto w = wh->installWatch(BuildTopicMask("test")); // only interested in odd packets
ph.requirePeer(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30305, 30305)); ph.requirePeer(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), port1, port1));
for (int i = 0; i < 200 && !result; ++i) for (int i = 0; i < 200 && !result; ++i)
{ {
@ -303,14 +307,15 @@ BOOST_AUTO_TEST_CASE(topicAdvertising)
cnote << "Testing Topic Advertising..."; cnote << "Testing Topic Advertising...";
VerbosityHolder setTemporaryLevel(2); VerbosityHolder setTemporaryLevel(2);
Host host1("first", NetworkPreferences("127.0.0.1", 30303, false)); Host host1("first", NetworkPreferences("127.0.0.1", 30319, false));
host1.setIdealPeerCount(1); host1.setIdealPeerCount(1);
auto whost1 = host1.registerCapability(new WhisperHost()); auto whost1 = host1.registerCapability(new WhisperHost());
host1.start(); host1.start();
while (!host1.haveNetwork()) while (!host1.haveNetwork())
this_thread::sleep_for(chrono::milliseconds(10)); this_thread::sleep_for(chrono::milliseconds(10));
Host host2("second", NetworkPreferences("127.0.0.1", 30305, false)); uint16_t port2 = 30318;
Host host2("second", NetworkPreferences("127.0.0.1", port2, false));
host2.setIdealPeerCount(1); host2.setIdealPeerCount(1);
auto whost2 = host2.registerCapability(new WhisperHost()); auto whost2 = host2.registerCapability(new WhisperHost());
unsigned w2 = whost2->installWatch(BuildTopicMask("test2")); unsigned w2 = whost2->installWatch(BuildTopicMask("test2"));
@ -319,7 +324,7 @@ BOOST_AUTO_TEST_CASE(topicAdvertising)
while (!host2.haveNetwork()) while (!host2.haveNetwork())
this_thread::sleep_for(chrono::milliseconds(10)); this_thread::sleep_for(chrono::milliseconds(10));
host1.addNode(host2.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30305, 30305)); host1.addNode(host2.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), port2, port2));
while (!host1.haveNetwork()) while (!host1.haveNetwork())
this_thread::sleep_for(chrono::milliseconds(10)); this_thread::sleep_for(chrono::milliseconds(10));
@ -385,7 +390,7 @@ BOOST_AUTO_TEST_CASE(selfAddressed)
char const* text = "deterministic pseudorandom test"; char const* text = "deterministic pseudorandom test";
BuildTopicMask mask(text); BuildTopicMask mask(text);
Host host("first", NetworkPreferences("127.0.0.1", 30305, false)); Host host("first", NetworkPreferences("127.0.0.1", 30320, false));
auto wh = host.registerCapability(new WhisperHost()); auto wh = host.registerCapability(new WhisperHost());
auto watch = wh->installWatch(BuildTopicMask(text)); auto watch = wh->installWatch(BuildTopicMask(text));

Loading…
Cancel
Save