Use separate name prefix and sequence number for each LSA type

refs: #1523

Change-Id: I9db6b3a3ea9ce5e17e132d2a4e2ae9f30dd4f591
diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index 477d7a7..eae6486 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -38,7 +38,7 @@
   PublisherFixture()
     : face(std::make_shared<ndn::util::DummyClientFace>())
     , nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
-    , lsdb(nlsr, g_scheduler, nlsr.getSyncLogicHandler())
+    , lsdb(nlsr, g_scheduler)
   {
   }
 
diff --git a/tests/test-lsa-rule.cpp b/tests/test-lsa-rule.cpp
index d60d6a0..e7f6a69 100644
--- a/tests/test-lsa-rule.cpp
+++ b/tests/test-lsa-rule.cpp
@@ -174,7 +174,7 @@
   lsaInterestName.append(ndn::Name("name"));
 
   // This would be the sequence number of its own NameLsa
-  lsaInterestName.appendNumber(nlsr.getSequencingManager().getNameLsaSeq());
+  lsaInterestName.appendNumber(nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
 
   // Append version, segmentNo
   lsaInterestName.appendNumber(1).appendNumber(1);
@@ -205,7 +205,7 @@
   lsaInterestName.append(ndn::Name("name"));
 
   // This would be the sequence number of its own NameLsa
-  lsaInterestName.appendNumber(nlsr.getSequencingManager().getNameLsaSeq());
+  lsaInterestName.appendNumber(nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
 
   // Append version, segmentNo
   lsaInterestName.appendNumber(1).appendNumber(1);
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 5d1613c..abd58d4 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -41,7 +41,7 @@
   LsdbFixture()
     : face(std::make_shared<ndn::util::DummyClientFace>(g_ioService))
     , nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
-    , sync(*face, nlsr.getLsdb(), nlsr.getConfParameter(), nlsr.getSequencingManager())
+    , sync(*face, nlsr.getLsdb(), nlsr.getConfParameter())
     , lsdb(nlsr.getLsdb())
     , conf(nlsr.getConfParameter())
     , REGISTER_COMMAND_PREFIX("/localhost/nfd/rib")
@@ -243,7 +243,7 @@
   //1800 is the default life time.
   NameLsa nlsa1(ndn::Name("/router1/1"), 12, testTimePoint, npl1);
 
-  Lsdb lsdb1(nlsr, g_scheduler, nlsr.getSyncLogicHandler());
+  Lsdb lsdb1(nlsr, g_scheduler);
 
   lsdb1.installNameLsa(nlsa1);
   lsdb1.writeNameLsdbLog();
diff --git a/tests/test-nlsr.cpp b/tests/test-nlsr.cpp
index 3553a43..3760289 100644
--- a/tests/test-nlsr.cpp
+++ b/tests/test-nlsr.cpp
@@ -190,7 +190,7 @@
   BOOST_REQUIRE(lsa != nullptr);
 
   uint32_t lastAdjLsaSeqNo = lsa->getLsSeqNo();
-  nlsr.getSequencingManager().setAdjLsaSeq(lastAdjLsaSeqNo);
+  nlsr.getLsdb().getSequencingManager().setAdjLsaSeq(lastAdjLsaSeqNo);
 
   // Make sure the routing table was calculated
   RoutingTableEntry* rtEntry = nlsr.getRoutingTable().findRoutingTableEntry(failNeighbor.getName());
diff --git a/tests/test-sequencing-manager.cpp b/tests/test-sequencing-manager.cpp
index 186e7df..e05597f 100644
--- a/tests/test-sequencing-manager.cpp
+++ b/tests/test-sequencing-manager.cpp
@@ -19,40 +19,103 @@
  * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  **/
 
+#include "test-common.hpp"
 #include "sequencing-manager.hpp"
 #include <boost/test/unit_test.hpp>
+#include <boost/filesystem.hpp>
+#include <string>
+#include <iostream>
+#include <fstream>
+
+using namespace ndn;
 
 namespace nlsr {
 
 namespace test {
 
-BOOST_AUTO_TEST_SUITE(TestSequencingManager)
-
-BOOST_AUTO_TEST_CASE(SequencingManagerBasic)
+class SequencingManagerFixture : public BaseFixture
 {
-  SequencingManager sm1(120, 121, 122);
+public:
+  SequencingManagerFixture()
+  : m_seqNumbers("")
+  , m_seqManager()
+  {
+    setFileDir();
+  }
 
-  SequencingManager sm2(sm1.getCombinedSeqNo());
+  ~SequencingManagerFixture()
+  {
+    boost::filesystem::remove(seqFile);
+  }
 
-  BOOST_CHECK_EQUAL(sm2.getNameLsaSeq(), (uint32_t)120);
+  void
+  setFileDir() {
+    m_seqManager.setSeqFileDirectory("/tmp");
+  }
 
-  BOOST_CHECK_EQUAL(sm2.getAdjLsaSeq(), (uint32_t)121);
+  void
+  writeToFile(const std::string& testSeq) {
+    std::ofstream outputFile(seqFile, std::ofstream::trunc);
+    outputFile << testSeq;
+    outputFile.close();
+  }
 
-  BOOST_CHECK_EQUAL(sm2.getCorLsaSeq(), (uint32_t)122);
+  void
+  initiateFromFile(const int& type) {
+    m_seqManager.initiateSeqNoFromFile(type);
+  }
+
+  void
+  checkSeqNumbers(const uint64_t& name, const uint64_t& adj, const uint64_t& cor) {
+    BOOST_CHECK_EQUAL(m_seqManager.getNameLsaSeq(), name);
+
+    BOOST_CHECK_EQUAL(m_seqManager.getAdjLsaSeq(), adj);
+
+    BOOST_CHECK_EQUAL(m_seqManager.getCorLsaSeq(), cor);
+  }
+
+private:
+  std::string m_seqNumbers;
+  std::string seqFile = "/tmp/nlsrSeqNo.txt";
+  SequencingManager m_seqManager;
+};
+
+BOOST_FIXTURE_TEST_SUITE(TestSequencingManager, SequencingManagerFixture)
+
+BOOST_AUTO_TEST_CASE(CombinedSeqNumber)
+{
+  // LS
+  writeToFile("27121653322350672");
+
+  initiateFromFile(HYPERBOLIC_STATE_OFF);
+
+  checkSeqNumbers(24667+10, 80+10, 0);
+
+  // HR
+  writeToFile("27121653322350672");
+
+  initiateFromFile(HYPERBOLIC_STATE_ON);
+
+  // AdjLsa is set to 0 since HR is on
+  checkSeqNumbers(24667+10, 0, 0+10);
 }
 
-BOOST_AUTO_TEST_CASE(BitMask)
+BOOST_AUTO_TEST_CASE(SeparateSeqNumber)
 {
-  uint64_t nameLsaSeqNoMax = 0xFFFFFF;
-  uint64_t corLsaSeqNoMax = 0xFFFFF;
-  uint64_t adjLsaSeqNoMax = 0xFFFFF;
+  // LS
+  writeToFile("NameLsaSeq 100\nAdjLsaSeq 100\nCorLsaSeq 0");
 
-  uint64_t seqNo = (nameLsaSeqNoMax << 40) | (corLsaSeqNoMax << 20) | adjLsaSeqNoMax;
-  SequencingManager manager(seqNo);
+  initiateFromFile(HYPERBOLIC_STATE_OFF);
 
-  BOOST_CHECK_EQUAL(manager.getNameLsaSeq(), nameLsaSeqNoMax);
-  BOOST_CHECK_EQUAL(manager.getCorLsaSeq(), corLsaSeqNoMax);
-  BOOST_CHECK_EQUAL(manager.getAdjLsaSeq(), adjLsaSeqNoMax);
+  checkSeqNumbers(100+10, 100+10, 0);
+
+  // HR
+  writeToFile("NameLsa 100\nAdjLsa 0\nCorLsa 100");
+
+  initiateFromFile(HYPERBOLIC_STATE_ON);
+
+  // AdjLsa is set to 0 since HR is on
+  checkSeqNumbers(100+10, 0, 100+10);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/test-sync-logic-handler.cpp b/tests/test-sync-logic-handler.cpp
index ef990cf..ea23571 100644
--- a/tests/test-sync-logic-handler.cpp
+++ b/tests/test-sync-logic-handler.cpp
@@ -37,7 +37,7 @@
   SyncLogicFixture()
     : face(std::make_shared<ndn::util::DummyClientFace>())
     , nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
-    , sync(nlsr.getSyncLogicHandler())
+    , sync(nlsr.getLsdb().getSyncLogicHandler())
     , CONFIG_NETWORK("/ndn")
     , CONFIG_SITE("/site")
     , CONFIG_ROUTER_NAME("/%C1.Router/this-router")
@@ -72,34 +72,38 @@
   const std::string CONFIG_NETWORK;
   const std::string CONFIG_SITE;
   const std::string CONFIG_ROUTER_NAME;
+  const std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, AdjLsa::TYPE_STRING,
+                                             CoordinateLsa::TYPE_STRING};
 };
 
 BOOST_FIXTURE_TEST_SUITE(TestSyncLogicHandler, SyncLogicFixture)
 
 BOOST_AUTO_TEST_CASE(UpdateForOtherLS)
 {
-  std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
-                           CONFIG_SITE + "/%C1.Router/other-router/";
+  std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, AdjLsa::TYPE_STRING};
 
   uint64_t syncSeqNo = 1;
-  receiveUpdate(updateName, syncSeqNo, sync);
 
-  std::vector<ndn::Interest>& interests = face->sentInterests;
+  for (const std::string& lsaType : lsaTypes) {
+    std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
+                             CONFIG_SITE + "/%C1.Router/other-router/" + lsaType;
 
-  std::vector<ndn::Interest>::iterator it = interests.begin();
+    receiveUpdate(updateName, syncSeqNo, sync);
 
-  BOOST_REQUIRE_EQUAL(interests.size(), 2);
+    std::vector<ndn::Interest>& interests = face->sentInterests;
 
-  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + NameLsa::TYPE_STRING + "/");
+    std::vector<ndn::Interest>::iterator it = interests.begin();
 
-  ++it;
-  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + AdjLsa::TYPE_STRING + "/");
+    BOOST_REQUIRE_EQUAL(interests.size(), 1);
+
+    BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "/");
+  }
 }
 
 BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
 {
   Nlsr nlsr_hr(g_ioService, g_scheduler, std::ref(*face), g_keyChain);
-  SyncLogicHandler& sync_hr(nlsr_hr.getSyncLogicHandler());
+  SyncLogicHandler& sync_hr(nlsr_hr.getLsdb().getSyncLogicHandler());
 
   nlsr_hr.getConfParameter().setNetwork(CONFIG_NETWORK);
   nlsr_hr.getConfParameter().setSiteName(CONFIG_SITE);
@@ -110,30 +114,30 @@
 
   nlsr_hr.initialize();
 
-  std::string updateName = nlsr_hr.getConfParameter().getLsaPrefix().toUri() +
-                           CONFIG_SITE + "/%C1.Router/other-router/";
+  uint64_t syncSeqNo = 1;
 
-  uint64_t syncSeqNo = 0;
-  syncSeqNo = syncSeqNo | (static_cast<uint64_t>(1) << 20);
+  std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, CoordinateLsa::TYPE_STRING};
 
-  receiveUpdate(updateName, syncSeqNo, sync_hr);
+  for (const std::string& lsaType : lsaTypes) {
+    std::string updateName = nlsr_hr.getConfParameter().getLsaPrefix().toUri() +
+                           CONFIG_SITE + "/%C1.Router/other-router/" + lsaType;
 
-  std::vector<ndn::Interest>& interests = face->sentInterests;
-  std::vector<ndn::Interest>::iterator it = interests.begin();
+    receiveUpdate(updateName, syncSeqNo, sync_hr);
 
-  BOOST_REQUIRE_EQUAL(interests.size(), 2);
+    std::vector<ndn::Interest>& interests = face->sentInterests;
+    std::vector<ndn::Interest>::iterator it = interests.begin();
 
-  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + NameLsa::TYPE_STRING + "/");
+    BOOST_REQUIRE_EQUAL(interests.size(), 1);
 
-  ++it;
-  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + CoordinateLsa::TYPE_STRING + "/");
+    BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "/");
+  }
 }
 
 BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry)
 {
 
   Nlsr nlsr_hrdry(g_ioService, g_scheduler, std::ref(*face),g_keyChain);
-  SyncLogicHandler& sync_hrdry(nlsr_hrdry.getSyncLogicHandler());
+  SyncLogicHandler& sync_hrdry(nlsr_hrdry.getLsdb().getSyncLogicHandler());
 
   nlsr_hrdry.getConfParameter().setNetwork(CONFIG_NETWORK);
   nlsr_hrdry.getConfParameter().setSiteName(CONFIG_SITE);
@@ -144,56 +148,50 @@
 
   nlsr_hrdry.initialize();
 
-  std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
-                           CONFIG_SITE + "/%C1.Router/other-router/";
+  for (const std::string& lsaType : lsaTypes) {
+
+    std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
+                 CONFIG_SITE + "/%C1.Router/other-router/" + lsaType;
 
 
-  uint64_t syncSeqNo = 1;
-  syncSeqNo = syncSeqNo | (static_cast<uint64_t>(1) << 20);
-  receiveUpdate(updateName, syncSeqNo, sync_hrdry);
+    uint64_t syncSeqNo = 1;
 
-  std::vector<ndn::Interest>& interests = face->sentInterests;
-  std::vector<ndn::Interest>::iterator it = interests.begin();
+    receiveUpdate(updateName, syncSeqNo, sync_hrdry);
 
-  BOOST_REQUIRE_EQUAL(interests.size(), 3);
+    std::vector<ndn::Interest>& interests = face->sentInterests;
 
-  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + NameLsa::TYPE_STRING + "/");
+    std::vector<ndn::Interest>::iterator it = interests.begin();
 
-  if (nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
-      ++it;
-      BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + CoordinateLsa::TYPE_STRING + "/");
-  }
-  else if (nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
-      ++it;
-      BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + AdjLsa::TYPE_STRING + "/");
-  }
-  else {
-      ++it;
-      BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + CoordinateLsa::TYPE_STRING + "/");
-
-      ++it;
-      BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + AdjLsa::TYPE_STRING + "/");
+    // In HR dry-state all LSA's should be published
+    BOOST_REQUIRE_EQUAL(interests.size(), 1);
+    BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "/");
   }
 }
 
