Fabcoin Core  0.16.2
P2P Digital Currency
shhrpc.cpp
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
22 #include <boost/test/unit_test.hpp>
23 #include <boost/lexical_cast.hpp>
24 #include <libdevcore/Log.h>
25 #include <libdevcore/CommonIO.h>
26 #include <libethcore/CommonJS.h>
27 #include <libwebthree/WebThree.h>
29 #include <libweb3jsonrpc/Whisper.h>
30 #include <libweb3jsonrpc/Net.h>
31 #include <libweb3jsonrpc/Web3.h>
32 #include <libweb3jsonrpc/Eth.h>
37 #include <jsonrpccpp/server/connectors/httpserver.h>
38 #include <jsonrpccpp/client/connectors/httpclient.h>
42 #include <libethcore/KeyManager.h>
43 #include <libp2p/Common.h>
44 #include <libwhisper/WhisperHost.h>
45 
46 using namespace std;
47 using namespace dev;
48 using namespace dev::eth;
49 using namespace dev::p2p;
50 using namespace dev::shh;
51 using namespace dev::test;
52 namespace js = json_spirit;
53 
55 
56 unique_ptr<ModularServer<rpc::EthFace, rpc::WhisperFace, rpc::NetFace, rpc::Web3Face, rpc::AdminNetFace, rpc::AdminUtilsFace>> modularServer;
64 unique_ptr<AccountHolder> accountHolder;
65 unique_ptr<WebThreeStubClient> jsonrpcClient;
66 static string const c_version("shhrpc-web3");
67 static unsigned const c_ttl = 777000;
68 
69 struct Setup: public TestOutputHelper
70 {
72  {
74  static bool setup = false;
75  if (!setup)
76  {
77  setup = true;
78  NetworkPreferences nprefs("127.0.0.1", 0, false);
79  web3 = new WebThreeDirect(c_version, "", ChainParams(), WithExisting::Trust, {"shh"}, nprefs);
80  web3->setIdealPeerCount(9);
81  //auto server = new jsonrpc::HttpServer(8080);
82  KeyManager keyMan;
84  accountHolder.reset(new FixedAccountHolder([&](){return web3->ethereum();}, {}));
85  whisperFace = new rpc::Whisper(*web3, {});
86  //ethFace = new rpc::Eth(*web3->ethereum(), *accountHolder.get());
87  netFace = new rpc::Net(*web3);
88  w3Face = new rpc::Web3(web3->clientVersion());
89  adminNetFace = new rpc::AdminNet(*web3, sm);
90  adminUtilsFace = new rpc::AdminUtils(sm);
91  //modularServer.reset(new ModularServer<rpc::EthFace, rpc::WhisperFace, rpc::NetFace, rpc::Web3Face, rpc::AdminNetFace, rpc::AdminUtilsFace>(ethFace, whisperFace, netFace, w3Face, adminNetFace, adminUtilsFace));
92  //modularServer->addConnector(server);
93  //modularServer->StartListening();
94  auto client = new jsonrpc::HttpClient("http://localhost:8080");
95  jsonrpcClient = unique_ptr<WebThreeStubClient>(new WebThreeStubClient(*client));
96  }
97  }
98 
100  {
102  }
103 
105 };
106 
107 Json::Value createMessage(string const& _from, string const& _to, string const& _topic = "", string _payload = "")
108 {
109  Json::Value msg;
110  msg["from"] = _from;
111  msg["to"] = _to;
112  msg["ttl"] = toJS(c_ttl);
113 
114  if (_payload.empty())
115  _payload = string("0x") + h256::random().hex();
116 
117  msg["payload"] = _payload;
118 
119  if (!_topic.empty())
120  {
121  Json::Value t(Json::arrayValue);
122  t.append(_topic);
123  msg["topics"] = t;
124  }
125 
126  return msg;
127 }
128 
130 
131 //
132 // Disabled tests as they are unstable and tend to stall the test suite.
133 //
134 
135 //BOOST_AUTO_TEST_CASE(basic)
136 //{
137 // cnote << "Testing web3 basic functionality...";
138 
139 // web3->startNetwork();
140 // unsigned const step = 10;
141 // for (unsigned i = 0; i < 3000 && !web3->haveNetwork(); i += step)
142 // this_thread::sleep_for(chrono::milliseconds(step));
143 
144 // BOOST_REQUIRE(web3->haveNetwork());
145 
146 // NetworkPreferences prefs2("127.0.0.1", 0, false);
147 // string const version2 = "shhrpc-host2";
148 // Host host2(version2, prefs2);
149 // host2.start();
150 // auto port2 = host2.listenPort();
151 // BOOST_REQUIRE(port2);
152 // BOOST_REQUIRE_NE(port2, web3->nodeInfo().port);
153 // auto whost2 = host2.registerCapability(make_shared<WhisperHost>());
154 
155 // for (unsigned i = 0; i < 3000 && !host2.haveNetwork(); i += step)
156 // this_thread::sleep_for(chrono::milliseconds(step));
157 
158 // BOOST_REQUIRE(host2.haveNetwork());
159 
160 // web3->addNode(host2.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), port2, port2));
161 
162 // for (unsigned i = 0; i < 3000 && (!web3->peerCount() || !host2.peerCount()); i += step)
163 // this_thread::sleep_for(chrono::milliseconds(step));
164 
165 // BOOST_REQUIRE_EQUAL(host2.peerCount(), 1);
166 // BOOST_REQUIRE_EQUAL(web3->peerCount(), 1);
167 
168 // vector<PeerSessionInfo> vpeers = web3->peers();
169 // BOOST_REQUIRE(!vpeers.empty());
170 // PeerSessionInfo const& peer = vpeers.back();
171 // BOOST_REQUIRE_EQUAL(peer.id, host2.id());
172 // BOOST_REQUIRE_EQUAL(peer.port, port2);
173 // BOOST_REQUIRE_EQUAL(peer.clientVersion, version2);
174 
175 // web3->stopNetwork();
176 
177 // for (unsigned i = 0; i < 3000 && (web3->haveNetwork() || host2.haveNetwork()); i += step)
178 // this_thread::sleep_for(chrono::milliseconds(step));
179 
180 // BOOST_REQUIRE(!web3->peerCount());
181 // BOOST_REQUIRE(!host2.peerCount());
182 //}
183 
184 //BOOST_AUTO_TEST_CASE(send)
185 //{
186 // cnote << "Testing web3 send...";
187 
188 // bool sent = false;
189 // bool ready = false;
190 // unsigned result = 0;
191 // unsigned const messageCount = 10;
192 // unsigned const step = 10;
193 
194 // Host host2("shhrpc-host2", NetworkPreferences("127.0.0.1", 0, false));
195 // host2.setIdealPeerCount(1);
196 // auto whost2 = host2.registerCapability(make_shared<WhisperHost>());
197 // host2.start();
198 // web3->startNetwork();
199 // auto port2 = host2.listenPort();
200 // BOOST_REQUIRE(port2);
201 // BOOST_REQUIRE_NE(port2, web3->nodeInfo().port);
202 
203 // std::thread listener([&]()
204 // {
205 // setThreadName("listener");
206 // ready = true;
207 // auto w = whost2->installWatch(BuildTopicMask("odd"));
208 // set<unsigned> received;
209 // for (unsigned x = 0; x < 7000 && !sent; x += step)
210 // this_thread::sleep_for(chrono::milliseconds(step));
211 
212 // for (unsigned x = 0, last = 0; x < 100 && received.size() < messageCount; ++x)
213 // {
214 // this_thread::sleep_for(chrono::milliseconds(50));
215 // for (auto i: whost2->checkWatch(w))
216 // {
217 // Message msg = whost2->envelope(i).open(whost2->fullTopics(w));
218 // last = RLP(msg.payload()).toInt<unsigned>();
219 // if (received.insert(last).second)
220 // result += last;
221 // }
222 // }
223 // });
224 
225 // for (unsigned i = 0; i < 2000 && (!host2.haveNetwork() || !web3->haveNetwork()); i += step)
226 // this_thread::sleep_for(chrono::milliseconds(step));
227 
228 // BOOST_REQUIRE(host2.haveNetwork());
229 // BOOST_REQUIRE(web3->haveNetwork());
230 
231 // web3->requirePeer(host2.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), port2, port2));
232 
233 // for (unsigned i = 0; i < 3000 && (!web3->peerCount() || !host2.peerCount()); i += step)
234 // this_thread::sleep_for(chrono::milliseconds(step));
235 
236 // BOOST_REQUIRE_EQUAL(host2.peerCount(), 1);
237 // BOOST_REQUIRE_EQUAL(web3->peerCount(), 1);
238 
239 // KeyPair us = KeyPair::create();
240 // for (unsigned i = 0; i < messageCount; ++i)
241 // {
242 // web3->whisper()->post(us.secret(), RLPStream().append(i * i).out(), BuildTopic(i)(i % 2 ? "odd" : "even"), 777000, 1);
243 // this_thread::sleep_for(chrono::milliseconds(50));
244 // }
245 
246 // sent = true;
247 // auto messages = web3->whisper()->all();
248 // BOOST_REQUIRE_EQUAL(messages.size(), messageCount);
249 
250 // listener.join();
251 // BOOST_REQUIRE_EQUAL(result, 1 + 9 + 25 + 49 + 81);
252 //}
253 
254 //BOOST_AUTO_TEST_CASE(receive)
255 //{
256 // cnote << "Testing web3 receive...";
257 
258 // bool sent = false;
259 // bool ready = false;
260 // unsigned result = 0;
261 // unsigned const messageCount = 6;
262 // unsigned const step = 10;
263 // Host host2("shhrpc-host2", NetworkPreferences("127.0.0.1", 0, false));
264 // host2.setIdealPeerCount(1);
265 // auto whost2 = host2.registerCapability(make_shared<WhisperHost>());
266 // host2.start();
267 // web3->startNetwork();
268 // auto port2 = host2.listenPort();
269 // BOOST_REQUIRE(port2);
270 // BOOST_REQUIRE_NE(port2, web3->nodeInfo().port);
271 
272 // std::thread listener([&]()
273 // {
274 // setThreadName("listener");
275 // ready = true;
276 // auto w = web3->whisper()->installWatch(BuildTopicMask("odd"));
277 
278 // set<unsigned> received;
279 // for (unsigned x = 0; x < 7000 && !sent; x += step)
280 // this_thread::sleep_for(chrono::milliseconds(step));
281 
282 // for (unsigned x = 0, last = 0; x < 100 && received.size() < messageCount; ++x)
283 // {
284 // this_thread::sleep_for(chrono::milliseconds(50));
285 // for (auto i: web3->whisper()->checkWatch(w))
286 // {
287 // Message msg = web3->whisper()->envelope(i).open(web3->whisper()->fullTopics(w));
288 // last = RLP(msg.payload()).toInt<unsigned>();
289 // if (received.insert(last).second)
290 // result += last;
291 // }
292 // }
293 
294 // web3->whisper()->uninstallWatch(w);
295 // });
296 
297 // for (unsigned i = 0; i < 2000 && (!host2.haveNetwork() || !web3->haveNetwork()); i += step)
298 // this_thread::sleep_for(chrono::milliseconds(step));
299 
300 // BOOST_REQUIRE(host2.haveNetwork());
301 // BOOST_REQUIRE(web3->haveNetwork());
302 
303 // auto port1 = web3->nodeInfo().port;
304 // host2.addNode(web3->id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), port1, port1));
305 
306 // for (unsigned i = 0; i < 3000 && (!web3->peerCount() || !host2.peerCount()); i += step)
307 // this_thread::sleep_for(chrono::milliseconds(step));
308 
309 // BOOST_REQUIRE_EQUAL(host2.peerCount(), 1);
310 // BOOST_REQUIRE_EQUAL(web3->peerCount(), 1);
311 
312 // KeyPair us = KeyPair::create();
313 // for (unsigned i = 0; i < messageCount; ++i)
314 // {
315 // web3->whisper()->post(us.secret(), RLPStream().append(i * i * i).out(), BuildTopic(i)(i % 2 ? "odd" : "even"), c_ttl, 1);
316 // this_thread::sleep_for(chrono::milliseconds(50));
317 // }
318 
319 // sent = true;
320 // listener.join();
321 // BOOST_REQUIRE_EQUAL(result, 1 + 27 + 125);
322 //}
323 
324 //BOOST_AUTO_TEST_CASE(serverBasic)
325 //{
326 // cnote << "Testing basic jsonrpc server...";
327 
328 // string s = w3Face->web3_clientVersion();
329 // BOOST_REQUIRE_EQUAL(s, c_version);
330 
331 // s = netFace->net_version();
332 // BOOST_REQUIRE(s.empty());
333 
334 // s = w3Face->web3_sha3("some pseudo-random string here");
335 // BOOST_REQUIRE_EQUAL(s.size(), h256::size * 2 + 2);
336 // BOOST_REQUIRE('0' == s[0] && 'x' == s[1]);
337 
338 // s = netFace->net_peerCount();
339 // BOOST_REQUIRE(!s.empty());
340 
341 // KeyPair src = KeyPair::create();
342 // KeyPair dst = KeyPair::create();
343 // Json::Value t1 = createMessage(toJS(src.address()), toJS(dst.address()));
344 // bool b = whisperFace->shh_post(t1);
345 // BOOST_REQUIRE(b);
346 
347 // string const id = whisperFace->shh_newIdentity();
348 // BOOST_REQUIRE_EQUAL(id.size(), 130);
349 // BOOST_REQUIRE('0' == id[0] && 'x' == id[1]);
350 
351 // b = whisperFace->shh_hasIdentity(id);
352 // BOOST_REQUIRE(b);
353 
354 // Json::Value t2 = createMessage(id, id);
355 // b = whisperFace->shh_post(t2);
356 // BOOST_REQUIRE(b);
357 //}
358 
359 //BOOST_AUTO_TEST_CASE(server)
360 //{
361 // cnote << "Testing server functionality...";
362 
363 // bool b;
364 // string s;
365 // Json::Value j;
366 // rpc::SessionPermissions permissions;
367 // permissions.privileges.insert(rpc::Privilege::Admin);
368 // string const text = string("0x") + h256::random().hex(); // message must be in raw form
369 
370 // string sess1 = sm.newSession(permissions);
371 // string sess2("session number two");
372 // sm.addSession(sess2, permissions);
373 
374 // int newVerbosity = 10;
375 // int oldVerbosity = g_logVerbosity;
376 // b = adminUtilsFace->admin_setVerbosity(newVerbosity, sess1);
377 // BOOST_REQUIRE(b);
378 // BOOST_REQUIRE_EQUAL(g_logVerbosity, newVerbosity);
379 
380 // b = adminUtilsFace->admin_setVerbosity(oldVerbosity, sess1);
381 // BOOST_REQUIRE(b);
382 // BOOST_REQUIRE_EQUAL(g_logVerbosity, oldVerbosity);
383 
384 // b = adminNetFace->admin_net_start(sess1);
385 // BOOST_REQUIRE(b);
386 
387 // unsigned const step = 10;
388 // for (unsigned i = 0; i < 3000 && !netFace->net_listening(); i += step)
389 // this_thread::sleep_for(chrono::milliseconds(step));
390 
391 // b = netFace->net_listening();
392 // BOOST_REQUIRE(b);
393 
394 // b = adminNetFace->admin_net_stop(sess1);
395 // BOOST_REQUIRE(b);
396 
397 // b = netFace->net_listening();
398 // BOOST_REQUIRE(!b);
399 
400 // j = adminNetFace->admin_net_peers(sess1);
401 // BOOST_REQUIRE(j.empty());
402 
403 // j = adminNetFace->admin_net_nodeInfo(sess2);
404 // BOOST_REQUIRE_EQUAL(j["id"].asString(), web3->id().hex());
405 // BOOST_REQUIRE_EQUAL(j["port"].asUInt(), web3->nodeInfo().port);
406 
407 // Host host2("shhrpc-host2", NetworkPreferences("127.0.0.1", 0, false));
408 // host2.setIdealPeerCount(9);
409 // auto whost2 = host2.registerCapability(make_shared<WhisperHost>());
410 // host2.start();
411 // auto port2 = host2.listenPort();
412 // BOOST_REQUIRE(port2);
413 // BOOST_REQUIRE_NE(port2, web3->nodeInfo().port);
414 
415 // b = adminNetFace->admin_net_start(sess2);
416 // BOOST_REQUIRE(b);
417 
418 // for (unsigned i = 0; i < 2000 && !host2.haveNetwork(); i += step)
419 // this_thread::sleep_for(chrono::milliseconds(step));
420 
421 // for (unsigned i = 0; i < 2000 && !netFace->net_listening(); i += step)
422 // this_thread::sleep_for(chrono::milliseconds(step));
423 
424 // BOOST_REQUIRE(host2.haveNetwork());
425 // BOOST_REQUIRE(netFace->net_listening());
426 
427 // string node("enode://");
428 // node += host2.id().hex();
429 // node += "@127.0.0.1:";
430 // node += toString(port2);
431 // b = adminNetFace->admin_net_connect(node, sess2);
432 
433 // for (unsigned i = 0; i < 3000 && !host2.peerCount(); i += step)
434 // this_thread::sleep_for(chrono::milliseconds(step));
435 
436 // BOOST_REQUIRE_EQUAL(host2.peerCount(), 1);
437 // this_thread::sleep_for(chrono::milliseconds(step));
438 
439 // j = adminNetFace->admin_net_peers(sess2);
440 // BOOST_REQUIRE_EQUAL(j.size(), 1);
441 // Json::Value peer = j[0];
442 // s = peer["id"].asString();
443 // BOOST_REQUIRE_EQUAL(s, host2.id().hex());
444 // BOOST_REQUIRE_EQUAL(peer["port"].asUInt(), port2);
445 
446 // s = netFace->net_peerCount();
447 // BOOST_REQUIRE_EQUAL(s, "0x1");
448 
449 // KeyPair src = KeyPair::create();
450 // KeyPair dst = KeyPair::create();
451 
452 // Json::Value t1 = createMessage(toJS(src.address()), toJS(dst.address()));
453 // b = whisperFace->shh_post(t1);
454 // BOOST_REQUIRE(b);
455 
456 // string const id = whisperFace->shh_newIdentity();
457 // BOOST_REQUIRE_EQUAL(id.size(), 130);
458 // BOOST_REQUIRE(whisperFace->shh_hasIdentity(id));
459 
460 // Json::Value t2 = createMessage(id, id);
461 // b = whisperFace->shh_post(t2);
462 // BOOST_REQUIRE(b);
463 
464 // string const nonexistent = "123456789";
465 // b = whisperFace->shh_uninstallFilter(nonexistent);
466 // BOOST_REQUIRE(b);
467 
468 // j = whisperFace->shh_getMessages(nonexistent);
469 // BOOST_REQUIRE(j.empty());
470 
471 // string const topic = "unicorns";
472 // Json::Value t(Json::arrayValue);
473 // t.append(topic);
474 // Json::Value f;
475 // f["to"] = id;
476 // f["topics"] = t;
477 // string const filter = whisperFace->shh_newFilter(f);
478 
479 // j = whisperFace->shh_getFilterChanges(filter);
480 // BOOST_REQUIRE(j.empty());
481 
482 // j = whisperFace->shh_getMessages(filter);
483 // BOOST_REQUIRE(j.empty());
484 
485 // Json::Value msg = createMessage(id, id, topic, text);
486 // b = whisperFace->shh_post(msg);
487 // BOOST_REQUIRE(b);
488 // this_thread::sleep_for(chrono::milliseconds(50));
489 
490 // j = whisperFace->shh_getFilterChanges(filter);
491 // BOOST_REQUIRE(!j.empty());
492 // Json::Value m1 = j[0];
493 // BOOST_REQUIRE_EQUAL(m1["ttl"], toJS(c_ttl));
494 // BOOST_REQUIRE_EQUAL(m1["from"], id);
495 // BOOST_REQUIRE_EQUAL(m1["to"], id);
496 // BOOST_REQUIRE_EQUAL(m1["payload"], text);
497 
498 // j = whisperFace->shh_getMessages(filter);
499 // BOOST_REQUIRE(!j.empty());
500 // Json::Value m2 = j[0];
501 // BOOST_REQUIRE_EQUAL(m2["ttl"], toJS(c_ttl));
502 // BOOST_REQUIRE_EQUAL(m2["from"], id);
503 // BOOST_REQUIRE_EQUAL(m2["to"], id);
504 // BOOST_REQUIRE_EQUAL(m2["payload"], text);
505 
506 // j = whisperFace->shh_getFilterChanges(filter);
507 // BOOST_REQUIRE(j.empty());
508 
509 // j = whisperFace->shh_getMessages(filter);
510 // BOOST_REQUIRE(!j.empty());
511 // m1 = j[0];
512 // BOOST_REQUIRE_EQUAL(m1["ttl"], toJS(c_ttl));
513 // BOOST_REQUIRE_EQUAL(m1["from"], id);
514 // BOOST_REQUIRE_EQUAL(m1["to"], id);
515 // BOOST_REQUIRE_EQUAL(m1["payload"], text);
516 // cnote << "Testing web3 receive...";
517 
518 // bool sent = false;
519 // bool ready = false;
520 // unsigned result = 0;
521 // unsigned const messageCount = 6;
522 // unsigned const step = 10;
523 // Host host2("shhrpc-host2", NetworkPreferences("127.0.0.1", 0, false));
524 // host2.setIdealPeerCount(1);
525 // auto whost2 = host2.registerCapability(make_shared<WhisperHost>());
526 // host2.start();
527 // web3->startNetwork();
528 // auto port2 = host2.listenPort();
529 // BOOST_REQUIRE(port2);
530 // BOOST_REQUIRE_NE(port2, web3->nodeInfo().port);
531 
532 // std::thread listener([&]()
533 // {
534 // setThreadName("listener");
535 // ready = true;
536 // auto w = web3->whisper()->installWatch(BuildTopicMask("odd"));
537 
538 // set<unsigned> received;
539 // for (unsigned x = 0; x < 7000 && !sent; x += step)
540 // this_thread::sleep_for(chrono::milliseconds(step));
541 
542 // for (unsigned x = 0, last = 0; x < 100 && received.size() < messageCount; ++x)
543 // {
544 // this_thread::sleep_for(chrono::milliseconds(50));
545 // for (auto i: web3->whisper()->checkWatch(w))
546 // {
547 // Message msg = web3->whisper()->envelope(i).open(web3->whisper()->fullTopics(w));
548 // last = RLP(msg.payload()).toInt<unsigned>();
549 // if (received.insert(last).second)
550 // result += last;
551 // }
552 // }
553 
554 // web3->whisper()->uninstallWatch(w);
555 // });
556 
557 // for (unsigned i = 0; i < 2000 && (!host2.haveNetwork() || !web3->haveNetwork()); i += step)
558 // this_thread::sleep_for(chrono::milliseconds(step));
559 
560 // BOOST_REQUIRE(host2.haveNetwork());
561 // BOOST_REQUIRE(web3->haveNetwork());
562 
563 // auto port1 = web3->nodeInfo().port;
564 // host2.addNode(web3->id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), port1, port1));
565 
566 // for (unsigned i = 0; i < 3000 && (!web3->peerCount() || !host2.peerCount()); i += step)
567 // this_thread::sleep_for(chrono::milliseconds(step));
568 
569 // BOOST_REQUIRE_EQUAL(host2.peerCount(), 1);
570 // BOOST_REQUIRE_EQUAL(web3->peerCount(), 1);
571 
572 // KeyPair us = KeyPair::create();
573 // for (unsigned i = 0; i < messageCount; ++i)
574 // {
575 // web3->whisper()->post(us.secret(), RLPStream().append(i * i * i).out(), BuildTopic(i)(i % 2 ? "odd" : "even"), c_ttl, 1);
576 // this_thread::sleep_for(chrono::milliseconds(50));
577 // }
578 
579 // sent = true;
580 // listener.join();
581 // BOOST_REQUIRE_EQUAL(result, 1 + 27 + 125);
582 // msg = createMessage(id, id, topic);
583 // b = whisperFace->shh_post(msg);
584 // BOOST_REQUIRE(b);
585 // this_thread::sleep_for(chrono::milliseconds(50));
586 
587 // j = whisperFace->shh_getFilterChanges(filter);
588 // BOOST_REQUIRE_EQUAL(j.size(), 1);
589 
590 // j = whisperFace->shh_getMessages(filter);
591 // BOOST_REQUIRE_EQUAL(j.size(), 2);
592 
593 // b = whisperFace->shh_uninstallFilter(filter);
594 // BOOST_REQUIRE(b);
595 
596 // j = whisperFace->shh_getFilterChanges(filter);
597 // BOOST_REQUIRE(j.empty());
598 
599 // j = whisperFace->shh_getMessages(filter);
600 // BOOST_REQUIRE(j.empty());
601 
602 // msg = createMessage(id, id, topic);
603 // b = whisperFace->shh_post(msg);
604 // BOOST_REQUIRE(b);
605 // this_thread::sleep_for(chrono::milliseconds(50));
606 
607 // j = whisperFace->shh_getFilterChanges(filter);
608 // BOOST_REQUIRE(j.empty());
609 
610 // j = whisperFace->shh_getMessages(filter);
611 // BOOST_REQUIRE(j.empty());
612 
613 // b = adminNetFace->admin_net_stop(sess2);
614 // BOOST_REQUIRE(b);
615 
616 // b = netFace->net_listening();
617 // BOOST_REQUIRE(!b);
618 //}
619 
rpc::EthFace * ethFace
Definition: shhrpc.cpp:61
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
TestOutputHelper testHelper
Definition: shhrpc.cpp:104
std::string const & clientVersion() const
Definition: WebThree.h:146
unique_ptr< AccountHolder > accountHolder
Definition: shhrpc.cpp:64
eth::Client * ethereum() const
Definition: WebThree.h:140
rpc::NetFace * netFace
Definition: shhrpc.cpp:58
~Setup()
Definition: shhrpc.cpp:99
std::hash for asio::adress
Definition: Common.h:323
Main API hub for interfacing with Web 3 components.
Definition: WebThree.h:119
Definition: Eth.h:45
rpc::AdminNetFace * adminNetFace
Definition: shhrpc.cpp:62
unique_ptr< ModularServer< rpc::EthFace, rpc::WhisperFace, rpc::NetFace, rpc::Web3Face, rpc::AdminNetFace, rpc::AdminUtilsFace > > modularServer
Definition: shhrpc.cpp:56
Config::Value_type Value
High-level manager of password-encrypted keys for Ethereum.
Definition: KeyManager.h:72
std::string toJS(FixedHash< S > const &_h)
Definition: CommonJS.h:34
rpc::SessionManager sm
Definition: shhrpc.cpp:60
rpc::AdminUtilsFace * adminUtilsFace
Definition: shhrpc.cpp:63
Definition: shhrpc.cpp:69
unique_ptr< WebThreeStubClient > jsonrpcClient
Definition: shhrpc.cpp:65
rpc::Web3Face * w3Face
Definition: shhrpc.cpp:59
WebThreeDirect * web3
Definition: shhrpc.cpp:54
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY!
rpc::WhisperFace * whisperFace
Definition: shhrpc.cpp:57
#define BOOST_AUTO_TEST_SUITE_END()
Definition: object.cpp:16
void setIdealPeerCount(size_t _n) override
Sets the ideal number of peers.
Definition: WebThree.cpp:130
Setup()
Definition: shhrpc.cpp:71
static bool test_allowLocal
Setting true causes isAllowed to return true for all addresses. (Used by test fixtures) ...
Definition: Common.h:185
Helper functions to work with json::spirit and test files.
Json::Value createMessage(string const &_from, string const &_to, string const &_topic="", string _payload="")
Definition: shhrpc.cpp:107