table: drop Selectors processing from PIT
refs #4805
Change-Id: Ic15aec7f30d40485031e48e83377a621279e82f1
diff --git a/daemon/table/pit-entry.cpp b/daemon/table/pit-entry.cpp
index 4f6f3f4..4de7bcd 100644
--- a/daemon/table/pit-entry.cpp
+++ b/daemon/table/pit-entry.cpp
@@ -43,8 +43,9 @@
return m_interest->getName().compare(nEqualNameComps, Name::npos,
interest.getName(), nEqualNameComps) == 0 &&
- m_interest->getSelectors() == interest.getSelectors();
- /// \todo #3162 match Link field
+ m_interest->getCanBePrefix() == interest.getCanBePrefix() &&
+ m_interest->getMustBeFresh() == interest.getMustBeFresh();
+ /// \todo #3162 match ForwardingHint field
}
InRecordCollection::iterator
diff --git a/tests/daemon/table/name-tree.t.cpp b/tests/daemon/table/name-tree.t.cpp
index b42de83..6c2f627 100644
--- a/tests/daemon/table/name-tree.t.cpp
+++ b/tests/daemon/table/name-tree.t.cpp
@@ -239,9 +239,10 @@
BOOST_CHECK_EQUAL(npe.hasTableEntries(), false);
BOOST_CHECK_EQUAL(npe.isEmpty(), true);
- auto pit1 = make_shared<pit::Entry>(*makeInterest(name));
- shared_ptr<Interest> interest2 = makeInterest(name);
- interest2->setMinSuffixComponents(2);
+ auto interest1 = makeInterest(name);
+ auto pit1 = make_shared<pit::Entry>(*interest1);
+ auto interest2 = makeInterest(name);
+ interest2->setMustBeFresh(true);
auto pit2 = make_shared<pit::Entry>(*interest2);
npe.insertPitEntry(pit1);
diff --git a/tests/daemon/table/pit-entry.t.cpp b/tests/daemon/table/pit-entry.t.cpp
index ac6709b..221753b 100644
--- a/tests/daemon/table/pit-entry.t.cpp
+++ b/tests/daemon/table/pit-entry.t.cpp
@@ -41,26 +41,23 @@
BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(CanMatch, 1)
BOOST_AUTO_TEST_CASE(CanMatch)
{
- shared_ptr<Interest> interest0 = makeInterest("/A");
+ auto interest0 = makeInterest("/A");
Entry entry(*interest0);
- shared_ptr<Interest> interest1 = makeInterest("/B");
+ auto interest1 = makeInterest("/B");
BOOST_CHECK_EQUAL(entry.canMatch(*interest1), false);
- shared_ptr<Interest> interest2 = makeInterest("/A");
- interest2->setNonce(27956);
+ auto interest2 = makeInterest("/A", false, nullopt, 27956);
BOOST_CHECK_EQUAL(entry.canMatch(*interest2), true);
- shared_ptr<Interest> interest3 = makeInterest("/A");
- interest3->setInterestLifetime(6210_ms);
+ auto interest3 = makeInterest("/A", false, 6210_ms);
BOOST_CHECK_EQUAL(entry.canMatch(*interest3), true);
- shared_ptr<Interest> interest4 = makeInterest("/A");
+ auto interest4 = makeInterest("/A");
interest4->setForwardingHint({{10, "/telia/terabits"}, {20, "/ucla/cs"}});
BOOST_CHECK_EQUAL(entry.canMatch(*interest4), false); // expected failure until #3162
- shared_ptr<Interest> interest5 = makeInterest("/A");
- interest5->setMaxSuffixComponents(21);
+ auto interest5 = makeInterest("/A", true);
BOOST_CHECK_EQUAL(entry.canMatch(*interest5), false);
}
@@ -69,20 +66,12 @@
auto face1 = make_shared<DummyFace>();
auto face2 = make_shared<DummyFace>();
- Name name("ndn:/KuYfjtRq");
+ Name name("/KuYfjtRq");
auto interest = makeInterest(name);
- auto interest1 = makeInterest(name);
- interest1->setInterestLifetime(2528_ms);
- interest1->setNonce(25559);
- auto interest2 = makeInterest(name);
- interest2->setInterestLifetime(6464_ms);
- interest2->setNonce(19004);
- auto interest3 = makeInterest(name);
- interest3->setInterestLifetime(3585_ms);
- interest3->setNonce(24216);
- auto interest4 = makeInterest(name);
- interest4->setInterestLifetime(8795_ms);
- interest4->setNonce(17365);
+ auto interest1 = makeInterest(name, false, 2528_ms, 25559);
+ auto interest2 = makeInterest(name, false, 6464_ms, 19004);
+ auto interest3 = makeInterest(name, false, 3585_ms, 24216);
+ auto interest4 = makeInterest(name, false, 8795_ms, 17365);
Entry entry(*interest);
@@ -194,7 +183,7 @@
BOOST_AUTO_TEST_CASE(Lifetime)
{
- auto interest = makeInterest("ndn:/7oIEurbgy6");
+ auto interest = makeInterest("/7oIEurbgy6");
auto face = make_shared<DummyFace>();
Entry entry(*interest);
@@ -211,12 +200,12 @@
OutRecord outR(*face1, 0);
BOOST_CHECK(outR.getIncomingNack() == nullptr);
- auto interest1 = makeInterest("ndn:/uWiapGjYL");
+ auto interest1 = makeInterest("/uWiapGjYL");
interest1->setNonce(165);
outR.update(*interest1);
BOOST_CHECK(outR.getIncomingNack() == nullptr);
- auto interest2 = makeInterest("ndn:/uWiapGjYL");
+ auto interest2 = makeInterest("/uWiapGjYL");
interest2->setNonce(996);
lp::Nack nack2(*interest2);
nack2.setReason(lp::NackReason::CONGESTION);
diff --git a/tests/daemon/table/pit.t.cpp b/tests/daemon/table/pit.t.cpp
index d5d77e9..99d23e7 100644
--- a/tests/daemon/table/pit.t.cpp
+++ b/tests/daemon/table/pit.t.cpp
@@ -29,8 +29,6 @@
#include "tests/daemon/global-io-fixture.hpp"
#include "tests/daemon/face/dummy-face.hpp"
-#include <ndn-cxx/exclude.hpp>
-
namespace nfd {
namespace pit {
namespace tests {
@@ -61,108 +59,62 @@
BOOST_AUTO_TEST_CASE(Insert)
{
- Name name1("ndn:/5vzBNnMst");
- Name name2("ndn:/igSGfEIM62");
- ndn::Exclude exclude1;
- exclude1.excludeOne(Name::Component("u26p47oep"));
- ndn::Exclude exclude2;
- exclude2.excludeBefore(Name::Component("u26p47oep"));
- ndn::KeyLocator keyLocator1("ndn:/sGAE3peMHA");
- ndn::KeyLocator keyLocator2("ndn:/nIJH6pr4");
+ Name name1("/5vzBNnMst");
+ Name name2("/igSGfEIM62");
NameTree nameTree(16);
Pit pit(nameTree);
BOOST_CHECK_EQUAL(pit.size(), 0);
- std::pair<shared_ptr<Entry>, bool> insertResult;
+
+ shared_ptr<Entry> entry;
+ bool isNew = false;
// base
- auto interestA = make_shared<Interest>(name1);
- insertResult = pit.insert(*interestA);
- BOOST_CHECK_EQUAL(insertResult.second, true);
+ auto interestA = makeInterest(name1, false, nullopt, 2148);
+ std::tie(entry, isNew) = pit.insert(*interestA);
+ BOOST_CHECK_EQUAL(isNew, true);
BOOST_CHECK_EQUAL(pit.size(), 1);
- // same as A
+ // same Interest, same PIT entry
auto interestA2 = make_shared<Interest>(*interestA);
- insertResult = pit.insert(*interestA2);
- BOOST_CHECK_EQUAL(insertResult.second, false); // sharing the same PIT entry
+ std::tie(entry, isNew) = pit.insert(*interestA2);
+ BOOST_CHECK_EQUAL(isNew, false);
BOOST_CHECK_EQUAL(pit.size(), 1);
- // A+MinSuffixComponents
+ // different CanBePrefix, different PIT entry
auto interestB = make_shared<Interest>(*interestA);
- interestB->setMinSuffixComponents(2);
- insertResult = pit.insert(*interestB);
- BOOST_CHECK_EQUAL(insertResult.second, true);
+ interestB->setCanBePrefix(true);
+ std::tie(entry, isNew) = pit.insert(*interestB);
+ BOOST_CHECK_EQUAL(isNew, true);
BOOST_CHECK_EQUAL(pit.size(), 2);
- // A+MaxSuffixComponents
+ // different MustBeFresh, different PIT entry
auto interestC = make_shared<Interest>(*interestA);
- interestC->setMaxSuffixComponents(4);
- insertResult = pit.insert(*interestC);
- BOOST_CHECK_EQUAL(insertResult.second, true);
+ interestC->setMustBeFresh(true);
+ std::tie(entry, isNew) = pit.insert(*interestC);
+ BOOST_CHECK_EQUAL(isNew, true);
BOOST_CHECK_EQUAL(pit.size(), 3);
- // A+KeyLocator1
+ // different InterestLifetime, same PIT entry
auto interestD = make_shared<Interest>(*interestA);
- interestD->setPublisherPublicKeyLocator(keyLocator1);
- insertResult = pit.insert(*interestD);
- BOOST_CHECK_EQUAL(insertResult.second, true);
- BOOST_CHECK_EQUAL(pit.size(), 4);
+ interestD->setInterestLifetime(1_s);
+ std::tie(entry, isNew) = pit.insert(*interestD);
+ BOOST_CHECK_EQUAL(isNew, false);
+ BOOST_CHECK_EQUAL(pit.size(), 3);
- // A+KeyLocator2
+ // different Nonce, same PIT entry
auto interestE = make_shared<Interest>(*interestA);
- interestE->setPublisherPublicKeyLocator(keyLocator2);
- insertResult = pit.insert(*interestE);
- BOOST_CHECK_EQUAL(insertResult.second, true);
- BOOST_CHECK_EQUAL(pit.size(), 5);
+ interestE->setNonce(2192);
+ std::tie(entry, isNew) = pit.insert(*interestE);
+ BOOST_CHECK_EQUAL(isNew, false);
+ BOOST_CHECK_EQUAL(pit.size(), 3);
- // A+Exclude1
+ // different name, different PIT entry
auto interestF = make_shared<Interest>(*interestA);
- interestF->setExclude(exclude1);
- insertResult = pit.insert(*interestF);
- BOOST_CHECK_EQUAL(insertResult.second, true);
- BOOST_CHECK_EQUAL(pit.size(), 6);
-
- // A+Exclude2
- auto interestG = make_shared<Interest>(*interestA);
- interestG->setExclude(exclude2);
- insertResult = pit.insert(*interestG);
- BOOST_CHECK_EQUAL(insertResult.second, true);
- BOOST_CHECK_EQUAL(pit.size(), 7);
-
- // A+ChildSelector1
- auto interestI = make_shared<Interest>(*interestA);
- interestI->setChildSelector(1);
- insertResult = pit.insert(*interestI);
- BOOST_CHECK_EQUAL(insertResult.second, true);
- BOOST_CHECK_EQUAL(pit.size(), 8);
-
- // A+MustBeFresh
- auto interestJ = make_shared<Interest>(*interestA);
- interestJ->setMustBeFresh(true);
- insertResult = pit.insert(*interestJ);
- BOOST_CHECK_EQUAL(insertResult.second, true);
- BOOST_CHECK_EQUAL(pit.size(), 9);
-
- // A+InterestLifetime
- auto interestK = make_shared<Interest>(*interestA);
- interestK->setInterestLifetime(1_s);
- insertResult = pit.insert(*interestK);
- BOOST_CHECK_EQUAL(insertResult.second, false); // only guiders differ
- BOOST_CHECK_EQUAL(pit.size(), 9);
-
- // A+Nonce
- auto interestL = make_shared<Interest>(*interestA);
- interestL->setNonce(2192);
- insertResult = pit.insert(*interestL);
- BOOST_CHECK_EQUAL(insertResult.second, false); // only guiders differ
- BOOST_CHECK_EQUAL(pit.size(), 9);
-
- // different Name+Exclude1
- auto interestM = make_shared<Interest>(name2);
- interestM->setExclude(exclude1);
- insertResult = pit.insert(*interestM);
- BOOST_CHECK_EQUAL(insertResult.second, true);
- BOOST_CHECK_EQUAL(pit.size(), 10);
+ interestF->setName(name2);
+ std::tie(entry, isNew) = pit.insert(*interestF);
+ BOOST_CHECK_EQUAL(isNew, true);
+ BOOST_CHECK_EQUAL(pit.size(), 4);
}
BOOST_AUTO_TEST_CASE(Erase)
@@ -172,26 +124,27 @@
NameTree nameTree(16);
Pit pit(nameTree);
- std::pair<shared_ptr<Entry>, bool> insertResult;
+ shared_ptr<Entry> entry;
+ bool isNew = false;
BOOST_CHECK_EQUAL(pit.size(), 0);
- insertResult = pit.insert(*interest);
- BOOST_CHECK_EQUAL(insertResult.second, true);
+ std::tie(entry, isNew) = pit.insert(*interest);
+ BOOST_CHECK_EQUAL(isNew, true);
BOOST_CHECK_EQUAL(pit.size(), 1);
BOOST_CHECK(pit.find(*interest) != nullptr);
- insertResult = pit.insert(*interest);
- BOOST_CHECK_EQUAL(insertResult.second, false);
+ std::tie(entry, isNew) = pit.insert(*interest);
+ BOOST_CHECK_EQUAL(isNew, false);
BOOST_CHECK_EQUAL(pit.size(), 1);
BOOST_CHECK(pit.find(*interest) != nullptr);
- pit.erase(insertResult.first.get());
+ pit.erase(entry.get());
BOOST_CHECK_EQUAL(pit.size(), 0);
BOOST_CHECK(pit.find(*interest) == nullptr);
- insertResult = pit.insert(*interest);
- BOOST_CHECK_EQUAL(insertResult.second, true);
+ std::tie(entry, isNew) = pit.insert(*interest);
+ BOOST_CHECK_EQUAL(isNew, true);
BOOST_CHECK_EQUAL(pit.size(), 1);
BOOST_CHECK(pit.find(*interest) != nullptr);
}
@@ -203,7 +156,7 @@
size_t nNameTreeEntriesBefore = nameTree.size();
auto interest = makeInterest("/37xWVvQ2K");
- shared_ptr<Entry> entry = pit.insert(*interest).first;
+ auto entry = pit.insert(*interest).first;
pit.erase(entry.get());
BOOST_CHECK_EQUAL(nameTree.size(), nNameTreeEntriesBefore);
}
@@ -238,11 +191,11 @@
BOOST_AUTO_TEST_CASE(FindAllDataMatches)
{
- Name nameA ("ndn:/A");
- Name nameAB ("ndn:/A/B");
- Name nameABC ("ndn:/A/B/C");
- Name nameABCD("ndn:/A/B/C/D");
- Name nameD ("ndn:/D");
+ Name nameA ("/A");
+ Name nameAB ("/A/B");
+ Name nameABC ("/A/B/C");
+ Name nameABCD("/A/B/C/D");
+ Name nameD ("/D");
auto interestA = makeInterest(nameA, true);
auto interestABC = makeInterest(nameABC, true);
@@ -271,7 +224,7 @@
bool hasABC = false;
bool hasD = false;
- for (const shared_ptr<Entry>& entry : matches) {
+ for (const auto& entry : matches) {
++count;
if (entry->getName().equals(nameA ))
@@ -307,7 +260,7 @@
DataMatchResult matches = pit.findAllDataMatches(*data);
BOOST_REQUIRE_EQUAL(std::distance(matches.begin(), matches.end()), 1);
- shared_ptr<Entry> found = *matches.begin();
+ auto found = *matches.begin();
BOOST_CHECK_EQUAL(found->getName(), fullName);
}
@@ -333,8 +286,8 @@
auto d3 = makeData(n3);
auto i3 = makeInterest(d3->getFullName());
- shared_ptr<Entry> entry2 = pit.insert(*i2).first;
- shared_ptr<Entry> entry3 = pit.insert(*i3).first;
+ auto entry2 = pit.insert(*i2).first;
+ auto entry3 = pit.insert(*i3).first;
BOOST_CHECK_EQUAL(pit.size(), 2);
BOOST_CHECK_EQUAL(nameTree.size(), 1 + NameTree::getMaxDepth()); // root node + max depth
@@ -354,11 +307,11 @@
NameTree nameTree(16);
Pit pit(nameTree);
- auto interestA = makeInterest("/A");
+ auto interestA = makeInterest("/A");
auto interestABC1 = makeInterest("/A/B/C");
auto interestABC2 = makeInterest("/A/B/C");
- interestABC2->setSelectors(ndn::Selectors().setMinSuffixComponents(10));
- auto interestD = makeInterest("/D");
+ interestABC2->setMustBeFresh(true);
+ auto interestD = makeInterest("/D");
BOOST_CHECK_EQUAL(pit.size(), 0);
BOOST_CHECK(pit.begin() == pit.end());
@@ -379,16 +332,13 @@
pit.insert(*interestABC2);
pit.insert(*interestD);
- std::set<const Interest*> expected = {&*interestA, &*interestABC1, &*interestABC2, &*interestD};
std::set<const Interest*> actual;
for (const auto& pitEntry : pit) {
actual.insert(&pitEntry.getInterest());
}
- BOOST_CHECK(actual == expected);
- for (auto actualIt = actual.begin(), expectedIt = expected.begin();
- actualIt != actual.end() && expectedIt != expected.end(); ++actualIt, ++expectedIt) {
- BOOST_CHECK_EQUAL(**actualIt, **expectedIt);
- }
+ std::set<const Interest*> expected = {interestA.get(), interestABC1.get(),
+ interestABC2.get(), interestD.get()};
+ BOOST_CHECK_EQUAL_COLLECTIONS(actual.begin(), actual.end(), expected.begin(), expected.end());
}
BOOST_AUTO_TEST_SUITE_END() // TestPit