mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
updates and fixes for code review
This commit is contained in:
parent
cc9a7cbb71
commit
2ed2a8ec8e
14
peer.cpp
14
peer.cpp
@ -51,6 +51,7 @@ BOOST_AUTO_TEST_SUITE_END()
|
|||||||
|
|
||||||
int peerTest(int argc, char** argv)
|
int peerTest(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
Public remoteAlias;
|
||||||
short listenPort = 30303;
|
short listenPort = 30303;
|
||||||
string remoteHost;
|
string remoteHost;
|
||||||
short remotePort = 30303;
|
short remotePort = 30303;
|
||||||
@ -64,21 +65,18 @@ int peerTest(int argc, char** argv)
|
|||||||
remoteHost = argv[++i];
|
remoteHost = argv[++i];
|
||||||
else if (arg == "-p" && i + 1 < argc)
|
else if (arg == "-p" && i + 1 < argc)
|
||||||
remotePort = (short)atoi(argv[++i]);
|
remotePort = (short)atoi(argv[++i]);
|
||||||
|
else if (arg == "-ra" && i + 1 < argc)
|
||||||
|
remoteAlias = Public(dev::fromHex(argv[++i]));
|
||||||
else
|
else
|
||||||
remoteHost = argv[i];
|
remoteHost = argv[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
Host ph("Test", NetworkPreferences(listenPort));
|
Host ph("Test", NetworkPreferences(listenPort));
|
||||||
|
|
||||||
if (!remoteHost.empty())
|
if (!remoteHost.empty() && !remoteAlias)
|
||||||
ph.addNode(NodeId(), remoteHost, remotePort, remotePort);
|
ph.addNode(remoteAlias, remoteHost, remotePort, remotePort);
|
||||||
|
|
||||||
// for (int i = 0; ; ++i)
|
this_thread::sleep_for(chrono::milliseconds(200));
|
||||||
// {
|
|
||||||
// this_thread::sleep_for(chrono::milliseconds(100));
|
|
||||||
// if (!(i % 10))
|
|
||||||
// ph.keepAlivePeers();
|
|
||||||
// }
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -34,29 +34,27 @@ BOOST_AUTO_TEST_CASE(topic)
|
|||||||
{
|
{
|
||||||
cnote << "Testing Whisper...";
|
cnote << "Testing Whisper...";
|
||||||
auto oldLogVerbosity = g_logVerbosity;
|
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;
|
bool started = false;
|
||||||
unsigned result = 0;
|
unsigned result = 0;
|
||||||
std::thread listener([&]()
|
std::thread listener([&]()
|
||||||
{
|
{
|
||||||
setThreadName("other");
|
setThreadName("other");
|
||||||
|
|
||||||
auto wh = ph1.registerCapability(new WhisperHost());
|
|
||||||
ph1.start();
|
|
||||||
|
|
||||||
started = true;
|
started = true;
|
||||||
|
|
||||||
/// Only interested in odd packets
|
/// 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 (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>();
|
last = RLP(msg.payload()).toInt<unsigned>();
|
||||||
cnote << "New message from:" << msg.from().abridged() << RLP(msg.payload()).toInt<unsigned>();
|
cnote << "New message from:" << msg.from().abridged() << RLP(msg.payload()).toInt<unsigned>();
|
||||||
result += last;
|
result += last;
|
||||||
@ -65,15 +63,15 @@ 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));
|
Host ph("Test", NetworkPreferences(30300, "127.0.0.1", true, true));
|
||||||
auto wh = ph.registerCapability(new WhisperHost());
|
auto wh = ph.registerCapability(new WhisperHost());
|
||||||
this_thread::sleep_for(chrono::milliseconds(500));
|
|
||||||
ph.start();
|
ph.start();
|
||||||
this_thread::sleep_for(chrono::milliseconds(500));
|
ph.addNode(phOther.id(), "127.0.0.1", 30303, 30303);
|
||||||
ph.addNode(ph1.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();
|
KeyPair us = KeyPair::create();
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
|
Loading…
Reference in New Issue
Block a user