mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
updates for code-review
This commit is contained in:
parent
c44376d1f9
commit
1ff4301409
8
net.cpp
8
net.cpp
@ -87,7 +87,7 @@ struct TestNodeTable: public NodeTable
|
|||||||
bi::address ourIp = bi::address::from_string("127.0.0.1");
|
bi::address ourIp = bi::address::from_string("127.0.0.1");
|
||||||
for (auto& n: _testNodes)
|
for (auto& n: _testNodes)
|
||||||
if (_count--)
|
if (_count--)
|
||||||
noteNode(n.first.pub(), bi::udp::endpoint(ourIp, n.second));
|
noteActiveNode(n.first.pub(), bi::udp::endpoint(ourIp, n.second));
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ BOOST_AUTO_TEST_CASE(kademlia)
|
|||||||
// Not yet a 'real' test.
|
// Not yet a 'real' test.
|
||||||
TestNodeTableHost node(8);
|
TestNodeTableHost node(8);
|
||||||
node.start();
|
node.start();
|
||||||
node.nodeTable->join(); // ideally, joining with empty node table logs warning we can check for
|
node.nodeTable->discover(); // ideally, joining with empty node table logs warning we can check for
|
||||||
node.setup();
|
node.setup();
|
||||||
node.populate();
|
node.populate();
|
||||||
clog << "NodeTable:\n" << *node.nodeTable.get() << endl;
|
clog << "NodeTable:\n" << *node.nodeTable.get() << endl;
|
||||||
@ -199,11 +199,11 @@ BOOST_AUTO_TEST_CASE(kademlia)
|
|||||||
node.populate(1);
|
node.populate(1);
|
||||||
clog << "NodeTable:\n" << *node.nodeTable.get() << endl;
|
clog << "NodeTable:\n" << *node.nodeTable.get() << endl;
|
||||||
|
|
||||||
node.nodeTable->join();
|
node.nodeTable->discover();
|
||||||
this_thread::sleep_for(chrono::milliseconds(2000));
|
this_thread::sleep_for(chrono::milliseconds(2000));
|
||||||
clog << "NodeTable:\n" << *node.nodeTable.get() << endl;
|
clog << "NodeTable:\n" << *node.nodeTable.get() << endl;
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(node.nodeTable->size(), 8);
|
BOOST_REQUIRE_EQUAL(node.nodeTable->count(), 8);
|
||||||
|
|
||||||
auto netNodes = node.nodeTable->nodes();
|
auto netNodes = node.nodeTable->nodes();
|
||||||
netNodes.sort();
|
netNodes.sort();
|
||||||
|
@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(forwarding)
|
|||||||
setThreadName("listener");
|
setThreadName("listener");
|
||||||
|
|
||||||
// Host must be configured not to share peers.
|
// Host must be configured not to share peers.
|
||||||
Host ph("Listner", NetworkPreferences(50303, "", false, true));
|
Host ph("Listner", NetworkPreferences(30303, "", false, true));
|
||||||
ph.setIdealPeerCount(0);
|
ph.setIdealPeerCount(0);
|
||||||
auto wh = ph.registerCapability(new WhisperHost());
|
auto wh = ph.registerCapability(new WhisperHost());
|
||||||
ph.start();
|
ph.start();
|
||||||
@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE(forwarding)
|
|||||||
this_thread::sleep_for(chrono::milliseconds(50));
|
this_thread::sleep_for(chrono::milliseconds(50));
|
||||||
|
|
||||||
// Host must be configured not to share peers.
|
// Host must be configured not to share peers.
|
||||||
Host ph("Forwarder", NetworkPreferences(50305, "", false, true));
|
Host ph("Forwarder", NetworkPreferences(30305, "", false, true));
|
||||||
ph.setIdealPeerCount(0);
|
ph.setIdealPeerCount(0);
|
||||||
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));
|
||||||
@ -153,7 +153,7 @@ BOOST_AUTO_TEST_CASE(forwarding)
|
|||||||
fwderid = ph.id();
|
fwderid = ph.id();
|
||||||
|
|
||||||
this_thread::sleep_for(chrono::milliseconds(500));
|
this_thread::sleep_for(chrono::milliseconds(500));
|
||||||
ph.addNode(phid, "127.0.0.1", 50303, 50303);
|
ph.addNode(phid, "127.0.0.1", 30303, 30303);
|
||||||
|
|
||||||
startedForwarder = true;
|
startedForwarder = true;
|
||||||
|
|
||||||
@ -174,13 +174,13 @@ BOOST_AUTO_TEST_CASE(forwarding)
|
|||||||
while (!startedForwarder)
|
while (!startedForwarder)
|
||||||
this_thread::sleep_for(chrono::milliseconds(50));
|
this_thread::sleep_for(chrono::milliseconds(50));
|
||||||
|
|
||||||
Host ph("Sender", NetworkPreferences(50300, "", false, true));
|
Host ph("Sender", NetworkPreferences(30300, "", false, true));
|
||||||
ph.setIdealPeerCount(0);
|
ph.setIdealPeerCount(0);
|
||||||
shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost());
|
shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost());
|
||||||
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.addNode(fwderid, "127.0.0.1", 50305, 50305);
|
ph.addNode(fwderid, "127.0.0.1", 30305, 30305);
|
||||||
|
|
||||||
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"));
|
||||||
@ -210,14 +210,14 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
|
|||||||
setThreadName("forwarder");
|
setThreadName("forwarder");
|
||||||
|
|
||||||
// Host must be configured not to share peers.
|
// Host must be configured not to share peers.
|
||||||
Host ph("Forwarder", NetworkPreferences(50305, "", false, true));
|
Host ph("Forwarder", NetworkPreferences(30305, "", false, true));
|
||||||
ph.setIdealPeerCount(0);
|
ph.setIdealPeerCount(0);
|
||||||
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();
|
||||||
|
|
||||||
this_thread::sleep_for(chrono::milliseconds(500));
|
this_thread::sleep_for(chrono::milliseconds(500));
|
||||||
// ph.addNode("127.0.0.1", 50303, 50303);
|
// ph.addNode("127.0.0.1", 30303, 30303);
|
||||||
|
|
||||||
startedForwarder = true;
|
startedForwarder = true;
|
||||||
|
|
||||||
@ -239,13 +239,13 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
|
|||||||
this_thread::sleep_for(chrono::milliseconds(50));
|
this_thread::sleep_for(chrono::milliseconds(50));
|
||||||
|
|
||||||
{
|
{
|
||||||
Host ph("Sender", NetworkPreferences(50300, "", false, true));
|
Host ph("Sender", NetworkPreferences(30300, "", false, true));
|
||||||
ph.setIdealPeerCount(0);
|
ph.setIdealPeerCount(0);
|
||||||
shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost());
|
shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost());
|
||||||
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.addNode("127.0.0.1", 50305, 50305);
|
// 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"));
|
wh->post(us.sec(), RLPStream().append(1).out(), BuildTopic("test"));
|
||||||
@ -253,13 +253,13 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Host ph("Listener", NetworkPreferences(50300, "", false, true));
|
Host ph("Listener", NetworkPreferences(30300, "", false, true));
|
||||||
ph.setIdealPeerCount(0);
|
ph.setIdealPeerCount(0);
|
||||||
shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost());
|
shared_ptr<WhisperHost> wh = ph.registerCapability(new WhisperHost());
|
||||||
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.addNode("127.0.0.1", 50305, 50305);
|
// ph.addNode("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