interest: update ForwardingHint format

Recognize and encode ForwardingHint as a sequence of Names.
The previous format with Delegations is still accepted for decoding, but
Preference field is ignored and no sorting is performed.

Delegation and DelegationList classes have been deleted.

refs #5187

Change-Id: I6f6f94020657b65c3fccb501694416dda24b894b
diff --git a/tests/unit/interest.t.cpp b/tests/unit/interest.t.cpp
index b630e64..482eac8 100644
--- a/tests/unit/interest.t.cpp
+++ b/tests/unit/interest.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -153,7 +153,7 @@
 BOOST_AUTO_TEST_CASE(Full)
 {
   const uint8_t WIRE[] = {
-    0x05, 0x5c, // Interest
+    0x05, 0x56, // Interest
           0x07, 0x36, // Name
                 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, // GenericNameComponent
                 0x08, 0x03, 0x6e, 0x64, 0x6e, // GenericNameComponent
@@ -164,12 +164,8 @@
                       0xcc, 0xd7, 0x2c, 0x6e, 0xa0, 0xf7, 0x31, 0x5a,
           0x21, 0x00, // CanBePrefix
           0x12, 0x00, // MustBeFresh
-          0x1e, 0x0b, // ForwardingHint
-                0x1f, 0x09, // Delegation List
-                      0x1e, 0x02,
-                            0x3e, 0x15,
-                      0x07, 0x03,
-                            0x08, 0x01, 0x48,
+          0x1e, 0x05, // ForwardingHint
+                0x07, 0x03, 0x08, 0x01, 0x48,
           0x0a, 0x04, // Nonce
                 0x4c, 0x1e, 0xcb, 0x4a,
           0x0c, 0x02, // InterestLifetime
@@ -184,7 +180,7 @@
   i1.setName("/local/ndn/prefix");
   i1.setMustBeFresh(true);
   i1.setCanBePrefix(true);
-  i1.setForwardingHint(DelegationList({{15893, "/H"}}));
+  i1.setForwardingHint({"/H"});
   i1.setNonce(0x4c1ecb4a);
   i1.setInterestLifetime(30369_ms);
   i1.setHopLimit(220);
@@ -199,7 +195,7 @@
                     "/local/ndn/prefix/params-sha256=ff9100e04eaadcf30674d98026a051ba25f56b69bfa026dcccd72c6ea0f7315a");
   BOOST_CHECK_EQUAL(i2.getCanBePrefix(), true);
   BOOST_CHECK_EQUAL(i2.getMustBeFresh(), true);
-  BOOST_CHECK_EQUAL(i2.getForwardingHint(), DelegationList({{15893, "/H"}}));
+  BOOST_TEST(i2.getForwardingHint() == std::vector<Name>({"/H"}), boost::test_tools::per_element());
   BOOST_CHECK_EQUAL(i2.hasNonce(), true);
   BOOST_CHECK_EQUAL(i2.getNonce(), 0x4c1ecb4a);
   BOOST_CHECK_EQUAL(i2.getInterestLifetime(), 30369_ms);
@@ -385,7 +381,7 @@
   {
     // initialize all elements to non-empty, to verify wireDecode clears them
     i.setName("/A");
-    i.setForwardingHint({{10309, "/F"}});
+    i.setForwardingHint({"/F"});
     i.setNonce(0x03d645a8);
     i.setInterestLifetime(18554_ms);
     i.setHopLimit(64);
@@ -448,7 +444,7 @@
   BOOST_CHECK_EQUAL(i.getName(), "/I");
   BOOST_CHECK_EQUAL(i.getCanBePrefix(), true);
   BOOST_CHECK_EQUAL(i.getMustBeFresh(), true);
-  BOOST_CHECK_EQUAL(i.getForwardingHint(), DelegationList({{15893, "/H"}}));
+  BOOST_TEST(i.getForwardingHint() == std::vector<Name>({"/H"}), boost::test_tools::per_element());
   BOOST_CHECK_EQUAL(i.hasNonce(), true);
   BOOST_CHECK_EQUAL(i.getNonce(), 0x4acb1e4c);
   BOOST_CHECK_EQUAL(i.getInterestLifetime(), 30369_ms);
@@ -459,11 +455,13 @@
   // encode without modification: retain original wire encoding
   BOOST_CHECK_EQUAL(i.wireEncode().value_size(), 49);
 
-  // modify then re-encode: unrecognized elements are discarded
+  // modify then re-encode:
+  // * unrecognized elements are discarded;
+  // * ForwardingHint is re-encoded as a sequence of Names
   i.setName("/J");
   BOOST_CHECK_EQUAL(i.wireEncode(),
-                    "0523 0703(08014A) "
-                    "2100 1200 1E0B(1F09 1E023E15 0703080148) "
+                    "051D 0703(08014A) "
+                    "2100 1200 1E05(0703080148) "
                     "0A044ACB1E4C 0C0276A1 2201D6"_block);
 }
 
@@ -476,7 +474,7 @@
                     "/I/params-sha256=f16db273f40436a852063f864d5072b01ead53151f5a688ea1560492bebedd05");
   BOOST_CHECK_EQUAL(i.getCanBePrefix(), true);
   BOOST_CHECK_EQUAL(i.getMustBeFresh(), true);
