fw: consumer retansmission in multicast startegy

refs: #2062

Change-Id: I2b58a289fffe262c69a797f339e40ad9037acf8f
diff --git a/tests/daemon/fw/multicast-strategy.t.cpp b/tests/daemon/fw/multicast-strategy.t.cpp
index be87930..07e854c 100644
--- a/tests/daemon/fw/multicast-strategy.t.cpp
+++ b/tests/daemon/fw/multicast-strategy.t.cpp
@@ -38,7 +38,7 @@
 typedef StrategyTester<MulticastStrategy> MulticastStrategyTester;
 NFD_REGISTER_STRATEGY(MulticastStrategyTester);
 
-class MulticastStrategyFixture : public BaseFixture
+class MulticastStrategyFixture : public UnitTestTimeFixture
 {
 protected:
   MulticastStrategyFixture()
@@ -91,23 +91,34 @@
   BOOST_CHECK_EQUAL_COLLECTIONS(sentInterestFaceIds.begin(), sentInterestFaceIds.end(),
                                 expectedInterestFaceIds.begin(), expectedInterestFaceIds.end());
 
-  // Check retransmission suppression, sendInterestHistory should remain 2
-  strategy.afterReceiveInterest(*face3, *interest, pitEntry);
-  BOOST_CHECK_EQUAL(strategy.sendInterestHistory.size(), 2);
-}
+  const time::nanoseconds TICK = time::duration_cast<time::nanoseconds>(
+                                 MulticastStrategy::RETX_SUPPRESSION_INITIAL * 0.1);
 
-BOOST_AUTO_TEST_CASE(RejectScope)
-{
-  fib::Entry& fibEntry = *fib.insert("ndn:/localhop/uS09bub6tm").first;
-  fibEntry.addNextHop(*face2, 0);
+  // downstream retransmits frequently, but the strategy should not send Interests
+  // more often than DEFAULT_MIN_RETX_INTERVAL
+  scheduler::EventId retxFrom4Evt;
+  size_t nSentLast = strategy.sendInterestHistory.size();
+  time::steady_clock::TimePoint timeSentLast = time::steady_clock::now();
+  function<void()> periodicalRetxFrom4; // let periodicalRetxFrom4 lambda capture itself
+  periodicalRetxFrom4 = [&] {
+    pitEntry->insertOrUpdateInRecord(*face3, *interest);
+    strategy.afterReceiveInterest(*face3, *interest, pitEntry);
 
-  shared_ptr<Interest> interest = makeInterest("ndn:/localhop/uS09bub6tm/eG3MMoP6z");
-  shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
-  pitEntry->insertOrUpdateInRecord(*face1, *interest);
+    size_t nSent = strategy.sendInterestHistory.size();
+    if (nSent > nSentLast) {
+      // Multicast strategy should multicast the interest to other two faces
+      BOOST_CHECK_EQUAL(nSent - nSentLast, 2);
+      time::steady_clock::TimePoint timeSent = time::steady_clock::now();
+      BOOST_CHECK_GE(timeSent - timeSentLast, TICK * 8);
+      nSentLast = nSent;
+      timeSentLast = timeSent;
+    }
 
-  strategy.afterReceiveInterest(*face1, *interest, pitEntry);
-  BOOST_CHECK_EQUAL(strategy.rejectPendingInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy.sendInterestHistory.size(), 0);
+    retxFrom4Evt = scheduler::schedule(TICK * 5, periodicalRetxFrom4);
+  };
+  periodicalRetxFrom4();
+  this->advanceClocks(TICK, MulticastStrategy::RETX_SUPPRESSION_MAX * 16);
+  scheduler::cancel(retxFrom4Evt);
 }
 
 BOOST_AUTO_TEST_CASE(RejectLoopback)
diff --git a/tests/daemon/fw/strategy-instantiation.t.cpp b/tests/daemon/fw/strategy-instantiation.t.cpp
index 21ab9a5..0e012b4 100644
--- a/tests/daemon/fw/strategy-instantiation.t.cpp
+++ b/tests/daemon/fw/strategy-instantiation.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2016,  Regents of the University of California,
+ * Copyright (c) 2014-2017,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -79,7 +79,7 @@
   Test<BestRouteStrategy, false, 1>,
   Test<BestRouteStrategy2, false, 4>,
   Test<ClientControlStrategy, false, 2>,
-  Test<MulticastStrategy, false, 1>,
+  Test<MulticastStrategy, false, 2>,
   Test<NccStrategy, false, 1>
 >;