+
 BOOST_AUTO_TEST_CASE(NoUpdateForSelf)
 {
-  std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
-                           CONFIG_SITE + CONFIG_ROUTER_NAME;
+  for (const std::string& lsaType : lsaTypes) {
+    std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
+                             CONFIG_SITE + CONFIG_ROUTER_NAME + lsaType;
 
-  receiveUpdate(updateName, 1, sync);
+    receiveUpdate(updateName, 1, sync);
 
-  std::vector<ndn::Interest>& interests = face->sentInterests;
-  BOOST_CHECK_EQUAL(interests.size(), 0);
+    std::vector<ndn::Interest>& interests = face->sentInterests;
+    BOOST_CHECK_EQUAL(interests.size(), 0);
+  }
 }
 
+
 BOOST_AUTO_TEST_CASE(MalformedUpdate)
 {
-  std::string updateName = CONFIG_SITE + nlsr.getConfParameter().getLsaPrefix().toUri() +
-                           CONFIG_ROUTER_NAME;
+  for (const std::string& lsaType : lsaTypes) {
+    std::string updateName = CONFIG_SITE + nlsr.getConfParameter().getLsaPrefix().toUri() +
+                             CONFIG_ROUTER_NAME + lsaType;
 
-  std::vector<ndn::Interest>& interests = face->sentInterests;
-  BOOST_CHECK_EQUAL(interests.size(), 0);
+    std::vector<ndn::Interest>& interests = face->sentInterests;
+    BOOST_CHECK_EQUAL(interests.size(), 0);
+  }
 }
 
 BOOST_AUTO_TEST_CASE(SequenceNumber)
