comm: Fix sync update prefix initialization
refs: #2399
Change-Id: I35c454e46c0b9552dba2a38b674d1ad3629f8bef
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index 5f87436..94ac76b 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -141,9 +141,6 @@
, m_confParam(conf)
, m_sequencingManager(seqManager)
{
- m_updatePrefix = m_confParam.getLsaPrefix();
- m_updatePrefix.append(m_confParam.getSiteName());
- m_updatePrefix.append(m_confParam.getRouterName());
}
void
@@ -269,6 +266,14 @@
}
void
+SyncLogicHandler::buildUpdatePrefix()
+{
+ m_updatePrefix = m_confParam.getLsaPrefix();
+ m_updatePrefix.append(m_confParam.getSiteName());
+ m_updatePrefix.append(m_confParam.getRouterName());
+}
+
+void
SyncLogicHandler::publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo)
{
_LOG_DEBUG("Publishing Sync Update. Prefix: " << updatePrefix << " Seq No: " << seqNo);
diff --git a/src/communication/sync-logic-handler.hpp b/src/communication/sync-logic-handler.hpp
index e602037..6a2c443 100644
--- a/src/communication/sync-logic-handler.hpp
+++ b/src/communication/sync-logic-handler.hpp
@@ -29,6 +29,8 @@
#include <unistd.h>
#include <boost/cstdint.hpp>
+#include "test-access-control.hpp"
+
class InterestManager;
namespace nlsr {
@@ -62,6 +64,9 @@
m_syncPrefix.set(sp);
}
+ void
+ buildUpdatePrefix();
+
private:
void
processUpdateFromSync(const SyncUpdate& updateName);
@@ -81,12 +86,15 @@
ndn::shared_ptr<Sync::SyncSocket> m_syncSocket;
ndn::Name m_syncPrefix;
+private:
Lsdb& m_lsdb;
ConfParameter& m_confParam;
const SequencingManager& m_sequencingManager;
+PUBLIC_WITH_TESTS_ELSE_PRIVATE:
ndn::Name m_updatePrefix;
+private:
static const std::string NLSR_COMPONENT;
static const std::string LSA_COMPONENT;
static const std::string NAME_COMPONENT;
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 19bb3cf..cf26a7b 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -128,7 +128,10 @@
m_fib.setEntryRefreshTime(2 * m_confParam.getLsaRefreshTime());
m_sequencingManager.setSeqFileName(m_confParam.getSeqFileDir());
m_sequencingManager.initiateSeqNoFromFile();
+
m_syncLogicHandler.setSyncPrefix(m_confParam.getChronosyncPrefix().toUri());
+ m_syncLogicHandler.buildUpdatePrefix();
+
/* Logging start */
m_confParam.writeLog();
m_adjacencyList.writeLog();
diff --git a/tests/test-sync-logic-handler.cpp b/tests/test-sync-logic-handler.cpp
index c229f35..dddbf1d 100644
--- a/tests/test-sync-logic-handler.cpp
+++ b/tests/test-sync-logic-handler.cpp
@@ -37,7 +37,7 @@
SyncLogicFixture()
: face(ndn::makeDummyFace())
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
- , sync(*face, nlsr.getLsdb(), nlsr.getConfParameter(), nlsr.getSequencingManager())
+ , sync(nlsr.getSyncLogicHandler())
, CONFIG_NETWORK("/ndn")
, CONFIG_SITE("/site")
, CONFIG_ROUTER_NAME("/%C1.Router/this-router")
@@ -67,7 +67,7 @@
public:
shared_ptr<DummyFace> face;
Nlsr nlsr;
- SyncLogicHandler sync;
+ SyncLogicHandler& sync;
const std::string CONFIG_NETWORK;
const std::string CONFIG_SITE;
@@ -166,6 +166,17 @@
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "name/");
}
+BOOST_AUTO_TEST_CASE(UpdatePrefix)
+{
+ ndn::Name expectedPrefix = nlsr.getConfParameter().getLsaPrefix();
+ expectedPrefix.append(CONFIG_SITE);
+ expectedPrefix.append(CONFIG_ROUTER_NAME);
+
+ nlsr.initialize();
+
+ BOOST_CHECK_EQUAL(sync.m_updatePrefix, expectedPrefix);
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace test