Avoid deprecated ndn-cxx functions

Change-Id: I763368c2ea12902b4ea400f92c23b17ad5a5628e
diff --git a/tests/identity-management-fixture.cpp b/tests/identity-management-fixture.cpp
index 4e6f731..b13c44a 100644
--- a/tests/identity-management-fixture.cpp
+++ b/tests/identity-management-fixture.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -128,7 +128,7 @@
   certificate.setFreshnessPeriod(time::hours(1));
 
   // set content
-  certificate.setContent(key.getPublicKey().data(), key.getPublicKey().size());
+  certificate.setContent(key.getPublicKey());
 
   // set signature-info
   ndn::SignatureInfo info;
diff --git a/tests/route/test-nexthop.cpp b/tests/route/test-nexthop.cpp
index a11c221..3ba3539 100644
--- a/tests/route/test-nexthop.cpp
+++ b/tests/route/test-nexthop.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -26,13 +26,13 @@
 
 BOOST_AUTO_TEST_SUITE(TestNexthop)
 
-double
+static double
 getHyperbolicAdjustedDecimal(unsigned int i)
 {
   return static_cast<double>(i)/(10*NextHop::HYPERBOLIC_COST_ADJUSTMENT_FACTOR);
 }
 
-uint64_t
+static uint64_t
 applyHyperbolicFactorAndRound(double d)
 {
   return round(NextHop::HYPERBOLIC_COST_ADJUSTMENT_FACTOR*d);
@@ -117,17 +117,13 @@
   nexthops1.setConnectingFaceUri("/test/nexthop/tlv");
   nexthops1.setRouteCost(1.65);
 
-  const ndn::Block& wire = nexthops1.wireEncode();
-  BOOST_REQUIRE_EQUAL_COLLECTIONS(NexthopData,
-                                  NexthopData + sizeof(NexthopData),
-                                  wire.begin(), wire.end());
+  BOOST_TEST(nexthops1.wireEncode() == NexthopData, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(NexthopDecode)
 {
   NextHop nexthops1;
-
-  nexthops1.wireDecode(ndn::Block(NexthopData, sizeof(NexthopData)));
+  nexthops1.wireDecode(ndn::Block{NexthopData});
 
   BOOST_REQUIRE_EQUAL(nexthops1.getConnectingFaceUri(), "/test/nexthop/tlv");
   BOOST_REQUIRE_EQUAL(nexthops1.getRouteCost(), 1.65);
diff --git a/tests/route/test-routing-table-entry.cpp b/tests/route/test-routing-table-entry.cpp
index c17b981..ef470e1 100644
--- a/tests/route/test-routing-table-entry.cpp
+++ b/tests/route/test-routing-table-entry.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -69,18 +69,13 @@
   nexthops2.setRouteCost(1.65);
   rte.getNexthopList().addNextHop(nexthops2);
 
-  const ndn::Block& wire = rte.wireEncode();
-
-  BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithNexthopsData,
-                                  RoutingTableEntryWithNexthopsData +
-                                    sizeof(RoutingTableEntryWithNexthopsData),
-                                  wire.begin(), wire.end());
+  BOOST_TEST(rte.wireEncode() == RoutingTableEntryWithNexthopsData,
+             boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithNexthops)
 {
-  RoutingTableEntry rte(ndn::Block(RoutingTableEntryWithNexthopsData,
-                                   sizeof(RoutingTableEntryWithNexthopsData)));
+  RoutingTableEntry rte(ndn::Block{RoutingTableEntryWithNexthopsData});
   BOOST_CHECK_EQUAL(rte.getDestination(), "dest1");
 
   BOOST_CHECK(rte.getNexthopList().size() != 0);
@@ -96,25 +91,17 @@
 BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithoutNexthops)
 {
   RoutingTableEntry rte(ndn::Name("dest1"));
-
-  auto wire = rte.wireEncode();
-
-  BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithoutNexthopsData,
-                                  RoutingTableEntryWithoutNexthopsData +
-                                    sizeof(RoutingTableEntryWithoutNexthopsData),
-                                  wire.begin(), wire.end());
+  BOOST_TEST(rte.wireEncode() == RoutingTableEntryWithoutNexthopsData,
+             boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithoutNexthops)
 {
-  RoutingTableEntry rte(ndn::Block(RoutingTableEntryWithoutNexthopsData,
-                                   sizeof(RoutingTableEntryWithoutNexthopsData)));
-
+  RoutingTableEntry rte(ndn::Block{RoutingTableEntryWithoutNexthopsData});
   BOOST_CHECK_EQUAL(rte.getDestination(), "dest1");
-  BOOST_CHECK(rte.getNexthopList().size() == 0);
+  BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 0);
 }
 
-
 BOOST_AUTO_TEST_CASE(RoutingTableEntryClear)
 {
   RoutingTableEntry rte(ndn::Name("dest1"));
diff --git a/tests/route/test-routing-table.cpp b/tests/route/test-routing-table.cpp
index 6a2971e..5624ad8 100644
--- a/tests/route/test-routing-table.cpp
+++ b/tests/route/test-routing-table.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -102,7 +102,7 @@
 
 BOOST_FIXTURE_TEST_CASE(RoutingTableDecode1, RoutingTableFixture)
 {
-  RoutingTableStatus rtStatus(ndn::Block(RoutingTableData1, sizeof(RoutingTableData1)));
+  RoutingTableStatus rtStatus(ndn::Block{RoutingTableData1});
 
   auto it1 = rtStatus.m_rTable.begin();
 
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
index 0f18dd7..2a1e607 100644
--- a/tests/test-common.hpp
+++ b/tests/test-common.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -24,10 +24,10 @@
 
 #include "common.hpp"
 #include "conf-parameter.hpp"
-#include "identity-management-fixture.hpp"
+#include "route/fib.hpp"
 
 #include "boost-test.hpp"
-#include "route/fib.hpp"
+#include "identity-management-fixture.hpp"
 
 #include <boost/asio.hpp>
 
@@ -132,7 +132,7 @@
     payload2.wireEncode(buffer);
     payload1.wireEncode(buffer);
 
-    this->sendDatasetReply(prefix, buffer.buf(), buffer.size());
+    this->sendDatasetReply(prefix, buffer);
   }
 
   /** \brief send a payload in reply to StatusDataset request
@@ -186,7 +186,6 @@
     conf.setSiteName(siteName);
     conf.setRouterName(routerName);
     conf.buildRouterAndSyncUserPrefix();
-
     conf.setSyncProtocol(protocol);
     conf.setHyperbolicState(hyperbolicState);
   }
diff --git a/tests/test-hello-protocol.cpp b/tests/test-hello-protocol.cpp
index 08adc02..efd8eac 100644
--- a/tests/test-hello-protocol.cpp
+++ b/tests/test-hello-protocol.cpp
@@ -129,10 +129,10 @@
                 Adjacent::STATUS_INACTIVE, 0, 300);
   adjList.insert(adj1);
 
-  ndn::Name dataName = adj1.getName() ;
-  dataName.append(nlsr::HelloProtocol::NLSR_COMPONENT);
-  dataName.append(nlsr::HelloProtocol::INFO_COMPONENT);
-  dataName.append(conf.getRouterPrefix().wireEncode());
+  ndn::Name dataName = adj1.getName();
+  dataName.append(HelloProtocol::NLSR_COMPONENT);
+  dataName.append(HelloProtocol::INFO_COMPONENT);
+  dataName.append(ndn::tlv::GenericNameComponent, conf.getRouterPrefix().wireEncode());
 
   ndn::Data data(ndn::Name(dataName).appendVersion());
   BOOST_CHECK_EQUAL(numOnInitialHelloDataValidates, 0);
diff --git a/tests/test-lsa.cpp b/tests/test-lsa.cpp
index ebb6c4e..d89fef6 100644
--- a/tests/test-lsa.cpp
+++ b/tests/test-lsa.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -31,10 +31,11 @@
 namespace nlsr {
 namespace test {
 
-/*static void
-printBytes(const uint8_t* buf, size_t size)
+/*
+static void
+printBytes(ndn::span<const uint8_t> buf)
 {
-  std::string hex = ndn::toHex(buf, size);
+  std::string hex = ndn::toHex(buf);
 
   for (size_t i = 0; i < hex.size(); i++) {
     if (i > 0 && i % 30 == 0)
@@ -49,7 +50,8 @@
   std::cout << "\n" << "};" << std::endl;
 }
 
-printBytes(wire.wire(), wire.size());*/
+printBytes(block);
+*/
 
 BOOST_AUTO_TEST_SUITE(TestLsa)
 
@@ -90,8 +92,7 @@
   ndn::Name s2{"name2"};
   NamePrefixList npl1{s1, s2};
 
-  ndn::time::system_clock::TimePoint testTimePoint =
-    ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
+  auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
 
   // 3rd argument is seqNo
   NameLsa nlsa1("router1", 12, testTimePoint, npl1);
@@ -172,8 +173,7 @@
 {
   ndn::Name routerName("/ndn/site/router");
   ndn::Name adjacencyName("/ndn/site/adjacency");
-  ndn::time::system_clock::TimePoint testTimePoint =
-    ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
+  auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
   uint32_t seqNo = 12;
 
   // An AdjLsa initialized with ACTIVE adjacencies should copy the adjacencies
@@ -272,9 +272,8 @@
 
 BOOST_AUTO_TEST_CASE(CoordinateLsaBasic)
 {
-  ndn::time::system_clock::TimePoint testTimePoint =
-    ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
-  std::vector<double> angles1 {30.0}, angles2 {30.0};
+  auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
+  std::vector<double> angles1{30.0}, angles2{30.0};
   angles1.push_back(30.0);
   angles2.push_back(30.0);
   CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles1);
@@ -369,7 +368,7 @@
   adjList.insert(adj1);
   adjList.insert(adj2);
 
-  ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
+  auto testTimePoint = ndn::time::system_clock::now();
 
   AdjLsa adjlsa1("router1", 1, testTimePoint, adjList.size(), adjList);
   AdjLsa adjlsa2(adjlsa1.wireEncode());
diff --git a/tests/test-nlsr.cpp b/tests/test-nlsr.cpp
index cd4d0d2..43c5baf 100644
--- a/tests/test-nlsr.cpp
+++ b/tests/test-nlsr.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -48,10 +48,12 @@
   receiveHelloData(const ndn::Name& sender, const ndn::Name& receiver)
   {
     ndn::Name dataName(sender);
-    dataName.append("NLSR").append("INFO").append(receiver.wireEncode()).appendVersion();
+    dataName.append("NLSR")
+            .append("INFO")
+            .append(ndn::tlv::GenericNameComponent, receiver.wireEncode())
+            .appendVersion();
 
     ndn::Data data(dataName);
-
     nlsr.m_helloProtocol.onContentValidated(data);
   }
 
diff --git a/tests/test-statistics.cpp b/tests/test-statistics.cpp
index 2c02bb7..4a5dc5b 100644
--- a/tests/test-statistics.cpp
+++ b/tests/test-statistics.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -20,11 +20,12 @@
  */
 
 #include "statistics.hpp"
-#include "test-common.hpp"
 #include "hello-protocol.hpp"
 #include "lsdb.hpp"
 #include "nlsr.hpp"
 
+#include "test-common.hpp"
+
 #include <ndn-cxx/util/dummy-client-face.hpp>
 #include <boost/lexical_cast.hpp>
 
@@ -158,7 +159,7 @@
   ndn::Name otherName(other.getName());
   otherName.append("NLSR");
   otherName.append("INFO");
-  otherName.append(conf.getRouterPrefix().wireEncode());
+  otherName.append(ndn::tlv::GenericNameComponent, conf.getRouterPrefix().wireEncode());
 
   hello.expressInterest(otherName, 1);
   this->advanceClocks(ndn::time::milliseconds(1), 10);
@@ -168,7 +169,7 @@
   ndn::Name thisName(conf.getRouterPrefix());
   thisName.append("NLSR");
   thisName.append("INFO");
-  thisName.append(other.getName().wireEncode());
+  thisName.append(ndn::tlv::GenericNameComponent, other.getName().wireEncode());
 
   ndn::Interest interest(thisName);
   hello.processInterest(ndn::Name(), interest);
diff --git a/tests/update/test-advertise-crash.cpp b/tests/update/test-advertise-crash.cpp
index 09a27d7..8925469 100644
--- a/tests/update/test-advertise-crash.cpp
+++ b/tests/update/test-advertise-crash.cpp
@@ -83,7 +83,7 @@
   ndn::nfd::ControlParameters parameters;
   parameters.setName("/prefix/to/advertise");
   ndn::Name advertiseCommand("/localhost/nlsr/prefix-update/advertise");
-  advertiseCommand.append(parameters.wireEncode());
+  advertiseCommand.append(ndn::tlv::GenericNameComponent, parameters.wireEncode());
 
   auto advertiseInterest = std::make_shared<ndn::Interest>(advertiseCommand);
   face.receive(*advertiseInterest);
diff --git a/tests/update/test-nfd-rib-command-processor.cpp b/tests/update/test-nfd-rib-command-processor.cpp
index cc23dd0..c9be622 100644
--- a/tests/update/test-nfd-rib-command-processor.cpp
+++ b/tests/update/test-nfd-rib-command-processor.cpp
@@ -54,7 +54,7 @@
   void
   sendCommand(ndn::Name prefix, const ndn::nfd::ControlParameters& parameters)
   {
-    ndn::Interest interest(prefix.append(parameters.wireEncode()));
+    ndn::Interest interest(prefix.append(ndn::tlv::GenericNameComponent, parameters.wireEncode()));
     face.receive(interest);
     this->advanceClocks(ndn::time::milliseconds(10), 10);
   }
diff --git a/tests/update/test-prefix-update-processor.cpp b/tests/update/test-prefix-update-processor.cpp
index 9c20114..ac50943 100644
--- a/tests/update/test-prefix-update-processor.cpp
+++ b/tests/update/test-prefix-update-processor.cpp
@@ -161,7 +161,7 @@
   ndn::Name advertiseCommand("/localhost/nlsr/prefix-update/advertise");
 
   // append /<control-parameters>
-  advertiseCommand.append(parameters.wireEncode());
+  advertiseCommand.append(ndn::tlv::GenericNameComponent, parameters.wireEncode());
 
   ndn::security::InterestSigner signer(m_keyChain);
 
@@ -186,7 +186,7 @@
 
   // Withdraw
   ndn::Name withdrawCommand("/localhost/nlsr/prefix-update/withdraw");
-  withdrawCommand.append(parameters.wireEncode());
+  withdrawCommand.append(ndn::tlv::GenericNameComponent, parameters.wireEncode());
 
   auto withdrawInterest= signer.makeCommandInterest(withdrawCommand,
                                                     ndn::security::signingByIdentity(opIdentity));
diff --git a/tests/update/test-save-delete-prefix.cpp b/tests/update/test-save-delete-prefix.cpp
index 9843489..c4db1bc 100644
--- a/tests/update/test-save-delete-prefix.cpp
+++ b/tests/update/test-save-delete-prefix.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -144,11 +144,11 @@
     ndn::security::InterestSigner signer(m_keyChain);
     // type true for advertise, else withdraw
     if (type == "advertise") {
-      advertiseCommand.append(parameters.wireEncode());
+      advertiseCommand.append(ndn::tlv::GenericNameComponent, parameters.wireEncode());
       return signer.makeCommandInterest(advertiseCommand, ndn::security::signingByIdentity(opIdentity));
     }
     else {
-      withdrawCommand.append(parameters.wireEncode());
+      withdrawCommand.append(ndn::tlv::GenericNameComponent, parameters.wireEncode());
       return signer.makeCommandInterest(withdrawCommand, ndn::security::signingByIdentity(opIdentity));
     }
   }