@@ -219,31 +217,31 @@
   lsdb.installCoordinateLsa(corLsa);
 
   std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
-                           CONFIG_SITE + "/%C1.Router/other-router/";
+                           CONFIG_SITE + "/%C1.Router/other-router/" + NameLsa::TYPE_STRING;
 
   // Lower NameLSA sequence number
-  uint64_t lowerSeqNo = static_cast<uint64_t>(998) << 40;
+  uint64_t lowerSeqNo = 998;
   receiveUpdate(updateName, lowerSeqNo, sync);
 
   std::vector<ndn::Interest>& interests = face->sentInterests;
   BOOST_REQUIRE_EQUAL(interests.size(), 0);
 
   // Same NameLSA sequence number
-  uint64_t sameSeqNo = static_cast<uint64_t>(999) << 40;
+  uint64_t sameSeqNo = 999;
   receiveUpdate(updateName, sameSeqNo, sync);
 
   interests = face->sentInterests;
   BOOST_REQUIRE_EQUAL(interests.size(), 0);
 
   // Higher NameLSA sequence number
-  uint64_t higherSeqNo = static_cast<uint64_t>(1000) << 40;
+  uint64_t higherSeqNo = 1000;
   receiveUpdate(updateName, higherSeqNo, sync);
 
   interests = face->sentInterests;
   BOOST_REQUIRE_EQUAL(interests.size(), 1);
 
   std::vector<ndn::Interest>::iterator it = interests.begin();
