Browse Source

fix net/ unit tests for nodetable updates

cl-refactor
subtly 10 years ago
parent
commit
14c2e4cab8
  1. 4
      libp2p/NodeTable.cpp
  2. 9
      test/net.cpp

4
libp2p/NodeTable.cpp

@ -340,7 +340,7 @@ void NodeTable::noteActiveNode(Public const& _pubk, bi::udp::endpoint const& _en
s.nodes.push_back(node);
s.touch();
if (!removed)
if (!removed && m_nodeEventHandler)
m_nodeEventHandler->appendEvent(node->id, NodeEntryAdded);
}
}
@ -349,7 +349,7 @@ void NodeTable::noteActiveNode(Public const& _pubk, bi::udp::endpoint const& _en
s.nodes.push_back(node);
s.touch();
if (!removed)
if (!removed && m_nodeEventHandler)
m_nodeEventHandler->appendEvent(node->id, NodeEntryAdded);
}
}

9
test/net.cpp

@ -89,7 +89,16 @@ struct TestNodeTable: public NodeTable
bi::address ourIp = bi::address::from_string("127.0.0.1");
for (auto& n: _testNodes)
if (_count--)
{
// manually add node for test
{
Guard ln(x_nodes);
shared_ptr<NodeEntry> node(new NodeEntry(m_node, n.first.pub(), NodeIPEndpoint(bi::udp::endpoint(ourIp, n.second), bi::tcp::endpoint(ourIp, n.second))));
node->pending = false;
m_nodes[node->id] = node;
}
noteActiveNode(n.first.pub(), bi::udp::endpoint(ourIp, n.second));
}
else
break;
}

Loading…
Cancel
Save