face: face refactoring completion
* delete old Face
* rename LpFace as Face
* eliminate LpFaceWrapper and use new Face
refs #3172
Change-Id: I08c3a5dfb4cc1b9834b30cccd9ab634535d0608c
diff --git a/tests/daemon/fw/client-control-strategy.t.cpp b/tests/daemon/fw/client-control-strategy.t.cpp
index 8f0870b..e180ec9 100644
--- a/tests/daemon/fw/client-control-strategy.t.cpp
+++ b/tests/daemon/fw/client-control-strategy.t.cpp
@@ -44,10 +44,10 @@
typedef StrategyTester<fw::ClientControlStrategy> ClientControlStrategyTester;
ClientControlStrategyTester strategy(forwarder);
- shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
- shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
- shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
- shared_ptr<DummyLocalFace> face4 = make_shared<DummyLocalFace>();
+ auto face1 = make_shared<DummyFace>();
+ auto face2 = make_shared<DummyFace>();
+ auto face3 = make_shared<DummyFace>();
+ auto face4 = make_shared<DummyFace>("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL);
forwarder.addFace(face1);
forwarder.addFace(face2);
forwarder.addFace(face3);
diff --git a/tests/daemon/fw/face-table.t.cpp b/tests/daemon/fw/face-table.t.cpp
index 6610034..59bb7c8 100644
--- a/tests/daemon/fw/face-table.t.cpp
+++ b/tests/daemon/fw/face-table.t.cpp
@@ -32,52 +32,49 @@
namespace nfd {
namespace tests {
-BOOST_FIXTURE_TEST_SUITE(FwFaceTable, BaseFixture)
+BOOST_AUTO_TEST_SUITE(Fw)
+BOOST_FIXTURE_TEST_SUITE(TestFaceTable, BaseFixture)
BOOST_AUTO_TEST_CASE(AddRemove)
{
Forwarder forwarder;
FaceTable& faceTable = forwarder.getFaceTable();
- std::vector<FaceId> onAddHistory;
- std::vector<FaceId> onRemoveHistory;
- faceTable.onAdd.connect([&] (shared_ptr<Face> face) {
- onAddHistory.push_back(face->getId());
- });
- faceTable.onRemove.connect([&] (shared_ptr<Face> face) {
- onRemoveHistory.push_back(face->getId());
- });
+ std::vector<FaceId> addHistory;
+ std::vector<FaceId> removeHistory;
+ faceTable.afterAdd.connect([&] (shared_ptr<Face> face) { addHistory.push_back(face->getId()); });
+ faceTable.beforeRemove.connect([&] (shared_ptr<Face> face) { removeHistory.push_back(face->getId()); });
shared_ptr<Face> face1 = make_shared<DummyFace>();
shared_ptr<Face> face2 = make_shared<DummyFace>();
- BOOST_CHECK_EQUAL(face1->getId(), INVALID_FACEID);
- BOOST_CHECK_EQUAL(face2->getId(), INVALID_FACEID);
+ BOOST_CHECK_EQUAL(face1->getId(), face::INVALID_FACEID);
+ BOOST_CHECK_EQUAL(face2->getId(), face::INVALID_FACEID);
forwarder.addFace(face1);
forwarder.addFace(face2);
- BOOST_CHECK_NE(face1->getId(), INVALID_FACEID);
- BOOST_CHECK_NE(face2->getId(), INVALID_FACEID);
+ BOOST_CHECK_NE(face1->getId(), face::INVALID_FACEID);
+ BOOST_CHECK_NE(face2->getId(), face::INVALID_FACEID);
BOOST_CHECK_NE(face1->getId(), face2->getId());
- BOOST_CHECK_GT(face1->getId(), FACEID_RESERVED_MAX);
- BOOST_CHECK_GT(face2->getId(), FACEID_RESERVED_MAX);
+ BOOST_CHECK_GT(face1->getId(), face::FACEID_RESERVED_MAX);
+ BOOST_CHECK_GT(face2->getId(), face::FACEID_RESERVED_MAX);
FaceId oldId1 = face1->getId();
faceTable.add(face1);
BOOST_CHECK_EQUAL(face1->getId(), oldId1);
BOOST_CHECK_EQUAL(faceTable.size(), 2);
- BOOST_REQUIRE_EQUAL(onAddHistory.size(), 2);
- BOOST_CHECK_EQUAL(onAddHistory[0], face1->getId());
- BOOST_CHECK_EQUAL(onAddHistory[1], face2->getId());
+ BOOST_REQUIRE_EQUAL(addHistory.size(), 2);
+ BOOST_CHECK_EQUAL(addHistory[0], face1->getId());
+ BOOST_CHECK_EQUAL(addHistory[1], face2->getId());
face1->close();
- BOOST_CHECK_EQUAL(face1->getId(), INVALID_FACEID);
+ BOOST_CHECK_EQUAL(face1->getId(), face::INVALID_FACEID);
- BOOST_REQUIRE_EQUAL(onRemoveHistory.size(), 1);
- BOOST_CHECK_EQUAL(onRemoveHistory[0], onAddHistory[0]);
+ BOOST_REQUIRE_EQUAL(removeHistory.size(), 1);
+ BOOST_CHECK_EQUAL(removeHistory[0], addHistory[0]);
}
BOOST_AUTO_TEST_CASE(AddReserved)
@@ -86,7 +83,7 @@
FaceTable& faceTable = forwarder.getFaceTable();
shared_ptr<Face> face1 = make_shared<DummyFace>();
- BOOST_CHECK_EQUAL(face1->getId(), INVALID_FACEID);
+ BOOST_CHECK_EQUAL(face1->getId(), face::INVALID_FACEID);
faceTable.addReserved(face1, 5);
BOOST_CHECK_EQUAL(face1->getId(), 5);
@@ -146,7 +143,8 @@
BOOST_CHECK(hasFace2);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestFaceTable
+BOOST_AUTO_TEST_SUITE_END() // Fw
} // namespace tests
} // namespace nfd
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index 67bce49..cfa5f71 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.cpp
@@ -25,8 +25,6 @@
#include "fw/forwarder.hpp"
#include "tests/daemon/face/dummy-face.hpp"
-#include "tests/daemon/face/dummy-lp-face.hpp"
-#include "face/lp-face-wrapper.hpp"
#include "dummy-strategy.hpp"
#include "tests/test-common.hpp"
@@ -51,10 +49,10 @@
interestAB->setInterestLifetime(time::seconds(4));
shared_ptr<Data> dataABC = makeData(nameABC);
- shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
- shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
- face1->afterSend.connect(afterOp);
- face2->afterSend.connect(afterOp);
+ auto face1 = make_shared<DummyFace>();
+ auto face2 = make_shared<DummyFace>();
+ face1->afterSend.connect(bind(afterOp));
+ face2->afterSend.connect(bind(afterOp));
forwarder.addFace(face1);
forwarder.addFace(face2);
@@ -66,10 +64,10 @@
BOOST_CHECK_EQUAL(forwarder.getCounters().nOutInterests, 0);
g_io.post([&] { face1->receiveInterest(*interestAB); });
BOOST_CHECK_EQUAL(limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS);
- BOOST_REQUIRE_EQUAL(face2->m_sentInterests.size(), 1);
- BOOST_CHECK_EQUAL(face2->m_sentInterests[0].getName(), nameAB);
- BOOST_REQUIRE(face2->m_sentInterests[0].getTag<lp::IncomingFaceIdTag>() != nullptr);
- BOOST_CHECK_EQUAL(*face2->m_sentInterests[0].getTag<lp::IncomingFaceIdTag>(), face1->getId());
+ BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face2->sentInterests[0].getName(), nameAB);
+ BOOST_REQUIRE(face2->sentInterests[0].getTag<lp::IncomingFaceIdTag>() != nullptr);
+ BOOST_CHECK_EQUAL(*face2->sentInterests[0].getTag<lp::IncomingFaceIdTag>(), face1->getId());
BOOST_CHECK_EQUAL(forwarder.getCounters().nInInterests, 1);
BOOST_CHECK_EQUAL(forwarder.getCounters().nOutInterests, 1);
@@ -77,10 +75,10 @@
BOOST_CHECK_EQUAL(forwarder.getCounters().nOutData, 0);
g_io.post([&] { face2->receiveData(*dataABC); });
BOOST_CHECK_EQUAL(limitedIo.run(1, time::seconds(1)), LimitedIo::EXCEED_OPS);
- BOOST_REQUIRE_EQUAL(face1->m_sentDatas.size(), 1);
- BOOST_CHECK_EQUAL(face1->m_sentDatas[0].getName(), nameABC);
- BOOST_REQUIRE(face1->m_sentDatas[0].getTag<lp::IncomingFaceIdTag>() != nullptr);
- BOOST_CHECK_EQUAL(*face1->m_sentDatas[0].getTag<lp::IncomingFaceIdTag>(), face2->getId());
+ BOOST_REQUIRE_EQUAL(face1->sentData.size(), 1);
+ BOOST_CHECK_EQUAL(face1->sentData[0].getName(), nameABC);
+ BOOST_REQUIRE(face1->sentData[0].getTag<lp::IncomingFaceIdTag>() != nullptr);
+ BOOST_CHECK_EQUAL(*face1->sentData[0].getTag<lp::IncomingFaceIdTag>(), face2->getId());
BOOST_CHECK_EQUAL(forwarder.getCounters().nInData, 1);
BOOST_CHECK_EQUAL(forwarder.getCounters().nOutData, 1);
}
@@ -90,9 +88,9 @@
LimitedIo limitedIo;
Forwarder forwarder;
- shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
- shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
- shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
+ auto face1 = make_shared<DummyFace>();
+ auto face2 = make_shared<DummyFace>();
+ auto face3 = make_shared<DummyFace>();
forwarder.addFace(face1);
forwarder.addFace(face2);
forwarder.addFace(face3);
@@ -115,12 +113,12 @@
face1->receiveInterest(*interestA);
limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(5));
// Interest matching ContentStore should not be forwarded
- BOOST_REQUIRE_EQUAL(face2->m_sentInterests.size(), 0);
+ BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 0);
- BOOST_REQUIRE_EQUAL(face1->m_sentDatas.size(), 1);
+ BOOST_REQUIRE_EQUAL(face1->sentData.size(), 1);
// IncomingFaceId field should be reset to represent CS
- BOOST_REQUIRE(face1->m_sentDatas[0].getTag<lp::IncomingFaceIdTag>() != nullptr);
- BOOST_CHECK_EQUAL(*face1->m_sentDatas[0].getTag<lp::IncomingFaceIdTag>(), FACEID_CONTENT_STORE);
+ BOOST_REQUIRE(face1->sentData[0].getTag<lp::IncomingFaceIdTag>() != nullptr);
+ BOOST_CHECK_EQUAL(*face1->sentData[0].getTag<lp::IncomingFaceIdTag>(), face::FACEID_CONTENT_STORE);
limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(500));
// PIT entry should not be left behind
@@ -155,8 +153,8 @@
BOOST_AUTO_TEST_CASE(ScopeLocalhostIncoming)
{
ScopeLocalhostIncomingTestForwarder forwarder;
- shared_ptr<Face> face1 = make_shared<DummyLocalFace>();
- shared_ptr<Face> face2 = make_shared<DummyFace>();
+ auto face1 = make_shared<DummyFace>("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL);
+ auto face2 = make_shared<DummyFace>();
forwarder.addFace(face1);
forwarder.addFace(face2);
@@ -212,9 +210,9 @@
BOOST_AUTO_TEST_CASE(ScopeLocalhostOutgoing)
{
Forwarder forwarder;
- shared_ptr<DummyLocalFace> face1 = make_shared<DummyLocalFace>();
- shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
- shared_ptr<Face> face3 = make_shared<DummyLocalFace>();
+ auto face1 = make_shared<DummyFace>("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL);
+ auto face2 = make_shared<DummyFace>();
+ auto face3 = make_shared<DummyFace>("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL);
forwarder.addFace(face1);
forwarder.addFace(face2);
forwarder.addFace(face3);
@@ -224,62 +222,62 @@
shared_ptr<Interest> interestA1 = makeInterest("/localhost/A1");
shared_ptr<pit::Entry> pitA1 = pit.insert(*interestA1).first;
pitA1->insertOrUpdateInRecord(face3, *interestA1);
- face1->m_sentInterests.clear();
+ face1->sentInterests.clear();
forwarder.onOutgoingInterest(pitA1, *face1);
- BOOST_CHECK_EQUAL(face1->m_sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face1->sentInterests.size(), 1);
// non-local face, /localhost: violate
shared_ptr<Interest> interestA2 = makeInterest("/localhost/A2");
shared_ptr<pit::Entry> pitA2 = pit.insert(*interestA2).first;
pitA2->insertOrUpdateInRecord(face3, *interestA2);
- face2->m_sentInterests.clear();
+ face2->sentInterests.clear();
forwarder.onOutgoingInterest(pitA2, *face2);
- BOOST_CHECK_EQUAL(face2->m_sentInterests.size(), 0);
+ BOOST_CHECK_EQUAL(face2->sentInterests.size(), 0);
// local face, non-/localhost: OK
shared_ptr<Interest> interestA3 = makeInterest("/A3");
shared_ptr<pit::Entry> pitA3 = pit.insert(*interestA3).first;
pitA3->insertOrUpdateInRecord(face3, *interestA3);
- face1->m_sentInterests.clear();
+ face1->sentInterests.clear();
forwarder.onOutgoingInterest(pitA3, *face1);
- BOOST_CHECK_EQUAL(face1->m_sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face1->sentInterests.size(), 1);
// non-local face, non-/localhost: OK
shared_ptr<Interest> interestA4 = makeInterest("/A4");
shared_ptr<pit::Entry> pitA4 = pit.insert(*interestA4).first;
pitA4->insertOrUpdateInRecord(face3, *interestA4);
- face2->m_sentInterests.clear();
+ face2->sentInterests.clear();
forwarder.onOutgoingInterest(pitA4, *face2);
- BOOST_CHECK_EQUAL(face2->m_sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face2->sentInterests.size(), 1);
// local face, /localhost: OK
- face1->m_sentDatas.clear();
+ face1->sentData.clear();
forwarder.onOutgoingData(Data("/localhost/B1"), *face1);
- BOOST_CHECK_EQUAL(face1->m_sentDatas.size(), 1);
+ BOOST_CHECK_EQUAL(face1->sentData.size(), 1);
// non-local face, /localhost: OK
- face2->m_sentDatas.clear();
+ face2->sentData.clear();
forwarder.onOutgoingData(Data("/localhost/B2"), *face2);
- BOOST_CHECK_EQUAL(face2->m_sentDatas.size(), 0);
+ BOOST_CHECK_EQUAL(face2->sentData.size(), 0);
// local face, non-/localhost: OK
- face1->m_sentDatas.clear();
+ face1->sentData.clear();
forwarder.onOutgoingData(Data("/B3"), *face1);
- BOOST_CHECK_EQUAL(face1->m_sentDatas.size(), 1);
+ BOOST_CHECK_EQUAL(face1->sentData.size(), 1);
// non-local face, non-/localhost: OK
- face2->m_sentDatas.clear();
+ face2->sentData.clear();
forwarder.onOutgoingData(Data("/B4"), *face2);
- BOOST_CHECK_EQUAL(face2->m_sentDatas.size(), 1);
+ BOOST_CHECK_EQUAL(face2->sentData.size(), 1);
}
BOOST_AUTO_TEST_CASE(ScopeLocalhopOutgoing)
{
Forwarder forwarder;
- shared_ptr<DummyLocalFace> face1 = make_shared<DummyLocalFace>();
- shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
- shared_ptr<DummyLocalFace> face3 = make_shared<DummyLocalFace>();
- shared_ptr<DummyFace> face4 = make_shared<DummyFace>();
+ auto face1 = make_shared<DummyFace>("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL);
+ auto face2 = make_shared<DummyFace>();
+ auto face3 = make_shared<DummyFace>("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL);
+ auto face4 = make_shared<DummyFace>();
forwarder.addFace(face1);
forwarder.addFace(face2);
forwarder.addFace(face3);
@@ -290,59 +288,59 @@
shared_ptr<Interest> interest1 = makeInterest("/localhop/1");
shared_ptr<pit::Entry> pit1 = pit.insert(*interest1).first;
pit1->insertOrUpdateInRecord(face1, *interest1);
- face3->m_sentInterests.clear();
+ face3->sentInterests.clear();
forwarder.onOutgoingInterest(pit1, *face3);
- BOOST_CHECK_EQUAL(face3->m_sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face3->sentInterests.size(), 1);
// from non-local face, to local face: OK
shared_ptr<Interest> interest2 = makeInterest("/localhop/2");
shared_ptr<pit::Entry> pit2 = pit.insert(*interest2).first;
pit2->insertOrUpdateInRecord(face2, *interest2);
- face3->m_sentInterests.clear();
+ face3->sentInterests.clear();
forwarder.onOutgoingInterest(pit2, *face3);
- BOOST_CHECK_EQUAL(face3->m_sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face3->sentInterests.size(), 1);
// from local face, to non-local face: OK
shared_ptr<Interest> interest3 = makeInterest("/localhop/3");
shared_ptr<pit::Entry> pit3 = pit.insert(*interest3).first;
pit3->insertOrUpdateInRecord(face1, *interest3);
- face4->m_sentInterests.clear();
+ face4->sentInterests.clear();
forwarder.onOutgoingInterest(pit3, *face4);
- BOOST_CHECK_EQUAL(face4->m_sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face4->sentInterests.size(), 1);
// from non-local face, to non-local face: violate
shared_ptr<Interest> interest4 = makeInterest("/localhop/4");
shared_ptr<pit::Entry> pit4 = pit.insert(*interest4).first;
pit4->insertOrUpdateInRecord(face2, *interest4);
- face4->m_sentInterests.clear();
+ face4->sentInterests.clear();
forwarder.onOutgoingInterest(pit4, *face4);
- BOOST_CHECK_EQUAL(face4->m_sentInterests.size(), 0);
+ BOOST_CHECK_EQUAL(face4->sentInterests.size(), 0);
// from local face and non-local face, to local face: OK
shared_ptr<Interest> interest5 = makeInterest("/localhop/5");
shared_ptr<pit::Entry> pit5 = pit.insert(*interest5).first;
pit5->insertOrUpdateInRecord(face1, *interest5);
pit5->insertOrUpdateInRecord(face2, *interest5);
- face3->m_sentInterests.clear();
+ face3->sentInterests.clear();
forwarder.onOutgoingInterest(pit5, *face3);
- BOOST_CHECK_EQUAL(face3->m_sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face3->sentInterests.size(), 1);
// from local face and non-local face, to non-local face: OK
shared_ptr<Interest> interest6 = makeInterest("/localhop/6");
shared_ptr<pit::Entry> pit6 = pit.insert(*interest6).first;
pit6->insertOrUpdateInRecord(face1, *interest6);
pit6->insertOrUpdateInRecord(face2, *interest6);
- face4->m_sentInterests.clear();
+ face4->sentInterests.clear();
forwarder.onOutgoingInterest(pit6, *face4);
- BOOST_CHECK_EQUAL(face4->m_sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face4->sentInterests.size(), 1);
}
BOOST_AUTO_TEST_CASE(IncomingInterestStrategyDispatch)
{
LimitedIo limitedIo;
Forwarder forwarder;
- shared_ptr<Face> face1 = make_shared<DummyFace>();
- shared_ptr<Face> face2 = make_shared<DummyFace>();
+ auto face1 = make_shared<DummyFace>();
+ auto face2 = make_shared<DummyFace>();
forwarder.addFace(face1);
forwarder.addFace(face2);
@@ -398,10 +396,10 @@
{
LimitedIo limitedIo;
Forwarder forwarder;
- shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
- shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
- shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
- shared_ptr<DummyFace> face4 = make_shared<DummyFace>();
+ auto face1 = make_shared<DummyFace>();
+ auto face2 = make_shared<DummyFace>();
+ auto face3 = make_shared<DummyFace>();
+ auto face4 = make_shared<DummyFace>();
forwarder.addFace(face1);
forwarder.addFace(face2);
forwarder.addFace(face3);
@@ -424,10 +422,10 @@
forwarder.onIncomingData(*face3, *dataD);
limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(5));
- BOOST_CHECK_EQUAL(face1->m_sentDatas.size(), 1);
- BOOST_CHECK_EQUAL(face2->m_sentDatas.size(), 1);
- BOOST_CHECK_EQUAL(face3->m_sentDatas.size(), 0);
- BOOST_CHECK_EQUAL(face4->m_sentDatas.size(), 1);
+ BOOST_CHECK_EQUAL(face1->sentData.size(), 1);
+ BOOST_CHECK_EQUAL(face2->sentData.size(), 1);
+ BOOST_CHECK_EQUAL(face3->sentData.size(), 0);
+ BOOST_CHECK_EQUAL(face4->sentData.size(), 1);
}
BOOST_AUTO_TEST_CASE(IncomingNack)
@@ -435,11 +433,10 @@
Forwarder forwarder;
auto face1 = make_shared<DummyFace>();
auto face2 = make_shared<DummyFace>();
- auto face3 = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>(
- "dummy://", "dummy://",
- ndn::nfd::FACE_SCOPE_NON_LOCAL,
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- ndn::nfd::LINK_TYPE_MULTI_ACCESS));
+ auto face3 = make_shared<DummyFace>("dummy://", "dummy://",
+ ndn::nfd::FACE_SCOPE_NON_LOCAL,
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ ndn::nfd::LINK_TYPE_MULTI_ACCESS);
forwarder.addFace(face1);
forwarder.addFace(face2);
forwarder.addFace(face3);
@@ -524,20 +521,15 @@
BOOST_AUTO_TEST_CASE(OutgoingNack)
{
Forwarder forwarder;
- auto face1w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>());
- auto face1 = static_cast<DummyLpFace*>(face1w->getLpFace());
- auto face2w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>());
- auto face2 = static_cast<DummyLpFace*>(face2w->getLpFace());
- auto face3w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>(
- "dummy://", "dummy://",
- ndn::nfd::FACE_SCOPE_NON_LOCAL,
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- ndn::nfd::LINK_TYPE_MULTI_ACCESS));
- auto face3 = static_cast<DummyLpFace*>(face3w->getLpFace());
- forwarder.addFace(face1w);
- forwarder.addFace(face2w);
- forwarder.addFace(face3w);
- // TODO#3172 eliminate wrapper
+ auto face1 = make_shared<DummyFace>();
+ auto face2 = make_shared<DummyFace>();
+ auto face3 = make_shared<DummyFace>("dummy://", "dummy://",
+ ndn::nfd::FACE_SCOPE_NON_LOCAL,
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ ndn::nfd::LINK_TYPE_MULTI_ACCESS);
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+ forwarder.addFace(face3);
Pit& pit = forwarder.getPit();
@@ -547,68 +539,63 @@
// don't send Nack if there's no in-record
shared_ptr<Interest> interest1 = makeInterest("/fM5IVEtC", 719);
shared_ptr<pit::Entry> pit1 = pit.insert(*interest1).first;
- pit1->insertOrUpdateInRecord(face1w, *interest1);
+ pit1->insertOrUpdateInRecord(face1, *interest1);
face2->sentNacks.clear();
- forwarder.onOutgoingNack(pit1, *face2w, nackHeader);
+ forwarder.onOutgoingNack(pit1, *face2, nackHeader);
BOOST_CHECK_EQUAL(face2->sentNacks.size(), 0);
// send Nack with correct Nonce
shared_ptr<Interest> interest2a = makeInterest("/Vi8tRm9MG3", 152);
shared_ptr<pit::Entry> pit2 = pit.insert(*interest2a).first;
- pit2->insertOrUpdateInRecord(face1w, *interest2a);
+ pit2->insertOrUpdateInRecord(face1, *interest2a);
shared_ptr<Interest> interest2b = makeInterest("/Vi8tRm9MG3", 808);
- pit2->insertOrUpdateInRecord(face2w, *interest2b);
+ pit2->insertOrUpdateInRecord(face2, *interest2b);
face1->sentNacks.clear();
- forwarder.onOutgoingNack(pit2, *face1w, nackHeader);
+ forwarder.onOutgoingNack(pit2, *face1, nackHeader);
BOOST_REQUIRE_EQUAL(face1->sentNacks.size(), 1);
BOOST_CHECK_EQUAL(face1->sentNacks.back().getReason(), lp::NackReason::CONGESTION);
BOOST_CHECK_EQUAL(face1->sentNacks.back().getInterest().getNonce(), 152);
// erase in-record
- pit::InRecordCollection::const_iterator inRecord2a = pit2->getInRecord(*face1w);
+ pit::InRecordCollection::const_iterator inRecord2a = pit2->getInRecord(*face1);
BOOST_CHECK(inRecord2a == pit2->getInRecords().end());
// send Nack with correct Nonce
face2->sentNacks.clear();
- forwarder.onOutgoingNack(pit2, *face2w, nackHeader);
+ forwarder.onOutgoingNack(pit2, *face2, nackHeader);
BOOST_REQUIRE_EQUAL(face2->sentNacks.size(), 1);
BOOST_CHECK_EQUAL(face2->sentNacks.back().getReason(), lp::NackReason::CONGESTION);
BOOST_CHECK_EQUAL(face2->sentNacks.back().getInterest().getNonce(), 808);
// erase in-record
- pit::InRecordCollection::const_iterator inRecord2b = pit2->getInRecord(*face1w);
+ pit::InRecordCollection::const_iterator inRecord2b = pit2->getInRecord(*face1);
BOOST_CHECK(inRecord2b == pit2->getInRecords().end());
// don't send Nack to multi-access face
shared_ptr<Interest> interest2c = makeInterest("/Vi8tRm9MG3", 228);
- pit2->insertOrUpdateInRecord(face3w, *interest2c);
+ pit2->insertOrUpdateInRecord(face3, *interest2c);
face3->sentNacks.clear();
- forwarder.onOutgoingNack(pit1, *face3w, nackHeader);
+ forwarder.onOutgoingNack(pit1, *face3, nackHeader);
BOOST_CHECK_EQUAL(face3->sentNacks.size(), 0);
}
BOOST_AUTO_TEST_CASE(InterestLoopNack)
{
Forwarder forwarder;
- auto face1w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>());
- auto face1 = static_cast<DummyLpFace*>(face1w->getLpFace());
- auto face2w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>());
- auto face2 = static_cast<DummyLpFace*>(face2w->getLpFace());
- auto face3w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>(
- "dummy://", "dummy://",
- ndn::nfd::FACE_SCOPE_NON_LOCAL,
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- ndn::nfd::LINK_TYPE_MULTI_ACCESS));
- auto face3 = static_cast<DummyLpFace*>(face3w->getLpFace());
+ auto face1 = make_shared<DummyFace>();
+ auto face2 = make_shared<DummyFace>();
+ auto face3 = make_shared<DummyFace>("dummy://", "dummy://",
+ ndn::nfd::FACE_SCOPE_NON_LOCAL,
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ ndn::nfd::LINK_TYPE_MULTI_ACCESS);
auto face4 = make_shared<DummyFace>();
- forwarder.addFace(face1w);
- forwarder.addFace(face2w);
- forwarder.addFace(face3w);
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+ forwarder.addFace(face3);
forwarder.addFace(face4);
- // TODO#3172 eliminate wrapper
Fib& fib = forwarder.getFib();
shared_ptr<fib::Entry> fibEntry = fib.insert(Name("/zT4XwK0Hnx")).first;
@@ -658,8 +645,11 @@
forwarder.addFace(face2);
// cause an Interest sent out of face2 to loop back into face1 after a delay
- face2->onSendInterest.connect([&face1] (const Interest& interest) {
- scheduler::schedule(time::milliseconds(170), [&] { face1->receiveInterest(interest); });
+ face2->afterSend.connect([face1, face2] (uint32_t pktType) {
+ if (pktType == tlv::Interest) {
+ auto interest = make_shared<Interest>(face2->sentInterests.back());
+ scheduler::schedule(time::milliseconds(170), [face1, interest] { face1->receiveInterest(*interest); });
+ }
});
Fib& fib = forwarder.getFib();
@@ -676,7 +666,7 @@
BOOST_ASSERT(time::milliseconds(25) * 40 < forwarder.getDeadNonceList().getLifetime());
this->advanceClocks(time::milliseconds(25), 40);
- BOOST_CHECK_EQUAL(face2->m_sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face2->sentInterests.size(), 1);
// It's unnecessary to check that Interest with duplicate Nonce can be forwarded again
// after it's gone from Dead Nonce List, because the entry lifetime of Dead Nonce List
diff --git a/tests/daemon/fw/strategy.t.cpp b/tests/daemon/fw/strategy.t.cpp
index 44fead2..90654d7 100644
--- a/tests/daemon/fw/strategy.t.cpp
+++ b/tests/daemon/fw/strategy.t.cpp
@@ -36,7 +36,8 @@
using namespace nfd::tests;
-BOOST_FIXTURE_TEST_SUITE(FwStrategy, BaseFixture)
+BOOST_AUTO_TEST_SUITE(Fw)
+BOOST_FIXTURE_TEST_SUITE(TestStrategy, BaseFixture)
class FaceTableAccessTestStrategy : public DummyStrategy
{
@@ -58,7 +59,7 @@
{
auto enumerable = this->getFaceTable() |
boost::adaptors::filtered([] (shared_ptr<Face> face) {
- return face->isLocal();
+ return face->getScope() == ndn::nfd::FACE_SCOPE_LOCAL;
});
std::vector<FaceId> results;
@@ -79,7 +80,7 @@
FaceTableAccessTestStrategy strategy(forwarder);
auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyLocalFace>();
+ auto face2 = make_shared<DummyFace>("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL);
forwarder.addFace(face1);
forwarder.addFace(face2);
FaceId id1 = face1->getId();
@@ -94,7 +95,8 @@
BOOST_CHECK((strategy.removedFaces == std::vector<FaceId>{id2, id1}));
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestStrategy
+BOOST_AUTO_TEST_SUITE_END() // Fw
} // namespace tests
} // namespace fw
diff --git a/tests/daemon/fw/topology-tester.cpp b/tests/daemon/fw/topology-tester.cpp
index 8b94abc..f1e54bb 100644
--- a/tests/daemon/fw/topology-tester.cpp
+++ b/tests/daemon/fw/topology-tester.cpp
@@ -34,7 +34,6 @@
using face::InternalTransportBase;
using face::InternalForwarderTransport;
using face::InternalClientTransport;
-using face::LpFaceWrapper;
using face::GenericLinkService;
TopologyLink::TopologyLink(const time::nanoseconds& delay)
@@ -46,9 +45,9 @@
}
void
-TopologyLink::addFace(TopologyNode i, shared_ptr<LpFaceWrapper> face)
+TopologyLink::addFace(TopologyNode i, shared_ptr<Face> face)
{
- this->attachTransport(i, dynamic_cast<InternalTransportBase*>(face->getLpFace()->getTransport()));
+ this->attachTransport(i, dynamic_cast<InternalTransportBase*>(face->getTransport()));
m_faces[i] = face;
}
@@ -87,9 +86,9 @@
});
}
-TopologyAppLink::TopologyAppLink(shared_ptr<LpFaceWrapper> forwarderFace)
+TopologyAppLink::TopologyAppLink(shared_ptr<Face> forwarderFace)
: m_face(forwarderFace)
- , m_forwarderTransport(static_cast<InternalForwarderTransport*>(forwarderFace->getLpFace()->getTransport()))
+ , m_forwarderTransport(static_cast<InternalForwarderTransport*>(forwarderFace->getTransport()))
, m_clientTransport(make_shared<InternalClientTransport>())
, m_client(make_shared<ndn::Face>(m_clientTransport, getGlobalIoService()))
{
@@ -136,11 +135,10 @@
auto service = make_unique<GenericLinkService>();
auto transport = make_unique<InternalForwarderTransport>(localUri, remoteUri,
ndn::nfd::FACE_SCOPE_NON_LOCAL, linkType);
- auto face = make_unique<LpFace>(std::move(service), std::move(transport));
- auto faceW = make_shared<LpFaceWrapper>(std::move(face));
+ auto face = make_shared<Face>(std::move(service), std::move(transport));
- forwarder.addFace(faceW);
- link->addFace(i, faceW);
+ forwarder.addFace(face);
+ link->addFace(i, face);
}
m_links.push_back(link); // keep a shared_ptr so callers don't have to
@@ -157,12 +155,11 @@
auto service = make_unique<GenericLinkService>();
auto transport = make_unique<InternalForwarderTransport>(localUri, remoteUri,
ndn::nfd::FACE_SCOPE_LOCAL, ndn::nfd::LINK_TYPE_POINT_TO_POINT);
- auto face = make_unique<LpFace>(std::move(service), std::move(transport));
- auto faceW = make_shared<LpFaceWrapper>(std::move(face));
+ auto face = make_shared<Face>(std::move(service), std::move(transport));
- forwarder.addFace(faceW);
+ forwarder.addFace(face);
- auto al = make_shared<TopologyAppLink>(faceW);
+ auto al = make_shared<TopologyAppLink>(face);
m_appLinks.push_back(al); // keep a shared_ptr so callers don't have to
return al;
}
diff --git a/tests/daemon/fw/topology-tester.hpp b/tests/daemon/fw/topology-tester.hpp
index 9a10ad7..88d73da 100644
--- a/tests/daemon/fw/topology-tester.hpp
+++ b/tests/daemon/fw/topology-tester.hpp
@@ -32,7 +32,7 @@
#include <ndn-cxx/face.hpp>
#include "face/internal-transport.hpp"
-#include "face/lp-face-wrapper.hpp"
+#include "face/face.hpp"
#include "fw/strategy.hpp"
#include "tests/test-common.hpp"
@@ -70,8 +70,12 @@
m_isUp = true;
}
+ /** \brief attach a face to the link
+ * \param i forwarder index
+ * \param face a Face with InternalForwarderTransport
+ */
void
- addFace(TopologyNode i, shared_ptr<face::LpFaceWrapper> face);
+ addFace(TopologyNode i, shared_ptr<Face> face);
/** \return a face of forwarder \p i which is attached to this link
*/
@@ -98,7 +102,7 @@
bool m_isUp;
time::nanoseconds m_delay;
std::unordered_map<TopologyNode, face::InternalTransportBase*> m_transports;
- std::unordered_map<TopologyNode, shared_ptr<face::LpFaceWrapper>> m_faces;
+ std::unordered_map<TopologyNode, shared_ptr<Face>> m_faces;
};
/** \brief represents a link to a local application
@@ -106,8 +110,11 @@
class TopologyAppLink : noncopyable
{
public:
+ /** \brief constructor
+ * \param forwarderFace a Face with InternalForwarderTransport
+ */
explicit
- TopologyAppLink(shared_ptr<face::LpFaceWrapper> forwarderFace);
+ TopologyAppLink(shared_ptr<Face> forwarderFace);
/** \brief fail the link, cause packets to be dropped silently
*/