rib: Cancel expiration on unregistration
refs: #1902
Change-Id: I85a75370ecc3677c8a9ebf3a48f3c0857598da2d
diff --git a/tests/rib/rib-manager.cpp b/tests/rib/rib-manager.cpp
index 593517f..0d43dcb 100644
--- a/tests/rib/rib-manager.cpp
+++ b/tests/rib/rib-manager.cpp
@@ -27,6 +27,7 @@
#include "tests/test-common.hpp"
#include "tests/dummy-client-face.hpp"
+#include "tests/limited-io.hpp"
#include "rib/rib-status-publisher-common.hpp"
namespace nfd {
@@ -255,6 +256,45 @@
RibStatusPublisherFixture::decodeRibEntryBlock(face->m_sentDatas[0], name, entry);
}
+BOOST_FIXTURE_TEST_CASE(CancelExpirationEvent, AuthorizedRibManager)
+{
+ // Register face
+ ControlParameters addParameters;
+ addParameters
+ .setName("/expire")
+ .setFaceId(1)
+ .setCost(10)
+ .setFlags(0)
+ .setOrigin(128)
+ .setExpirationPeriod(ndn::time::milliseconds(500));
+
+ Name registerName("/localhost/nfd/rib/register");
+
+ receiveCommandInterest(registerName, addParameters);
+ face->m_sentInterests.clear();
+
+ // Unregister face
+ ControlParameters removeParameters;
+ removeParameters
+ .setName("/expire")
+ .setFaceId(1)
+ .setOrigin(128);
+
+ Name unregisterName("/localhost/nfd/rib/unregister");
+
+ receiveCommandInterest(unregisterName, removeParameters);
+
+ // Reregister face
+ Name reRegisterName("/localhost/nfd/rib/register");
+ addParameters.setExpirationPeriod(ndn::time::milliseconds::max());
+ receiveCommandInterest(reRegisterName, addParameters);
+
+ nfd::tests::LimitedIo limitedIo;
+ limitedIo.run(nfd::tests::LimitedIo::UNLIMITED_OPS, time::seconds(1));
+
+ BOOST_REQUIRE_EQUAL(manager->m_managedRib.size(), 1);
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace tests
diff --git a/tests/rib/rib.cpp b/tests/rib/rib.cpp
index faa1845..3226e57 100644
--- a/tests/rib/rib.cpp
+++ b/tests/rib/rib.cpp
@@ -60,7 +60,9 @@
entry.insertFace(face2);
BOOST_CHECK_EQUAL(entry.getFaces().size(), 1);
- BOOST_CHECK_EQUAL(entry.eraseFace(face1), false);
+ entry.eraseFace(face1);
+ BOOST_CHECK_EQUAL(entry.getFaces().size(), 1);
+ BOOST_CHECK(entry.findFace(face2) != entry.getFaces().end());
}
BOOST_AUTO_TEST_CASE(Parent)