-  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "name/");
+  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "/");
 }
 
 BOOST_AUTO_TEST_CASE(UpdatePrefix)
@@ -254,7 +252,9 @@
 
   nlsr.initialize();
 
-  BOOST_CHECK_EQUAL(sync.m_updatePrefix, expectedPrefix);
+  BOOST_CHECK_EQUAL(sync.m_nameLsaUserPrefix, ndn::Name(expectedPrefix).append(NameLsa::TYPE_STRING));
+  BOOST_CHECK_EQUAL(sync.m_adjLsaUserPrefix, ndn::Name(expectedPrefix).append(AdjLsa::TYPE_STRING));
+  BOOST_CHECK_EQUAL(sync.m_coorLsaUserPrefix, ndn::Name(expectedPrefix).append(CoordinateLsa::TYPE_STRING));
 }
 
 BOOST_AUTO_TEST_CASE(CreateSyncSocketOnInitialization) // Bug #2649
@@ -267,7 +267,7 @@
   BOOST_REQUIRE(lsa == nullptr);
 
   // Publish a routing update before an Adjacency LSA is built
-  BOOST_CHECK_NO_THROW(sync.publishRoutingUpdate());
+  BOOST_CHECK_NO_THROW(sync.publishRoutingUpdate(AdjLsa::TYPE_STRING, 0));
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/update/test-nfd-rib-command-processor.cpp b/tests/update/test-nfd-rib-command-processor.cpp
index 3c0ae47..81b66ce 100644
--- a/tests/update/test-nfd-rib-command-processor.cpp
+++ b/tests/update/test-nfd-rib-command-processor.cpp
@@ -56,6 +56,8 @@
 
     this->advanceClocks(ndn::time::milliseconds(10));
     face.sentInterests.clear();
+
+    nameLsaSeqNoBeforeInterest = nlsr.getLsdb().getSequencingManager().getNameLsaSeq();
   }
 
   std::shared_ptr<ndn::Interest>
@@ -73,9 +75,11 @@
     // no longer does face->put(*data) in publishData.
     // Instead it does it in onInterest
     ndn::Name lsaInterestName("/localhop/ndn/NLSR/LSA");
+    lsaInterestName.append(NameLsa::TYPE_STRING);
+
     // The part after LSA is Chronosync getSession
     lsaInterestName.append(sessionTime);
-    lsaInterestName.appendNumber(nlsr.getSequencingManager().getCombinedSeqNo());
+    lsaInterestName.appendNumber(nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
     shared_ptr<ndn::Interest> lsaInterest = make_shared<ndn::Interest>(lsaInterestName);
 
     face.receive(*lsaInterest);
@@ -89,7 +93,7 @@
     const ndn::Name& lsaPrefix = nlsr.getConfParameter().getLsaPrefix();
 
     const auto& it = std::find_if(face.sentData.begin(), face.sentData.end(),
-      [lsaPrefix] (const ndn::Data& data) {
+      [&] (const ndn::Data& data) {
         return lsaPrefix.isPrefixOf(data.getName());
       });
 
@@ -104,6 +108,7 @@
   NamePrefixList& namePrefixes;
   NfdRibCommandProcessor& processor;
   ndn::Name sessionTime;
+  uint64_t nameLsaSeqNoBeforeInterest;
 };
 
 typedef boost::mpl::vector<NfdRibRegisterCommand, NfdRibUnregisterCommand> Commands;
@@ -150,6 +155,7 @@
   }
   BOOST_CHECK_EQUAL((*itr), parameters.getName());
   BOOST_CHECK(wasRoutingUpdatePublished());
