update whisper test for node-network

This commit is contained in:
subtly 2015-02-02 09:47:16 -08:00
parent 2a4951c111
commit e5f9016eb6

View File

@ -101,6 +101,7 @@ BOOST_AUTO_TEST_CASE(forwarding)
bool done = false; bool done = false;
bool startedListener = false; bool startedListener = false;
Public phid;
std::thread listener([&]() std::thread listener([&]()
{ {
setThreadName("listener"); setThreadName("listener");
@ -110,6 +111,7 @@ BOOST_AUTO_TEST_CASE(forwarding)
ph.setIdealPeerCount(0); ph.setIdealPeerCount(0);
auto wh = ph.registerCapability(new WhisperHost()); auto wh = ph.registerCapability(new WhisperHost());
ph.start(); ph.start();
phid = ph.id();
startedListener = true; startedListener = true;
@ -130,6 +132,7 @@ BOOST_AUTO_TEST_CASE(forwarding)
}); });
bool startedForwarder = false; bool startedForwarder = false;
Public fwderid;
std::thread forwarder([&]() std::thread forwarder([&]()
{ {
setThreadName("forwarder"); setThreadName("forwarder");
@ -143,9 +146,10 @@ BOOST_AUTO_TEST_CASE(forwarding)
auto wh = ph.registerCapability(new WhisperHost()); auto wh = ph.registerCapability(new WhisperHost());
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
ph.start(); ph.start();
fwderid = ph.id();
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
ph.connect("127.0.0.1", 50303); ph.addNode(phid, "127.0.0.1", 50303, 50303);
startedForwarder = true; startedForwarder = true;
@ -172,7 +176,7 @@ BOOST_AUTO_TEST_CASE(forwarding)
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
ph.start(); ph.start();
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
ph.connect("127.0.0.1", 50305); ph.addNode(fwderid, "127.0.0.1", 50305, 50305);
KeyPair us = KeyPair::create(); KeyPair us = KeyPair::create();
wh->post(us.sec(), RLPStream().append(1).out(), BuildTopic("test")); wh->post(us.sec(), RLPStream().append(1).out(), BuildTopic("test"));
@ -195,6 +199,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
unsigned result = 0; unsigned result = 0;
bool done = false; bool done = false;
Public listenerid;
bool startedForwarder = false; bool startedForwarder = false;
std::thread forwarder([&]() std::thread forwarder([&]()
{ {
@ -208,7 +213,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
ph.start(); ph.start();
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
ph.connect("127.0.0.1", 50303); // ph.addNode("127.0.0.1", 50303, 50303);
startedForwarder = true; startedForwarder = true;
@ -236,7 +241,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
ph.start(); ph.start();
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
ph.connect("127.0.0.1", 50305); // ph.addNode("127.0.0.1", 50305, 50305);
KeyPair us = KeyPair::create(); KeyPair us = KeyPair::create();
wh->post(us.sec(), RLPStream().append(1).out(), BuildTopic("test")); wh->post(us.sec(), RLPStream().append(1).out(), BuildTopic("test"));
@ -250,7 +255,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
ph.start(); ph.start();
this_thread::sleep_for(chrono::milliseconds(500)); this_thread::sleep_for(chrono::milliseconds(500));
ph.connect("127.0.0.1", 50305); // ph.addNode("127.0.0.1", 50305, 50305);
/// Only interested in odd packets /// Only interested in odd packets
auto w = wh->installWatch(BuildTopicMask("test")); auto w = wh->installWatch(BuildTopicMask("test"));