tests: set CanBePrefix in test suites

refs #4581

Change-Id: Ia53e2a865dbc8a422626640d8d7f3878e49066ba
diff --git a/tests/publisher/test-dataset-interest-handler.cpp b/tests/publisher/test-dataset-interest-handler.cpp
index bbb37a7..7083b82 100644
--- a/tests/publisher/test-dataset-interest-handler.cpp
+++ b/tests/publisher/test-dataset-interest-handler.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2018,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -33,11 +33,11 @@
 namespace nlsr {
 namespace test {
 
-void
+static void
 processDatasetInterest(ndn::util::DummyClientFace& face,
                        std::function<bool(const ndn::Block&)> isSameType)
 {
-  face.processEvents(ndn::time::milliseconds(30));
+  face.processEvents(30_ms);
 
   BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
 
@@ -86,22 +86,22 @@
   rt1.addNextHop(DEST_ROUTER, nh);
 
   // Request adjacency LSAs
-  face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("adjacencies")));
+  face.receive(ndn::Interest("/localhost/nlsr/lsdb/adjacencies").setCanBePrefix(true));
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::AdjacencyLsa; });
 
   // Request coordinate LSAs
-  face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("coordinates")));
+  face.receive(ndn::Interest("/localhost/nlsr/lsdb/coordinates").setCanBePrefix(true));
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::CoordinateLsa; });
 
   // Request Name LSAs
-  face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("names")));
+  face.receive(ndn::Interest("/localhost/nlsr/lsdb/names").setCanBePrefix(true));
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
 
   // Request Routing Table
-  face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/routing-table")));
+  face.receive(ndn::Interest("/localhost/nlsr/routing-table").setCanBePrefix(true));
   processDatasetInterest(face,
     [] (const ndn::Block& block) {
       return block.type() == ndn::tlv::nlsr::RoutingTable; });
@@ -138,22 +138,22 @@
   rt1.addNextHop(DEST_ROUTER, nh);
 
   // Request adjacency LSAs
-  face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/nlsr/lsdb").append("adjacencies")));
+  face.receive(ndn::Interest("/ndn/This/Router/nlsr/lsdb/adjacencies").setCanBePrefix(true));
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::AdjacencyLsa; });
 
   // Request coordinate LSAs
-  face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/nlsr/lsdb").append("coordinates")));
+  face.receive(ndn::Interest("/ndn/This/Router/nlsr/lsdb/coordinates").setCanBePrefix(true));
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::CoordinateLsa; });
 
   // Request Name LSAs
-  face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/nlsr/lsdb").append("names")));
+  face.receive(ndn::Interest("/ndn/This/Router/nlsr/lsdb/names").setCanBePrefix(true));
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
 
   // Request Routing Table
-  face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/nlsr/routing-table")));
+  face.receive(ndn::Interest("/ndn/This/Router/nlsr/routing-table").setCanBePrefix(true));
   processDatasetInterest(face,
     [] (const ndn::Block& block) {
       return block.type() == ndn::tlv::nlsr::RoutingTable; });
diff --git a/tests/update/test-advertise-crash.cpp b/tests/update/test-advertise-crash.cpp
index db9dfe6..fd760aa 100644
--- a/tests/update/test-advertise-crash.cpp
+++ b/tests/update/test-advertise-crash.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -19,9 +19,10 @@
  * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  **/
 
-#include "../test-common.hpp"
 #include "nlsr.hpp"
 