+  BOOST_CHECK(nameLsaSeqNoBeforeInterest < nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
 }
 
 BOOST_AUTO_TEST_CASE(RemovePrefix)
@@ -170,6 +176,7 @@
     BOOST_FAIL("Prefix was not removed!");
   }
   BOOST_CHECK(wasRoutingUpdatePublished());
+  BOOST_CHECK(nameLsaSeqNoBeforeInterest < nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
 }
 
 BOOST_AUTO_TEST_CASE(onReceiveInterestRegisterCommand)
@@ -192,6 +199,7 @@
   }
   BOOST_CHECK_EQUAL((*itr), prefixName);
   BOOST_CHECK(wasRoutingUpdatePublished());
+  BOOST_CHECK(nameLsaSeqNoBeforeInterest < nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
 }
 
 BOOST_AUTO_TEST_CASE(onReceiveInterestUnregisterCommand)
@@ -210,6 +218,7 @@
 
   BOOST_CHECK_EQUAL(namePrefixes.getNameList().size(), 0);
   BOOST_CHECK(wasRoutingUpdatePublished());
+  BOOST_CHECK(nameLsaSeqNoBeforeInterest < nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
 }
 
 BOOST_AUTO_TEST_CASE(onReceiveInterestInvalidPrefix)
@@ -225,7 +234,10 @@
   this->advanceClocks(ndn::time::milliseconds(10));
 
   BOOST_CHECK_EQUAL(namePrefixes.getNameList().size(), 0);
-  BOOST_CHECK(!wasRoutingUpdatePublished());
+
+  // Cannot use routingUpdatePublish test now since in
+  // initialize nlsr calls buildOwnNameLsa which publishes the routing update
+  BOOST_CHECK(nameLsaSeqNoBeforeInterest == nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/update/test-prefix-update-processor.cpp b/tests/update/test-prefix-update-processor.cpp
index 169fc48..efb24a0 100644
--- a/tests/update/test-prefix-update-processor.cpp
+++ b/tests/update/test-prefix-update-processor.cpp
@@ -161,9 +161,12 @@
     // no longer does face->put(*data) in publishData.
     // Instead it does it in onInterest
     ndn::Name lsaInterestName("/localhop/ndn/NLSR/LSA");
+    lsaInterestName.append(NameLsa::TYPE_STRING);
+
     // The part after LSA is Chronosync getSession
     lsaInterestName.append(sessionTime);
-    lsaInterestName.appendNumber(nlsr.getSequencingManager().getCombinedSeqNo());
+    lsaInterestName.appendNumber(nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
+
     shared_ptr<Interest> lsaInterest = make_shared<Interest>(lsaInterestName);
 
     face.receive(*lsaInterest);
@@ -231,6 +234,7 @@
 
 BOOST_AUTO_TEST_CASE(Basic)
 {
+  uint64_t nameLsaSeqNoBeforeInterest = nlsr.getLsdb().getSequencingManager().getNameLsaSeq();
   updateProcessor.enable();
 
   // Advertise
@@ -252,8 +256,10 @@
   BOOST_CHECK_EQUAL(namePrefixList.getNameList().front(), parameters.getName());
 
   BOOST_CHECK(wasRoutingUpdatePublished());
+  BOOST_CHECK(nameLsaSeqNoBeforeInterest < nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
 
   face.sentData.clear();
+  nameLsaSeqNoBeforeInterest = nlsr.getLsdb().getSequencingManager().getNameLsaSeq();
 
   // Withdraw
   ndn::Name withdrawCommand("/localhost/nlsr/prefix-update/withdraw");
@@ -268,6 +274,7 @@
   BOOST_CHECK_EQUAL(namePrefixList.getSize(), 0);
 
   BOOST_CHECK(wasRoutingUpdatePublished());
+  BOOST_CHECK(nameLsaSeqNoBeforeInterest < nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
 }
 
 BOOST_AUTO_TEST_CASE(DisabledAndEnabled)