aboutsummaryrefslogtreecommitdiffstats
path: root/whisperTopic.cpp
diff options
context:
space:
mode:
authorsubtly <subtly@users.noreply.github.com>2015-01-26 06:08:34 +0800
committersubtly <subtly@users.noreply.github.com>2015-01-26 06:08:34 +0800
commit2ed2a8ec8e2a1abe8bdc6bfc8cb0f81d1c6374c2 (patch)
tree92c3753e2a2d2120e2632b9368fb4801457a0c7b /whisperTopic.cpp
parentcc9a7cbb71aadd84cfb5a9687e5082d53004063e (diff)
downloaddexon-solidity-2ed2a8ec8e2a1abe8bdc6bfc8cb0f81d1c6374c2.tar.gz
dexon-solidity-2ed2a8ec8e2a1abe8bdc6bfc8cb0f81d1c6374c2.tar.zst
dexon-solidity-2ed2a8ec8e2a1abe8bdc6bfc8cb0f81d1c6374c2.zip
updates and fixes for code review
Diffstat (limited to 'whisperTopic.cpp')
-rw-r--r--whisperTopic.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/whisperTopic.cpp b/whisperTopic.cpp
index 9f0f3463..02fccbc9 100644
--- a/whisperTopic.cpp
+++ b/whisperTopic.cpp
@@ -34,29 +34,27 @@ BOOST_AUTO_TEST_CASE(topic)
{
cnote << "Testing Whisper...";
auto oldLogVerbosity = g_logVerbosity;
- g_logVerbosity = 0;
+ g_logVerbosity = 5;
- Host ph1("Test", NetworkPreferences(30303, "127.0.0.1", true, true));
+ Host phOther("Test", NetworkPreferences(30303, "127.0.0.1", true, true));
+ auto whOther = phOther.registerCapability(new WhisperHost());
+ phOther.start();
bool started = false;
unsigned result = 0;
std::thread listener([&]()
{
setThreadName("other");
-
- auto wh = ph1.registerCapability(new WhisperHost());
- ph1.start();
-
started = true;
/// Only interested in odd packets
- auto w = wh->installWatch(BuildTopicMask("odd"));
+ auto w = whOther->installWatch(BuildTopicMask("odd"));
for (int i = 0, last = 0; i < 200 && last < 81; ++i)
{
- for (auto i: wh->checkWatch(w))
+ for (auto i: whOther->checkWatch(w))
{
- Message msg = wh->envelope(i).open();
+ Message msg = whOther->envelope(i).open();
last = RLP(msg.payload()).toInt<unsigned>();
cnote << "New message from:" << msg.from().abridged() << RLP(msg.payload()).toInt<unsigned>();
result += last;
@@ -65,16 +63,16 @@ BOOST_AUTO_TEST_CASE(topic)
}
});
- while (!started)
- this_thread::sleep_for(chrono::milliseconds(50));
-
Host ph("Test", NetworkPreferences(30300, "127.0.0.1", true, true));
auto wh = ph.registerCapability(new WhisperHost());
- this_thread::sleep_for(chrono::milliseconds(500));
ph.start();
- this_thread::sleep_for(chrono::milliseconds(500));
- ph.addNode(ph1.id(), "127.0.0.1", 30303, 30303);
+ ph.addNode(phOther.id(), "127.0.0.1", 30303, 30303);
+ this_thread::sleep_for(chrono::milliseconds(300));
+ while (!started)
+ this_thread::sleep_for(chrono::milliseconds(25));
+
+
KeyPair us = KeyPair::create();
for (int i = 0; i < 10; ++i)
{