Browse Source

test constants

cl-refactor
subtly 10 years ago
parent
commit
fdc28893c4
  1. 27
      test/net.cpp
  2. 23
      test/peer.cpp

27
test/net.cpp

@ -343,3 +343,30 @@ BOOST_AUTO_TEST_CASE(test_udp_once)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(netTypes)
BOOST_AUTO_TEST_CASE(unspecifiedNode)
{
Node n = UnspecifiedNode;
BOOST_REQUIRE(!n);
Node node(Public(sha3("0")), NodeIPEndpoint(bi::address(), 0, 0));
BOOST_REQUIRE(node);
BOOST_REQUIRE(n != node);
Node nodeEq(Public(sha3("0")), NodeIPEndpoint(bi::address(), 0, 0));
BOOST_REQUIRE_EQUAL(node, nodeEq);
}
BOOST_AUTO_TEST_CASE(nodeTableReturnsUnspecifiedNode)
{
ba::io_service io;
NodeTable t(io, KeyPair::create(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30303, 30303));
if (Node n = t.node(NodeId()))
BOOST_REQUIRE(false);
else
BOOST_REQUIRE(n == UnspecifiedNode);
}
BOOST_AUTO_TEST_SUITE_END()

23
test/peer.cpp

@ -112,6 +112,29 @@ BOOST_AUTO_TEST_CASE(save_nodes)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(peerTypes)
BOOST_AUTO_TEST_CASE(emptySharedPeer)
{
shared_ptr<Peer> p;
BOOST_REQUIRE(!p);
std::map<NodeId, std::shared_ptr<Peer>> peers;
p = peers[NodeId()];
BOOST_REQUIRE(!p);
p.reset(new Peer(UnspecifiedNode));
BOOST_REQUIRE(!p->id);
BOOST_REQUIRE(!*p);
p.reset(new Peer(Node(NodeId(EmptySHA3), UnspecifiedNodeIPEndpoint)));
BOOST_REQUIRE(!(!*p));
BOOST_REQUIRE(*p);
BOOST_REQUIRE(p);
}
BOOST_AUTO_TEST_SUITE_END()
int peerTest(int argc, char** argv)
{
Public remoteAlias;

Loading…
Cancel
Save