sync: improved unit tests

refs: #4264

Change-Id: I981f3d8f653e4750ee6f9d77f2c89188f11d8ebb
diff --git a/src/common.hpp b/src/common.hpp
index 0d67efc..93b3e87 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -29,6 +29,7 @@
 
 #include <ndn-cxx/common.hpp>
 #include <ndn-cxx/util/time.hpp>
+#include <ndn-cxx/name.hpp>
 
 namespace nlsr {
 
@@ -55,6 +56,8 @@
    static constexpr bool value = true;
 };
 
+using IsLsaNew = std::function<bool(const ndn::Name&, const std::string&, const uint64_t&)>;
+
 } // namespace nlsr
 
 #endif // NLSR_COMMON_HPP
diff --git a/src/communication/sync-logic-handler.hpp b/src/communication/sync-logic-handler.hpp
index b46ac7c..afa1464 100644
--- a/src/communication/sync-logic-handler.hpp
+++ b/src/communication/sync-logic-handler.hpp
@@ -94,12 +94,13 @@
   void
   createSyncSocket(const ndn::Name& syncPrefix);
 
-private:
+PUBLIC_WITH_TESTS_ELSE_PRIVATE:
   /*! \brief Simple function to glue Name components together
    */
   void
   buildUpdatePrefix();
 
+private:
   /*! \brief Determine which kind of LSA was updated and fetch it.
    *
    * Checks that the received update is not from us, which can happen,
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index 4de69ef..789edf6 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -68,23 +68,8 @@
   , m_sync(m_nlsr.getNlsrFace(),
            [this] (const ndn::Name& routerName, const std::string& lsaType,
                    const uint64_t& sequenceNumber) {
-             ndn::Name lsaKey = routerName;
-             lsaKey.append(lsaType);
-
-             if (lsaType == NameLsa::TYPE_STRING) {
-                 return isNameLsaNew(lsaKey, sequenceNumber);
-             }
-             else if (lsaType == AdjLsa::TYPE_STRING) {
-                 return isAdjLsaNew(lsaKey, sequenceNumber);
-             }
-             else if (lsaType == CoordinateLsa::TYPE_STRING) {
-                 return isCoordinateLsaNew(lsaKey, sequenceNumber);
-             }
-             else {
-               return false;
-             }
-           },
-           m_nlsr.getConfParameter())
+             return isLsaNew(routerName, lsaType, sequenceNumber);
+           }, m_nlsr.getConfParameter())
   , m_lsaRefreshTime(0)
   , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
   , m_sequencingManager()
@@ -1313,4 +1298,24 @@
   return false;
 }
 
+bool
+Lsdb::isLsaNew(const ndn::Name& routerName, const std::string& lsaType,
+               const uint64_t& sequenceNumber) {
+  ndn::Name lsaKey = routerName;
+  lsaKey.append(lsaType);
+
+  if (lsaType == NameLsa::TYPE_STRING) {
+    return isNameLsaNew(lsaKey, sequenceNumber);
+  }
+  else if (lsaType == AdjLsa::TYPE_STRING) {
+    return isAdjLsaNew(lsaKey, sequenceNumber);
+  }
+  else if (lsaType == CoordinateLsa::TYPE_STRING) {
+    return isCoordinateLsaNew(lsaKey, sequenceNumber);
+  }
+  else {
+    return false;
+  }
+}
+
 } // namespace nlsr
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 042d727..4574242 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -51,8 +51,10 @@
   }
 
   bool
-  doesLsaExist(const ndn::Name& key, const std::string& lsType);
+  isLsaNew(const ndn::Name& routerName, const std::string& lsaType, const uint64_t& sequenceNumber);
 
+  bool
+  doesLsaExist(const ndn::Name& key, const std::string& lsType);
 
   /*! \brief Builds a name LSA for this router and then installs it
       into the LSDB.