communication: refactor SyncLogicHandler to not need a ConfParameter reference
refs #4208
Change-Id: I5194c0a775dc1581af3a6ebd2db3699892671fb4
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index cd9e17a..8193a60 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, The University of Memphis,
+ * Copyright (c) 2014-2024, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -24,8 +24,6 @@
#include "logger.hpp"
#include "utility/name-helper.hpp"
-#include <boost/lexical_cast.hpp>
-
namespace nlsr {
INIT_LOGGER(SyncLogicHandler);
@@ -33,24 +31,22 @@
const std::string LSA_COMPONENT{"LSA"};
SyncLogicHandler::SyncLogicHandler(ndn::Face& face, ndn::KeyChain& keyChain,
- IsLsaNew isLsaNew, const ConfParameter& conf)
+ IsLsaNew isLsaNew, const SyncLogicOptions& opts)
: m_isLsaNew(std::move(isLsaNew))
- , m_confParam(conf)
- , m_nameLsaUserPrefix(ndn::Name(m_confParam.getSyncUserPrefix()).append(boost::lexical_cast<std::string>(Lsa::Type::NAME)))
- , m_syncLogic(face, keyChain, m_confParam.getSyncProtocol(), m_confParam.getSyncPrefix(),
- m_nameLsaUserPrefix, m_confParam.getSyncInterestLifetime(),
+ , m_routerPrefix(opts.routerPrefix)
+ , m_hyperbolicState(opts.hyperbolicState)
+ , m_nameLsaUserPrefix(makeLsaUserPrefix(opts.userPrefix, Lsa::Type::NAME))
+ , m_adjLsaUserPrefix(makeLsaUserPrefix(opts.userPrefix, Lsa::Type::ADJACENCY))
+ , m_coorLsaUserPrefix(makeLsaUserPrefix(opts.userPrefix, Lsa::Type::COORDINATE))
+ , m_syncLogic(face, keyChain, opts.syncProtocol, opts.syncPrefix,
+ m_nameLsaUserPrefix, opts.syncInterestLifetime,
std::bind(&SyncLogicHandler::processUpdate, this, _1, _2, _3))
{
- m_adjLsaUserPrefix = ndn::Name(m_confParam.getSyncUserPrefix())
- .append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
- m_coorLsaUserPrefix = ndn::Name(m_confParam.getSyncUserPrefix())
- .append(boost::lexical_cast<std::string>(Lsa::Type::COORDINATE));
-
- if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_ON) {
+ if (m_hyperbolicState != HYPERBOLIC_STATE_ON) {
m_syncLogic.addUserNode(m_adjLsaUserPrefix);
}
- if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
+ if (m_hyperbolicState != HYPERBOLIC_STATE_OFF) {
m_syncLogic.addUserNode(m_coorLsaUserPrefix);
}
}
@@ -83,37 +79,36 @@
{
NLSR_LOG_DEBUG("Origin Router of update: " << originRouter);
- // A router should not try to fetch its own LSA
- if (originRouter != m_confParam.getRouterPrefix()) {
+ if (originRouter == m_routerPrefix) {
+ // A router should not try to fetch its own LSA
+ return;
+ }
- Lsa::Type lsaType;
- std::istringstream(updateName.get(updateName.size()-1).toUri()) >> lsaType;
+ auto lsaType = boost::lexical_cast<Lsa::Type>(updateName.get(-1).toUri());
+ NLSR_LOG_DEBUG("Received sync update with higher " << lsaType <<
+ " sequence number than entry in LSDB");
- NLSR_LOG_DEBUG("Received sync update with higher " << lsaType <<
- " sequence number than entry in LSDB");
-
- if (m_isLsaNew(originRouter, lsaType, seqNo, incomingFaceId)) {
- if (lsaType == Lsa::Type::ADJACENCY && seqNo != 0 &&
- m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
- NLSR_LOG_ERROR("Got an update for adjacency LSA when hyperbolic routing " <<
- "is enabled. Not going to fetch.");
- return;
- }
-
- if (lsaType == Lsa::Type::COORDINATE && seqNo != 0 &&
- m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
- NLSR_LOG_ERROR("Got an update for coordinate LSA when link-state " <<
- "is enabled. Not going to fetch.");
- return;
- }
-
- onNewLsa(updateName, seqNo, originRouter, incomingFaceId);
+ if (m_isLsaNew(originRouter, lsaType, seqNo, incomingFaceId)) {
+ if (lsaType == Lsa::Type::ADJACENCY && seqNo != 0 &&
+ m_hyperbolicState == HYPERBOLIC_STATE_ON) {
+ NLSR_LOG_ERROR("Got an update for adjacency LSA when hyperbolic routing "
+ "is enabled. Not going to fetch.");
+ return;
}
+
+ if (lsaType == Lsa::Type::COORDINATE && seqNo != 0 &&
+ m_hyperbolicState == HYPERBOLIC_STATE_OFF) {
+ NLSR_LOG_ERROR("Got an update for coordinate LSA when link-state "
+ "is enabled. Not going to fetch.");
+ return;
+ }
+
+ onNewLsa(updateName, seqNo, originRouter, incomingFaceId);
}
}
void
-SyncLogicHandler::publishRoutingUpdate(const Lsa::Type& type, const uint64_t& seqNo)
+SyncLogicHandler::publishRoutingUpdate(Lsa::Type type, uint64_t seqNo)
{
switch (type) {
case Lsa::Type::ADJACENCY:
diff --git a/src/communication/sync-logic-handler.hpp b/src/communication/sync-logic-handler.hpp
index 6eee213..3782663 100644
--- a/src/communication/sync-logic-handler.hpp
+++ b/src/communication/sync-logic-handler.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, The University of Memphis,
+ * Copyright (c) 2014-2024, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -28,14 +28,30 @@
#include "sync-protocol-adapter.hpp"
#include "test-access-control.hpp"
+#include <boost/lexical_cast.hpp>
+
namespace nlsr {
-/*! \brief NLSR-to-ChronoSync interaction point
+struct SyncLogicOptions
+{
+ SyncProtocol syncProtocol;
+ ndn::Name syncPrefix;
+ ndn::Name userPrefix;
+ ndn::time::milliseconds syncInterestLifetime;
+ ndn::Name routerPrefix;
+ HyperbolicState hyperbolicState;
+};
+
+inline ndn::Name
+makeLsaUserPrefix(const ndn::Name& userPrefix, Lsa::Type lsaType)
+{
+ return ndn::Name(userPrefix).append(boost::lexical_cast<std::string>(lsaType));
+}
+
+/*! \brief NLSR-to-sync interaction point
*
* This class serves as the abstraction for the syncing portion of
- * NLSR and its components. NLSR has no particular reliance on
- * ChronoSync, except that the NLSR source would need to be modified
- * for use with other sync protocols.
+ * NLSR and its components.
*/
class SyncLogicHandler
{
@@ -46,11 +62,12 @@
using std::runtime_error::runtime_error;
};
- using IsLsaNew =
- std::function<bool(const ndn::Name&, const Lsa::Type& lsaType, const uint64_t&, uint64_t/*inFace*/)>;
+ using IsLsaNew = std::function<
+ bool (const ndn::Name& routerName, Lsa::Type lsaType, uint64_t seqNo, uint64_t inFace)
+ >;
SyncLogicHandler(ndn::Face& face, ndn::KeyChain& keyChain,
- IsLsaNew isLsaNew, const ConfParameter& conf);
+ IsLsaNew isLsaNew, const SyncLogicOptions& opts);
/*! \brief Instruct ChronoSync to publish an update.
*
@@ -62,7 +79,7 @@
* \sa publishSyncUpdate
*/
void
- publishRoutingUpdate(const Lsa::Type& type, const uint64_t& seqNo);
+ publishRoutingUpdate(Lsa::Type type, uint64_t seqNo);
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
/*! \brief Callback from Sync protocol
@@ -91,7 +108,8 @@
private:
IsLsaNew m_isLsaNew;
- const ConfParameter& m_confParam;
+ ndn::Name m_routerPrefix;
+ HyperbolicState m_hyperbolicState;
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
ndn::Name m_nameLsaUserPrefix;
diff --git a/src/conf-parameter.hpp b/src/conf-parameter.hpp
index 687aa1c..40eb7dd 100644
--- a/src/conf-parameter.hpp
+++ b/src/conf-parameter.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, The University of Memphis,
+ * Copyright (c) 2014-2024, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -340,12 +340,12 @@
}
void
- setHyperbolicState(int32_t ihc)
+ setHyperbolicState(HyperbolicState ihc)
{
m_hyperbolicState = ihc;
}
- int32_t
+ HyperbolicState
getHyperbolicState() const
{
return m_hyperbolicState;
@@ -517,7 +517,7 @@
uint32_t m_infoInterestInterval;
- int32_t m_hyperbolicState;
+ HyperbolicState m_hyperbolicState;
double m_corR;
std::vector<double> m_corTheta;
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index 608b575..844de22 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -36,10 +36,17 @@
, m_scheduler(face.getIoContext())
, m_confParam(confParam)
, m_sync(m_face, keyChain,
- [this] (const auto& routerName, const Lsa::Type& lsaType,
- uint64_t sequenceNumber, uint64_t incomingFaceId) {
- return isLsaNew(routerName, lsaType, sequenceNumber);
- }, m_confParam)
+ [this] (const auto& routerName, Lsa::Type lsaType, uint64_t seqNo, uint64_t) {
+ return isLsaNew(routerName, lsaType, seqNo);
+ },
+ SyncLogicOptions{
+ confParam.getSyncProtocol(),
+ confParam.getSyncPrefix(),
+ confParam.getSyncUserPrefix(),
+ confParam.getSyncInterestLifetime(),
+ confParam.getRouterPrefix(),
+ confParam.getHyperbolicState()
+ })
, m_lsaRefreshTime(ndn::time::seconds(m_confParam.getLsaRefreshTime()))
, m_adjLsaBuildInterval(m_confParam.getAdjLsaBuildInterval())
, m_thisRouterPrefix(m_confParam.getRouterPrefix())
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 1116e98..93e1ad9 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, The University of Memphis,
+ * Copyright (c) 2014-2024, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -220,7 +220,7 @@
\param seqNo The sequence number to check.
*/
bool
- isLsaNew(const ndn::Name& originRouter, const Lsa::Type& lsaType, uint64_t seqNo) const
+ isLsaNew(const ndn::Name& originRouter, Lsa::Type lsaType, uint64_t seqNo) const
{
// Is the name in the LSDB and the supplied seq no is the highest so far
auto lsaPtr = findLsa(originRouter, lsaType);
diff --git a/tests/communication/test-sync-logic-handler.cpp b/tests/communication/test-sync-logic-handler.cpp
index c259bfc..4f759e0 100644
--- a/tests/communication/test-sync-logic-handler.cpp
+++ b/tests/communication/test-sync-logic-handler.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, The University of Memphis,
+ * Copyright (c) 2014-2024, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -25,47 +25,57 @@
#include "tests/io-key-chain-fixture.hpp"
#include "tests/test-common.hpp"
-#include <boost/lexical_cast.hpp>
-
-namespace nlsr {
-namespace test {
+namespace nlsr::test {
class SyncLogicFixture : public IoKeyChainFixture
{
public:
SyncLogicFixture()
- : testIsLsaNew([] (auto&&...) { return true; })
- , updateNamePrefix(this->conf.getLsaPrefix().toUri() +
- this->conf.getSiteName().toUri() +
- "/%C1.Router/other-router/")
{
- m_keyChain.createIdentity(conf.getRouterPrefix());
+ m_keyChain.createIdentity(opts.routerPrefix);
+ }
+
+ SyncLogicHandler&
+ getSync()
+ {
+ if (m_sync == nullptr) {
+ m_sync.reset(new SyncLogicHandler(face, m_keyChain, testIsLsaNew, opts));
+ }
+ return *m_sync;
}
void
- receiveUpdate(const std::string& prefix, uint64_t seqNo)
+ receiveUpdate(const ndn::Name& prefix, uint64_t seqNo)
{
this->advanceClocks(ndn::time::milliseconds(1), 10);
face.sentInterests.clear();
std::vector<psync::MissingDataInfo> updates;
- updates.push_back({ndn::Name(prefix), 0, seqNo, 0});
- sync.m_syncLogic.onPSyncUpdate(updates);
+ updates.push_back({prefix, 0, seqNo, 0});
+ getSync().m_syncLogic.onPSyncUpdate(updates);
this->advanceClocks(ndn::time::milliseconds(1), 10);
}
public:
ndn::DummyClientFace face{m_io, m_keyChain};
- ConfParameter conf{face, m_keyChain};
- DummyConfFileProcessor confProcessor{conf, SyncProtocol::PSYNC};
- SyncLogicHandler::IsLsaNew testIsLsaNew;
- SyncLogicHandler sync{face, m_keyChain, testIsLsaNew, conf};
+ SyncLogicHandler::IsLsaNew testIsLsaNew = [] (auto&&...) { return true; };
+ SyncLogicOptions opts{
+ SyncProtocol::PSYNC,
+ ndn::Name("/ndn/nlsr/sync").appendVersion(ConfParameter::SYNC_VERSION),
+ "/localhop/ndn/nlsr/LSA/site/%C1.Router/this-router",
+ ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT),
+ "/ndn/site/%C1.Router/this-router",
+ HYPERBOLIC_STATE_OFF
+ };
- const std::string updateNamePrefix;
+ ndn::Name otherRouter = "/localhop/ndn/nlsr/LSA/site/%C1.Router/other-router";
const std::vector<Lsa::Type> lsaTypes{Lsa::Type::NAME,
Lsa::Type::ADJACENCY,
Lsa::Type::COORDINATE};
+
+private:
+ std::unique_ptr<SyncLogicHandler> m_sync;
};
BOOST_FIXTURE_TEST_SUITE(TestSyncLogicHandler, SyncLogicFixture)
@@ -80,11 +90,11 @@
uint64_t syncSeqNo = 1;
for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::ADJACENCY}) {
- std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
+ auto updateName = makeLsaUserPrefix(otherRouter, lsaType);
- ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
+ ndn::signal::ScopedConnection connection = getSync().onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
- BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
+ BOOST_CHECK_EQUAL(updateName, routerName);
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
++nCallbacks;
});
@@ -101,17 +111,17 @@
*/
BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
{
- this->conf.setHyperbolicState(HYPERBOLIC_STATE_ON);
+ opts.hyperbolicState = HYPERBOLIC_STATE_ON;
size_t nCallbacks = 0;
uint64_t syncSeqNo = 1;
for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::COORDINATE}) {
- std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
+ auto updateName = makeLsaUserPrefix(otherRouter, lsaType);
- ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
+ ndn::signal::ScopedConnection connection = getSync().onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
- BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
+ BOOST_CHECK_EQUAL(updateName, routerName);
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
++nCallbacks;
});
@@ -128,17 +138,17 @@
*/
BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry)
{
- this->conf.setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
+ opts.hyperbolicState = HYPERBOLIC_STATE_DRY_RUN;
size_t nCallbacks = 0;
uint64_t syncSeqNo = 1;
for (auto lsaType : this->lsaTypes) {
- std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
+ auto updateName = makeLsaUserPrefix(otherRouter, lsaType);
- ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
+ ndn::signal::ScopedConnection connection = getSync().onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
- BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
+ BOOST_CHECK_EQUAL(updateName, routerName);
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
++nCallbacks;
});
@@ -158,19 +168,14 @@
const uint64_t sequenceNumber = 1;
for (auto lsaType : this->lsaTypes) {
- // To ensure that we get correctly-separated components, create
- // and modify a Name to hand off.
- ndn::Name updateName{this->conf.getLsaPrefix()};
- updateName.append(this->conf.getSiteName())
- .append(this->conf.getRouterName())
- .append(boost::lexical_cast<std::string>(lsaType));
+ auto updateName = makeLsaUserPrefix(opts.routerPrefix, lsaType);
- ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
+ ndn::signal::ScopedConnection connection = getSync().onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
BOOST_FAIL("Updates for self should not be emitted!");
});
- this->receiveUpdate(updateName.toUri(), sequenceNumber);
+ this->receiveUpdate(updateName, sequenceNumber);
}
// avoid "test case [...] did not check any assertions" message from Boost.Test
@@ -186,15 +191,14 @@
const uint64_t sequenceNumber = 1;
for (auto lsaType : this->lsaTypes) {
- ndn::Name updateName{this->conf.getSiteName()};
- updateName.append(this->conf.getRouterName()).append(boost::lexical_cast<std::string>(lsaType));
+ auto updateName = makeLsaUserPrefix("/site/%C1.Router/this-router", lsaType);
- ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
+ ndn::signal::ScopedConnection connection = getSync().onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
BOOST_FAIL("Malformed updates should not be emitted!");
});
- this->receiveUpdate(updateName.toUri(), sequenceNumber);
+ this->receiveUpdate(updateName, sequenceNumber);
}
// avoid "test case [...] did not check any assertions" message from Boost.Test
@@ -207,19 +211,18 @@
*/
BOOST_AUTO_TEST_CASE(LsaNotNew)
{
- auto testLsaAlwaysFalse = [] (const ndn::Name& routerName, const Lsa::Type& lsaType,
- const uint64_t& sequenceNumber, uint64_t incomingFaceId) {
+ testIsLsaNew = [] (const ndn::Name& routerName, const Lsa::Type& lsaType,
+ const uint64_t& sequenceNumber, uint64_t incomingFaceId) {
return false;
};
const uint64_t sequenceNumber = 1;
- SyncLogicHandler sync{this->face, this->m_keyChain, testLsaAlwaysFalse, this->conf};
- ndn::signal::ScopedConnection connection = sync.onNewLsa.connect(
+ ndn::signal::ScopedConnection connection = getSync().onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
BOOST_FAIL("An update for an LSA with non-new sequence number should not emit!");
});
- std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(Lsa::Type::NAME);
+ auto updateName = makeLsaUserPrefix(otherRouter, Lsa::Type::NAME);
this->receiveUpdate(updateName, sequenceNumber);
// avoid "test case [...] did not check any assertions" message from Boost.Test
@@ -232,19 +235,14 @@
*/
BOOST_AUTO_TEST_CASE(UpdatePrefix)
{
- ndn::Name expectedPrefix = this->conf.getLsaPrefix();
- expectedPrefix.append(this->conf.getSiteName());
- expectedPrefix.append(this->conf.getRouterName());
-
- BOOST_CHECK_EQUAL(this->sync.m_nameLsaUserPrefix,
- ndn::Name(expectedPrefix).append(boost::lexical_cast<std::string>(Lsa::Type::NAME)));
- BOOST_CHECK_EQUAL(this->sync.m_adjLsaUserPrefix,
- ndn::Name(expectedPrefix).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY)));
- BOOST_CHECK_EQUAL(this->sync.m_coorLsaUserPrefix,
- ndn::Name(expectedPrefix).append(boost::lexical_cast<std::string>(Lsa::Type::COORDINATE)));
+ BOOST_CHECK_EQUAL(getSync().m_nameLsaUserPrefix,
+ ndn::Name(opts.userPrefix).append(boost::lexical_cast<std::string>(Lsa::Type::NAME)));
+ BOOST_CHECK_EQUAL(getSync().m_adjLsaUserPrefix,
+ ndn::Name(opts.userPrefix).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY)));
+ BOOST_CHECK_EQUAL(getSync().m_coorLsaUserPrefix,
+ ndn::Name(opts.userPrefix).append(boost::lexical_cast<std::string>(Lsa::Type::COORDINATE)));
}
BOOST_AUTO_TEST_SUITE_END()
-} // namespace test
-} // namespace nlsr
+} // namespace nlsr::test
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index bf7ddb3..a2b6c09 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, The University of Memphis,
+ * Copyright (c) 2014-2024, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -211,7 +211,7 @@
BOOST_CHECK_EQUAL(castor.getFaceUri().toString(), "udp4://10.0.0.1:6363");
// Hyperbolic
- BOOST_CHECK_EQUAL(conf.getHyperbolicState(), 0);
+ BOOST_CHECK_EQUAL(conf.getHyperbolicState(), HYPERBOLIC_STATE_OFF);
// FIB
BOOST_CHECK_EQUAL(conf.getMaxFacesPerPrefix(), 3);
@@ -259,7 +259,7 @@
{
BOOST_REQUIRE(processConfigurationString(CONFIG_HYPERBOLIC));
- BOOST_CHECK_EQUAL(conf.getHyperbolicState(), 1);
+ BOOST_CHECK_EQUAL(conf.getHyperbolicState(), HYPERBOLIC_STATE_ON);
BOOST_CHECK_EQUAL(conf.getCorR(), 123.456);
std::vector<double> angles{1.45};
BOOST_CHECK(conf.getCorTheta() == angles);
@@ -269,7 +269,7 @@
{
BOOST_REQUIRE(processConfigurationString(CONFIG_HYPERBOLIC_ANGLES));
- BOOST_CHECK_EQUAL(conf.getHyperbolicState(), 1);
+ BOOST_CHECK_EQUAL(conf.getHyperbolicState(), HYPERBOLIC_STATE_ON);
BOOST_CHECK_EQUAL(conf.getCorR(), 123.456);
std::vector<double> angles{1.45, 2.25};
BOOST_CHECK(conf.getCorTheta() == angles);
@@ -364,7 +364,7 @@
BOOST_REQUIRE(processConfigurationString(config));
- BOOST_CHECK_EQUAL(conf.getHyperbolicState(), static_cast<int32_t>(HYPERBOLIC_STATE_DEFAULT));
+ BOOST_CHECK_EQUAL(conf.getHyperbolicState(), HYPERBOLIC_STATE_DEFAULT);
}
BOOST_AUTO_TEST_CASE(OutOfRangeValue)
diff --git a/tests/test-conf-parameter.cpp b/tests/test-conf-parameter.cpp
index 02fe05b..cb52323 100644
--- a/tests/test-conf-parameter.cpp
+++ b/tests/test-conf-parameter.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, The University of Memphis,
+ * Copyright (c) 2014-2024, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -62,7 +62,7 @@
cp1.setMaxFacesPerPrefix(50);
- cp1.setHyperbolicState(1);
+ cp1.setHyperbolicState(HYPERBOLIC_STATE_ON);
cp1.setCorR(2.5);
@@ -98,7 +98,7 @@
BOOST_CHECK_EQUAL(cp1.getMaxFacesPerPrefix(), 50);
- BOOST_CHECK_EQUAL(cp1.getHyperbolicState(), 1);
+ BOOST_CHECK_EQUAL(cp1.getHyperbolicState(), HYPERBOLIC_STATE_ON);
BOOST_CHECK(cp1.getCorTheta() == angles);