fw: localhop scope restriction in BestRouteStrategy2
localhop scope rules are implemented as wouldViolateScope function;
the old violatesScope function is now deprecated.
Strategy::sendInterest overload without specific Interest packet is also
deprecated. BestRouteStrategy2 has switched to use the new overload.
refs #3841, #1756
Change-Id: Ic117f01926eadddf1da3ccb580b52a3903a70c89
diff --git a/tests/daemon/fw/pit-algorithm.t.cpp b/tests/daemon/fw/algorithm.t.cpp
similarity index 86%
rename from tests/daemon/fw/pit-algorithm.t.cpp
rename to tests/daemon/fw/algorithm.t.cpp
index 0589e0d..caebecc 100644
--- a/tests/daemon/fw/pit-algorithm.t.cpp
+++ b/tests/daemon/fw/algorithm.t.cpp
@@ -23,7 +23,7 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "fw/pit-algorithm.hpp"
+#include "fw/algorithm.hpp"
#include "tests/test-common.hpp"
#include "tests/daemon/face/dummy-face.hpp"
@@ -35,7 +35,7 @@
using namespace nfd::tests;
BOOST_AUTO_TEST_SUITE(Fw)
-BOOST_FIXTURE_TEST_SUITE(TestPitAlgorithm, BaseFixture)
+BOOST_FIXTURE_TEST_SUITE(TestAlgorithm, BaseFixture)
class ScopeControlFixture : public BaseFixture
{
@@ -55,6 +55,40 @@
shared_ptr<Face> localFace4;
};
+BOOST_FIXTURE_TEST_SUITE(WouldViolateScope, ScopeControlFixture)
+
+BOOST_AUTO_TEST_CASE(Unrestricted)
+{
+ shared_ptr<Interest> interest = makeInterest("ndn:/ieWRzDsCu");
+
+ BOOST_CHECK_EQUAL(wouldViolateScope(*nonLocalFace1, *interest, *nonLocalFace2), false);
+ BOOST_CHECK_EQUAL(wouldViolateScope(*nonLocalFace1, *interest, *localFace4), false);
+ BOOST_CHECK_EQUAL(wouldViolateScope(*localFace3, *interest, *nonLocalFace2), false);
+ BOOST_CHECK_EQUAL(wouldViolateScope(*localFace3, *interest, *localFace4), false);
+}
+
+BOOST_AUTO_TEST_CASE(Localhost)
+{
+ shared_ptr<Interest> interest = makeInterest("ndn:/localhost/5n1LzIt3");
+
+ // /localhost Interests from non-local faces should be rejected by incoming Interest pipeline,
+ // and are not tested here.
+ BOOST_CHECK_EQUAL(wouldViolateScope(*localFace3, *interest, *nonLocalFace2), true);
+ BOOST_CHECK_EQUAL(wouldViolateScope(*localFace3, *interest, *localFace4), false);
+}
+
+BOOST_AUTO_TEST_CASE(Localhop)
+{
+ shared_ptr<Interest> interest = makeInterest("ndn:/localhop/YcIKWCRYJ");
+
+ BOOST_CHECK_EQUAL(wouldViolateScope(*nonLocalFace1, *interest, *nonLocalFace2), true);
+ BOOST_CHECK_EQUAL(wouldViolateScope(*nonLocalFace1, *interest, *localFace4), false);
+ BOOST_CHECK_EQUAL(wouldViolateScope(*localFace3, *interest, *nonLocalFace2), false);
+ BOOST_CHECK_EQUAL(wouldViolateScope(*localFace3, *interest, *localFace4), false);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // WouldViolateScope
+
BOOST_FIXTURE_TEST_SUITE(ViolatesScope, ScopeControlFixture)
BOOST_AUTO_TEST_CASE(Unrestricted)