tests: don't use makeDummyClientFace
refs #3383
Change-Id: Ia71fa8e349ced7495edcb79336ee34894bb200cb
diff --git a/tests/unit/clients/iterative-query-controller.cpp b/tests/unit/clients/iterative-query-controller.cpp
index 254b4f3..a34375b 100644
--- a/tests/unit/clients/iterative-query-controller.cpp
+++ b/tests/unit/clients/iterative-query-controller.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2016, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -37,25 +37,25 @@
{
public:
QueryControllerFixture()
- : producerFace(ndn::util::makeDummyClientFace(io, { false, true }))
- , consumerFace(ndn::util::makeDummyClientFace(io, { false, true }))
- , validator(*producerFace)
- , top(m_root.getName(), m_certName, *producerFace, m_session, m_keyChain, validator)
- , net(m_net.getName(), m_certName, *producerFace, m_session, m_keyChain, validator)
- , ndnsim(m_ndnsim.getName(), m_certName, *producerFace, m_session, m_keyChain, validator)
+ : producerFace(io, {false, true})
+ , consumerFace(io, {false, true})
+ , validator(producerFace)
+ , top(m_root.getName(), m_certName, producerFace, m_session, m_keyChain, validator)
+ , net(m_net.getName(), m_certName, producerFace, m_session, m_keyChain, validator)
+ , ndnsim(m_ndnsim.getName(), m_certName, producerFace, m_session, m_keyChain, validator)
{
run();
- producerFace->onSendInterest.connect([this] (const Interest& interest) {
- io.post([=] { consumerFace->receive(interest); });
+ producerFace.onSendInterest.connect([this] (const Interest& interest) {
+ io.post([=] { consumerFace.receive(interest); });
});
- consumerFace->onSendInterest.connect([this] (const Interest& interest) {
- io.post([=] { producerFace->receive(interest); });
+ consumerFace.onSendInterest.connect([this] (const Interest& interest) {
+ io.post([=] { producerFace.receive(interest); });
});
- producerFace->onSendData.connect([this] (const Data& data) {
- io.post([=] { consumerFace->receive(data); });
+ producerFace.onSendData.connect([this] (const Data& data) {
+ io.post([=] { consumerFace.receive(data); });
});
- consumerFace->onSendData.connect([this] (const Data& data) {
- io.post([=] { producerFace->receive(data); });
+ consumerFace.onSendData.connect([this] (const Data& data) {
+ io.post([=] { producerFace.receive(data); });
});
}
@@ -68,8 +68,8 @@
public:
boost::asio::io_service io;
- shared_ptr<ndn::util::DummyClientFace> producerFace;
- shared_ptr<ndn::util::DummyClientFace> consumerFace;
+ ndn::util::DummyClientFace producerFace;
+ ndn::util::DummyClientFace consumerFace;
Name hint;
Validator validator;
@@ -102,7 +102,7 @@
[&hasDataBack] (uint32_t errCode, const std::string& errMsg) {
BOOST_CHECK(false);
},
- *consumerFace);
+ consumerFace);
// IterativeQueryController is a whole process
// the tester should not send Interest one by one
diff --git a/tests/unit/daemon/name-server.cpp b/tests/unit/daemon/name-server.cpp
index 9e7a926..8944759 100644
--- a/tests/unit/daemon/name-server.cpp
+++ b/tests/unit/daemon/name-server.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2016, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -40,10 +40,10 @@
{
public:
NameServerFixture()
- : face(ndn::util::makeDummyClientFace({ false, true }))
+ : face({false, true})
, zone(m_root.getName())
- , validator(*face)
- , server(zone, m_certName, *face, m_session, m_keyChain, validator)
+ , validator(face)
+ , server(zone, m_certName, face, m_session, m_keyChain, validator)
{
// ensure prefix is registered
run();
@@ -52,12 +52,12 @@
void
run()
{
- face->getIoService().poll();
- face->getIoService().reset();
+ face.getIoService().poll();
+ face.getIoService().reset();
}
public:
- shared_ptr<ndn::util::DummyClientFace> face;
+ ndn::util::DummyClientFace face;
Name hint;
const Name& zone;
Validator validator;
@@ -74,7 +74,7 @@
bool hasDataBack = false;
- face->onSendData.connectSingleShot([&] (const Data& data) {
+ face.onSendData.connectSingleShot([&] (const Data& data) {
hasDataBack = true;
NDNS_LOG_TRACE("get Data back");
BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
@@ -84,7 +84,7 @@
BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_RESP);
});
- face->receive(q.toInterest());
+ face.receive(q.toInterest());
run();
@@ -100,7 +100,7 @@
size_t nDataBack = 0;
// will ask for non-existing record
- face->onSendData.connectSingleShot([&] (const Data& data) {
+ face.onSendData.connectSingleShot([&] (const Data& data) {
++nDataBack;
NDNS_LOG_TRACE("get Data back");
BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
@@ -110,11 +110,11 @@
BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_NACK);
});
- face->receive(q.toInterest());
+ face.receive(q.toInterest());
run();
// will ask for the existing record (will have type NDNS_RAW, as it is certificate)
- face->onSendData.connectSingleShot([&] (const Data& data) {
+ face.onSendData.connectSingleShot([&] (const Data& data) {
++nDataBack;
NDNS_LOG_TRACE("get Data back");
BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
@@ -126,15 +126,15 @@
q.setRrLabel("dsk-1");
- face->receive(q.toInterest());
+ face.receive(q.toInterest());
run();
BOOST_CHECK_EQUAL(nDataBack, 2);
// explicit interest with correct version
- face->receive(Interest("/test19/KEY/dsk-1/ID-CERT/%FDd"));
+ face.receive(Interest("/test19/KEY/dsk-1/ID-CERT/%FDd"));
- face->onSendData.connectSingleShot([&] (const Data& data) {
+ face.onSendData.connectSingleShot([&] (const Data& data) {
++nDataBack;
Response resp;
@@ -146,9 +146,9 @@
BOOST_CHECK_EQUAL(nDataBack, 3);
// explicit interest with wrong version
- face->receive(Interest("/test19/KEY/dsk-1/ID-CERT/%FD010101010"));
+ face.receive(Interest("/test19/KEY/dsk-1/ID-CERT/%FD010101010"));
- face->onSendData.connectSingleShot([&] (const Data& data) {
+ face.onSendData.connectSingleShot([&] (const Data& data) {
++nDataBack;
Response resp;
@@ -187,7 +187,7 @@
bool hasDataBack = false;
- face->onSendData.connectSingleShot([&] (const Data& data) {
+ face.onSendData.connectSingleShot([&] (const Data& data) {
hasDataBack = true;
NDNS_LOG_TRACE("get Data back");
BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
@@ -206,7 +206,7 @@
BOOST_CHECK_EQUAL(ret, 0);
});
- face->receive(q.toInterest());
+ face.receive(q.toInterest());
run();
BOOST_CHECK_EQUAL(hasDataBack, true);
@@ -239,7 +239,7 @@
bool hasDataBack = false;
- face->onSendData.connectSingleShot([&] (const Data& data) {
+ face.onSendData.connectSingleShot([&] (const Data& data) {
hasDataBack = true;
NDNS_LOG_TRACE("get Data back");
BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
@@ -258,7 +258,7 @@
BOOST_CHECK_EQUAL(ret, 0);
});
- face->receive(q.toInterest());
+ face.receive(q.toInterest());
run();
BOOST_CHECK_EQUAL(hasDataBack, true);
@@ -316,12 +316,12 @@
bool hasDataBack = false;
// no data back, since the Update cannot pass verification
- face->onSendData.connectSingleShot([&] (const Data& data) {
+ face.onSendData.connectSingleShot([&] (const Data& data) {
hasDataBack = true;
BOOST_FAIL("UNEXPECTED");
});
- face->receive(q.toInterest());
+ face.receive(q.toInterest());
run();
BOOST_CHECK_EQUAL(hasDataBack, false);
@@ -331,21 +331,21 @@
{
public:
NameServerFixture2()
- : face(ndn::util::makeDummyClientFace(io, { false, true }))
- , validatorFace(ndn::util::makeDummyClientFace(io, { false, true }))
+ : face(io, m_keyChain, {false, true})
+ , validatorFace(io, m_keyChain, {false, true})
, zone(m_root.getName())
- , validator(*validatorFace) // different face for validator
- , server(zone, m_certName, *face, m_session, m_keyChain, validator)
+ , validator(validatorFace) // different face for validator
+ , server(zone, m_certName, face, m_session, m_keyChain, validator)
{
// ensure prefix is registered
run();
- validatorFace->onSendInterest.connect([this] (const Interest& interest) {
+ validatorFace.onSendInterest.connect([this] (const Interest& interest) {
NDNS_LOG_TRACE("validatorFace get Interest: " << interest.getName());
shared_ptr<const Interest> i = interest.shared_from_this();
io.post([i, this] {
- face->receive(*i);
+ face.receive(*i);
});
});
}
@@ -359,8 +359,8 @@
public:
boost::asio::io_service io;
- shared_ptr<ndn::util::DummyClientFace> face;
- shared_ptr<ndn::util::DummyClientFace> validatorFace;
+ ndn::util::DummyClientFace face;
+ ndn::util::DummyClientFace validatorFace;
Name hint;
const Name& zone;
Validator validator;
@@ -419,11 +419,11 @@
bool hasDataBack = false;
shared_ptr<Regex> regex = make_shared<Regex>("(<>*)<KEY>(<>+)<ID-CERT><>");
- face->onSendData.connect([&] (const Data& data) {
+ face.onSendData.connect([&] (const Data& data) {
if (regex->match(data.getName())) {
shared_ptr<const Data> d = data.shared_from_this();
io.post([d, this] {
- validatorFace->receive(*d); // It's data requested by validator
+ validatorFace.receive(*d); // It's data requested by validator
});
}
else {
@@ -447,7 +447,7 @@
}
});
- face->receive(q.toInterest());
+ face.receive(q.toInterest());
run();
BOOST_CHECK_EQUAL(hasDataBack, true);
diff --git a/tests/unit/validator.cpp b/tests/unit/validator.cpp
index 1ec16c6..b5fcfeb 100644
--- a/tests/unit/validator.cpp
+++ b/tests/unit/validator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2016, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -41,7 +41,7 @@
, m_randomId("/test03")
, m_keyChain("sqlite3", "file")
, m_version(name::Component::fromVersion(0))
- , m_face(ndn::util::makeDummyClientFace(ndn::util::DummyClientFace::Options { false, true }))
+ , m_face(m_keyChain, {false, true})
{
m_keyChain.deleteIdentity(m_testId1);
m_keyChain.deleteIdentity(m_testId2);
@@ -60,13 +60,13 @@
m_keyChain.addCertificate(*cert);
NDNS_LOG_TRACE("add cert: " << cert->getName() << " to KeyChain");
- m_face->onSendInterest.connect(bind(&Fixture::respondInterest, this, _1));
+ m_face.onSendInterest.connect(bind(&Fixture::respondInterest, this, _1));
}
~Fixture()
{
- m_face->getIoService().stop();
- m_face->shutdown();
+ m_face.getIoService().stop();
+ m_face.shutdown();
m_keyChain.deleteIdentity(m_testId1);
m_keyChain.deleteIdentity(m_testId2);
m_keyChain.deleteIdentity(m_testId3);
@@ -133,8 +133,8 @@
NDNS_LOG_TRACE("validator needs: " << certName);
BOOST_CHECK_EQUAL(m_keyChain.doesCertificateExist(certName), true);
auto cert = m_keyChain.getCertificate(certName);
- m_face->getIoService().post([this, cert] {
- m_face->receive<Data>(*cert);
+ m_face.getIoService().post([this, cert] {
+ m_face.receive<Data>(*cert);
});
}
@@ -158,14 +158,14 @@
name::Component m_version;
- shared_ptr<ndn::util::DummyClientFace> m_face;
+ ndn::util::DummyClientFace m_face;
};
BOOST_FIXTURE_TEST_CASE(Basic, Fixture)
{
// validator must be created after root key is saved to the target
- ndns::Validator validator(*m_face, TEST_CONFIG_PATH "/" "validator.conf");
+ ndns::Validator validator(m_face, TEST_CONFIG_PATH "/" "validator.conf");
Name dataName(m_testId3);
dataName.append("NDNS")
@@ -186,7 +186,7 @@
BOOST_CHECK(false);
});
- m_face->processEvents(time::milliseconds(-1));
+ m_face.processEvents(time::milliseconds(-1));
BOOST_CHECK_EQUAL(hasValidated, true);
@@ -210,7 +210,7 @@
BOOST_CHECK(true);
});
- m_face->processEvents(time::milliseconds(-1));
+ m_face.processEvents(time::milliseconds(-1));
// cannot pass verification due to key's owner's name is longer than data owner's
BOOST_CHECK_EQUAL(hasValidated, true);
@@ -234,7 +234,7 @@
BOOST_CHECK(true);
});
- m_face->processEvents(time::milliseconds(-1));
+ m_face.processEvents(time::milliseconds(-1));
// cannot pass due to self-sign cert is used
BOOST_CHECK_EQUAL(hasValidated, true);
@@ -257,7 +257,7 @@
BOOST_CHECK(true);
});
- m_face->processEvents(time::milliseconds(-1));
+ m_face.processEvents(time::milliseconds(-1));
// cannot pass due to a totally mismatched key
BOOST_CHECK_EQUAL(hasValidated, true);
}