-  BOOST_CHECK_EQUAL(i.getForwardingHint(), DelegationList({{15893, "/H"}}));
+  BOOST_TEST(i.getForwardingHint() == std::vector<Name>({"/H"}), boost::test_tools::per_element());
   BOOST_CHECK_EQUAL(i.hasNonce(), true);
   BOOST_CHECK_EQUAL(i.getNonce(), 0x4acb1e4c);
   BOOST_CHECK_EQUAL(i.getInterestLifetime(), 30369_ms);
@@ -487,21 +485,22 @@
   // encode without modification: retain original wire encoding
   BOOST_CHECK_EQUAL(i.wireEncode().value_size(), 91);
 
-  // modify then re-encode: unrecognized elements after ApplicationParameters
-  //                        are preserved, the rest are discarded
+  // modify then re-encode:
+  // * unrecognized elements after ApplicationParameters are preserved, the rest are discarded;
+  // * ForwardingHint is re-encoded as a sequence of Names
   i.setName("/J");
   BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true);
   BOOST_CHECK_EQUAL(i.wireEncode(),
-                    "054D 0725(08014A 0220F16DB273F40436A852063F864D5072B01EAD53151F5A688EA1560492BEBEDD05) "
-                    "2100 1200 1E0B(1F09 1E023E15 0703080148) "
+                    "0547 0725(08014A 0220F16DB273F40436A852063F864D5072B01EAD53151F5A688EA1560492BEBEDD05) "
+                    "2100 1200 1E05(0703080148) "
                     "0A044ACB1E4C 0C0276A1 2201D6 2404C0C1C2C3 FC00"_block);
 
   // modify ApplicationParameters: unrecognized elements are preserved
   i.setApplicationParameters("2402CAFE"_block);
   BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true);
   BOOST_CHECK_EQUAL(i.wireEncode(),
-                    "054B 0725(08014A 02205FDA67967EE302FC457E41B7D3D51BA6A9379574D193FD88F64954BF16C2927A) "
-                    "2100 1200 1E0B(1F09 1E023E15 0703080148) "
+                    "0545 0725(08014A 02205FDA67967EE302FC457E41B7D3D51BA6A9379574D193FD88F64954BF16C2927A) "
+                    "2100 1200 1E05(0703080148) "
                     "0A044ACB1E4C 0C0276A1 2201D6 2402CAFE FC00"_block);
 }
 
@@ -689,7 +688,7 @@
   interest.setName("/A")
           .setCanBePrefix(true)
           .setMustBeFresh(true)
-          .setForwardingHint({{1, "/H"}})
+          .setForwardingHint({"/H"})
           .setNonce(2228)
           .setInterestLifetime(5_s)
           .setHopLimit(90);
@@ -706,7 +705,8 @@
   other.setMustBeFresh(interest.getMustBeFresh());
   BOOST_CHECK_EQUAL(interest.matchesInterest(other), false); // will match until #3162 implemented
 
-  other.setForwardingHint(interest.getForwardingHint());
+  auto fh = interest.getForwardingHint();
+  other.setForwardingHint(std::vector<Name>(fh.begin(), fh.end()));
   BOOST_CHECK_EQUAL(interest.matchesInterest(other), true);
 
   other.setNonce(9336);
@@ -754,19 +754,6 @@
   BOOST_CHECK_EQUAL(i.getMustBeFresh(), false);
 }
 
-BOOST_AUTO_TEST_CASE(ModifyForwardingHint)
-{
-  Interest i("/I");
-  i.setCanBePrefix(false);
-  i.setForwardingHint({{1, "/A"}});
-  i.wireEncode();
-  BOOST_CHECK(i.hasWire());
-
-  i.modifyForwardingHint([] (DelegationList& fh) { fh.insert(2, "/B"); });
-  BOOST_CHECK(!i.hasWire());
-  BOOST_CHECK_EQUAL(i.getForwardingHint(), DelegationList({{1, "/A"}, {2, "/B"}}));
-}
-
 BOOST_AUTO_TEST_CASE(GetNonce)
 {
   unique_ptr<Interest> i1, i2;