fw: use UnitTestClock in Forwarder persistent loop test case

refs #2162

Change-Id: Ibbf1d5fa615e4275a86caf64f79890d40cb09a77
diff --git a/tests/daemon/fw/forwarder.cpp b/tests/daemon/fw/forwarder.cpp
index 930de00..e824514 100644
--- a/tests/daemon/fw/forwarder.cpp
+++ b/tests/daemon/fw/forwarder.cpp
@@ -424,36 +424,40 @@
   BOOST_CHECK_EQUAL(face4->m_sentDatas.size(), 1);
 }
 
-static inline void
-delayedInterestLoop(const time::nanoseconds& delay, DummyFace& face, const Interest& interest)
+BOOST_FIXTURE_TEST_CASE(InterestLoopWithShortLifetime, UnitTestTimeFixture) // Bug 1953
 {
-  scheduler::schedule(delay, bind(&DummyFace::receiveInterest, &face, cref(interest)));
-}
-
-BOOST_AUTO_TEST_CASE(Bug1953) // persistent loop with short InterestLifetime
-{
-  LimitedIo limitedIo;
   Forwarder forwarder;
-  shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
-  shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
+  auto face1 = make_shared<DummyFace>();
+  auto face2 = make_shared<DummyFace>();
   forwarder.addFace(face1);
   forwarder.addFace(face2);
 
   // cause an Interest sent out of face2 to loop back into face1 after a delay
-  face2->onSendInterest += bind(&delayedInterestLoop, time::milliseconds(170), ref(*face1), _1);
+  face2->onSendInterest += [&face1] (const Interest& interest) {
+    scheduler::schedule(time::milliseconds(170), [&] { face1->receiveInterest(interest); });
+  };
 
   Fib& fib = forwarder.getFib();
   shared_ptr<fib::Entry> fibEntry = fib.insert(Name("ndn:/A")).first;
   fibEntry->addNextHop(face2, 0);
 
+  // receive an Interest
   shared_ptr<Interest> interest = makeInterest("ndn:/A/1");
   interest->setNonce(82101183);
   interest->setInterestLifetime(time::milliseconds(50));
   face1->receiveInterest(*interest);
 
-  limitedIo.defer(time::milliseconds(1000));
+  // interest should be forwarded only once, as long as Nonce is in Dead Nonce List
+  BOOST_ASSERT(time::milliseconds(25) * 40 < forwarder.getDeadNonceList().getLifetime());
+  this->advanceClocks(time::milliseconds(25), 40);
 
   BOOST_CHECK_EQUAL(face2->m_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
+  // is an implementation decision. NDN protocol requires Name+Nonce to be unique,
+  // without specifying when Name+Nonce could repeat. Forwarder is permitted to suppress
+  // an Interest if its Name+Nonce has appeared any point in the past.
 }
 
 BOOST_AUTO_TEST_SUITE_END()