mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
update remaining whisper tests
This commit is contained in:
parent
1f0839385b
commit
6a9caebe7a
@ -210,32 +210,32 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
|
|||||||
unsigned result = 0;
|
unsigned result = 0;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
|
||||||
Public listenerid;
|
// Host must be configured not to share peers.
|
||||||
|
Host host1("Forwarder", NetworkPreferences(30305, "", false, true));
|
||||||
|
host1.setIdealPeerCount(1);
|
||||||
|
auto whost1 = host1.registerCapability(new WhisperHost());
|
||||||
|
host1.start();
|
||||||
|
while (!host1.isStarted())
|
||||||
|
this_thread::sleep_for(chrono::milliseconds(2));
|
||||||
|
|
||||||
bool startedForwarder = false;
|
bool startedForwarder = false;
|
||||||
std::thread forwarder([&]()
|
std::thread forwarder([&]()
|
||||||
{
|
{
|
||||||
setThreadName("forwarder");
|
setThreadName("forwarder");
|
||||||
|
|
||||||
// Host must be configured not to share peers.
|
|
||||||
Host ph("Forwarder", NetworkPreferences(30305, "", false, true));
|
|
||||||
ph.setIdealPeerCount(0);
|
|
||||||
auto wh = ph.registerCapability(new WhisperHost());
|
|
||||||
this_thread::sleep_for(chrono::milliseconds(500));
|
|
||||||
ph.start();
|
|
||||||
|
|
||||||
this_thread::sleep_for(chrono::milliseconds(500));
|
this_thread::sleep_for(chrono::milliseconds(500));
|
||||||
// ph.addNode("127.0.0.1", 30303, 30303);
|
// ph.addNode("127.0.0.1", 30303, 30303);
|
||||||
|
|
||||||
startedForwarder = true;
|
startedForwarder = true;
|
||||||
|
|
||||||
/// Only interested in odd packets
|
/// Only interested in odd packets
|
||||||
auto w = wh->installWatch(BuildTopicMask("test"));
|
auto w = whost1->installWatch(BuildTopicMask("test"));
|
||||||
|
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
for (auto i: wh->checkWatch(w))
|
for (auto i: whost1->checkWatch(w))
|
||||||
{
|
{
|
||||||
Message msg = wh->envelope(i).open(wh->fullTopic(w));
|
Message msg = whost1->envelope(i).open(whost1->fullTopic(w));
|
||||||
cnote << "New message from:" << msg.from().abridged() << RLP(msg.payload()).toInt<unsigned>();
|
cnote << "New message from:" << msg.from().abridged() << RLP(msg.payload()).toInt<unsigned>();
|
||||||
}
|
}
|
||||||
this_thread::sleep_for(chrono::milliseconds(50));
|
this_thread::sleep_for(chrono::milliseconds(50));
|
||||||
@ -245,28 +245,28 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
|
|||||||
while (!startedForwarder)
|
while (!startedForwarder)
|
||||||
this_thread::sleep_for(chrono::milliseconds(50));
|
this_thread::sleep_for(chrono::milliseconds(50));
|
||||||
|
|
||||||
{
|
Host host2("Sender", NetworkPreferences(30300, "", false, true));
|
||||||
Host ph("Sender", NetworkPreferences(30300, "", false, true));
|
host2.setIdealPeerCount(1);
|
||||||
ph.setIdealPeerCount(0);
|
shared_ptr<WhisperHost> whost2 = host2.registerCapability(new WhisperHost());
|
||||||
shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost());
|
host2.start();
|
||||||
this_thread::sleep_for(chrono::milliseconds(500));
|
while (!host2.isStarted())
|
||||||
ph.start();
|
this_thread::sleep_for(chrono::milliseconds(2));
|
||||||
this_thread::sleep_for(chrono::milliseconds(500));
|
host2.addNode(host1.id(), "127.0.0.1", 30305, 30305);
|
||||||
// ph.addNode("127.0.0.1", 30305, 30305);
|
|
||||||
|
|
||||||
|
{
|
||||||
KeyPair us = KeyPair::create();
|
KeyPair us = KeyPair::create();
|
||||||
wh->post(us.sec(), RLPStream().append(1).out(), BuildTopic("test"));
|
whost2->post(us.sec(), RLPStream().append(1).out(), BuildTopic("test"));
|
||||||
this_thread::sleep_for(chrono::milliseconds(250));
|
this_thread::sleep_for(chrono::milliseconds(250));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Host ph("Listener", NetworkPreferences(30300, "", false, true));
|
Host ph("Listener", NetworkPreferences(30300, "", false, true));
|
||||||
ph.setIdealPeerCount(0);
|
ph.setIdealPeerCount(1);
|
||||||
shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost());
|
shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost());
|
||||||
this_thread::sleep_for(chrono::milliseconds(500));
|
|
||||||
ph.start();
|
ph.start();
|
||||||
this_thread::sleep_for(chrono::milliseconds(500));
|
while (!ph.isStarted())
|
||||||
// ph.addNode("127.0.0.1", 30305, 30305);
|
this_thread::sleep_for(chrono::milliseconds(2));
|
||||||
|
ph.addNode(host1.id(), "127.0.0.1", 30305, 30305);
|
||||||
|
|
||||||
/// Only interested in odd packets
|
/// Only interested in odd packets
|
||||||
auto w = wh->installWatch(BuildTopicMask("test"));
|
auto w = wh->installWatch(BuildTopicMask("test"));
|
||||||
|
Loading…
Reference in New Issue
Block a user