fw: fix NccStrategy loop back to sole downstream
refs #1998
Change-Id: I81c089f67aa6278a4fcb42ec79a32eed065e19f5
diff --git a/tests/daemon/fw/ncc-strategy.cpp b/tests/daemon/fw/ncc-strategy.cpp
index ab3f641..da70e86 100644
--- a/tests/daemon/fw/ncc-strategy.cpp
+++ b/tests/daemon/fw/ncc-strategy.cpp
@@ -1,12 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis
+ * Copyright (c) 2014-2015, Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology,
+ * The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -273,6 +273,40 @@
BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[1].get<1>(), face2);
}
+BOOST_AUTO_TEST_CASE(Bug1998)
+{
+ Forwarder forwarder;
+ typedef StrategyTester<fw::NccStrategy> NccStrategyTester;
+ shared_ptr<NccStrategyTester> strategy = make_shared<NccStrategyTester>(ref(forwarder));
+
+ shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+
+ Fib& fib = forwarder.getFib();
+ shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
+ fibEntry->addNextHop(face1, 10); // face1 is top-ranked nexthop
+ fibEntry->addNextHop(face2, 20);
+
+ StrategyChoice& strategyChoice = forwarder.getStrategyChoice();
+ strategyChoice.install(strategy);
+ strategyChoice.insert(Name(), strategy->getName());
+
+ Pit& pit = forwarder.getPit();
+
+ // Interest comes from face1, which is sole downstream
+ shared_ptr<Interest> interest1 = makeInterest("ndn:/tFy5HzUzD4");
+ shared_ptr<pit::Entry> pitEntry1 = pit.insert(*interest1).first;
+ pitEntry1->insertOrUpdateInRecord(face1, *interest1);
+
+ strategy->afterReceiveInterest(*face1, *interest1, fibEntry, pitEntry1);
+
+ // Interest shall go to face2, not loop back to face1
+ BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 1);
+ BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[0].get<1>(), face2);
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace tests