+#include "../test-common.hpp"
+
 namespace nlsr {
 namespace update {
 namespace test {
@@ -84,12 +85,12 @@
 
   // Advertise
   ndn::nfd::ControlParameters parameters;
-  parameters.setName("/prefix/to/advertise/");
+  parameters.setName("/prefix/to/advertise");
   ndn::Name advertiseCommand("/localhost/nlsr/prefix-update/advertise");
   advertiseCommand.append(parameters.wireEncode());
 
-  std::shared_ptr<ndn::Interest> advertiseInterest = std::make_shared<ndn::Interest>(advertiseCommand);
-
+  auto advertiseInterest = std::make_shared<ndn::Interest>(advertiseCommand);
+  advertiseInterest->setCanBePrefix(false);
   face.receive(*advertiseInterest);
   this->advanceClocks(ndn::time::milliseconds(10), 10);
 }
diff --git a/tests/update/test-nfd-rib-command-processor.cpp b/tests/update/test-nfd-rib-command-processor.cpp
index b6645d2..93a5f4d 100644
--- a/tests/update/test-nfd-rib-command-processor.cpp
+++ b/tests/update/test-nfd-rib-command-processor.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2018,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -20,16 +20,12 @@
  **/
 
 #include "update/nfd-rib-command-processor.hpp"
+#include "adjacency-list.hpp"
+#include "conf-parameter.hpp"
+#include "nlsr.hpp"
 
 #include "../test-common.hpp"
 #include "../control-commands.hpp"
-#include "conf-parameter.hpp"
-#include "adjacency-list.hpp"
-#include "nlsr.hpp"
-
-#include <ndn-cxx/interest.hpp>
-#include <ndn-cxx/util/dummy-client-face.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
 
 namespace nlsr {
 namespace update {
@@ -59,17 +55,18 @@
     nameLsaSeqNoBeforeInterest = nlsr.getLsdb().getSequencingManager().getNameLsaSeq();
   }
 
-  std::shared_ptr<ndn::Interest>
-  makeInterest(const ndn::Name& name, uint32_t nonce)
+  void
+  sendCommand(ndn::Name prefix, const ndn::nfd::ControlParameters& parameters)
   {
-    auto interest = std::make_shared<ndn::Interest>(name);
-    if (nonce != 0) {
-      interest->setNonce(nonce);
-    }
-    return interest;
+    ndn::Interest interest(prefix.append(parameters.wireEncode()));
+    interest.setCanBePrefix(false);
+    face.receive(interest);
+    this->advanceClocks(ndn::time::milliseconds(10), 10);
   }
 
-  void sendInterestForPublishedData() {
+  void
+  sendInterestForPublishedData()
+  {
     // Need to send an interest now since ChronoSync
     // no longer does face->put(*data) in publishData.
     // Instead it does it in onInterest
@@ -77,8 +74,8 @@
     lsaInterestName.append(std::to_string(Lsa::Type::NAME));
 
     lsaInterestName.appendNumber(nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
-    shared_ptr<ndn::Interest> lsaInterest = make_shared<ndn::Interest>(lsaInterestName);
-
+    auto lsaInterest = make_shared<ndn::Interest>(lsaInterestName);
+    lsaInterest->setCanBePrefix(true);
     face.receive(*lsaInterest);
     this->advanceClocks(ndn::time::milliseconds(10), 10);
   }
@@ -139,12 +136,9 @@
   ndn::Name name("/localhost/nlsr/rib/register");
   ndn::Name prefixName("/test/prefixA");
   ndn::nfd::ControlParameters parameters;
+  parameters.setName(prefixName);
 
-  shared_ptr<ndn::Interest> command = makeInterest(name.append(parameters.setName(prefixName)
-    .wireEncode()), 0);
-
-  face.receive(*command);
-  this->advanceClocks(ndn::time::milliseconds(10), 10);
+  sendCommand(name, parameters);
 
   BOOST_CHECK_EQUAL(namePrefixes.getNames().size(), 1);
   std::list<ndn::Name> names = namePrefixes.getNames();
@@ -162,14 +156,11 @@
   ndn::Name name("/localhost/nlsr/rib/unregister");
   ndn::Name prefixName("/test/prefixA");
   ndn::nfd::ControlParameters parameters;
+  parameters.setName(prefixName);
 
   namePrefixes.insert(prefixName);
 
-  shared_ptr<ndn::Interest> command = makeInterest(name.append(parameters.setName(prefixName)
-    .wireEncode()), 0);
-
-  face.receive(ndn::Interest(name));
-  this->advanceClocks(ndn::time::milliseconds(10), 10);
+  sendCommand(name, parameters);
 
   BOOST_CHECK_EQUAL(namePrefixes.getNames().size(), 0);
   BOOST_CHECK(wasRoutingUpdatePublished());
@@ -181,12 +172,9 @@
   ndn::Name name("/localhost/invalid/rib/register");
   ndn::Name prefixName("/test/prefixA");
   ndn::nfd::ControlParameters parameters;
+  parameters.setName(prefixName);
 
-  shared_ptr<ndn::Interest> command = makeInterest(name.append(parameters.setName(prefixName)
-    .wireEncode()), 0);
-
-  face.receive(ndn::Interest(name));
-  this->advanceClocks(ndn::time::milliseconds(10), 10);
+  sendCommand(name, parameters);
 
   BOOST_CHECK_EQUAL(namePrefixes.getNames().size(), 0);
 
diff --git a/tests/update/test-prefix-update-processor.cpp b/tests/update/test-prefix-update-processor.cpp
index c4bbaa7..4713eb3 100644
--- a/tests/update/test-prefix-update-processor.cpp
+++ b/tests/update/test-prefix-update-processor.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2018,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -20,20 +20,15 @@
  **/
 
 #include "update/prefix-update-processor.hpp"
+#include "nlsr.hpp"
 
 #include "../control-commands.hpp"
 #include "../test-common.hpp"
-#include "nlsr.hpp"
 
-#include <ndn-cxx/interest.hpp>
-#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
 #include <ndn-cxx/mgmt/nfd/control-response.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/security/command-interest-signer.hpp>
 #include <ndn-cxx/security/pib/identity.hpp>
 #include <ndn-cxx/security/signing-helpers.hpp>
-#include <ndn-cxx/security/command-interest-signer.hpp>
-#include <ndn-cxx/util/dummy-client-face.hpp>
-#include <ndn-cxx/lp/tags.hpp>
 
 #include <boost/filesystem.hpp>
 
@@ -142,8 +137,8 @@
 
     lsaInterestName.appendNumber(nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
 
-    std::shared_ptr<Interest> lsaInterest = std::make_shared<Interest>(lsaInterestName);
-
+    auto lsaInterest = std::make_shared<Interest>(lsaInterestName);
+    lsaInterest->setCanBePrefix(true);
     face.receive(*lsaInterest);
     this->advanceClocks(ndn::time::milliseconds(100));
   }
diff --git a/tests/update/test-save-delete-prefix.cpp b/tests/update/test-save-delete-prefix.cpp
index 7bbe06e..f3145e3 100644
--- a/tests/update/test-save-delete-prefix.cpp
+++ b/tests/update/test-save-delete-prefix.cpp
@@ -20,18 +20,16 @@
  **/
 
 #include "update/prefix-update-processor.hpp"
-#include "../control-commands.hpp"
-#include "../test-common.hpp"
 #include "nlsr.hpp"
 
-#include <ndn-cxx/interest.hpp>
-#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
+#include "../control-commands.hpp"
+#include "../test-common.hpp"
+
 #include <ndn-cxx/mgmt/nfd/control-response.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/security/command-interest-signer.hpp>
 #include <ndn-cxx/security/pib/identity.hpp>
 #include <ndn-cxx/security/signing-helpers.hpp>
-#include <ndn-cxx/security/command-interest-signer.hpp>
-#include <ndn-cxx/util/dummy-client-face.hpp>
+
 #include <boost/filesystem.hpp>
 
 namespace nlsr {
@@ -146,20 +144,16 @@
     }
     ndn::Name advertiseCommand("/localhost/nlsr/prefix-update/advertise");
     ndn::Name withdrawCommand("/localhost/nlsr/prefix-update/withdraw");
-    ndn:: Interest interestName;
     ndn::security::CommandInterestSigner cis(m_keyChain);
     // type true for advertise, else withdraw
     if (type == "advertise") {
       advertiseCommand.append(parameters.wireEncode());
-      interestName = cis.makeCommandInterest(advertiseCommand,
-                                             ndn::security::signingByIdentity(opIdentity));
+      return cis.makeCommandInterest(advertiseCommand, ndn::security::signingByIdentity(opIdentity));
     }
     else {
       withdrawCommand.append(parameters.wireEncode());
-      interestName = cis.makeCommandInterest(withdrawCommand,
-                                             ndn::security::signingByIdentity(opIdentity));
+      return cis.makeCommandInterest(withdrawCommand, ndn::security::signingByIdentity(opIdentity));
     }
-    return interestName;
   }
 
 public: