lsa: change type variable to enum class
Change-Id: I7fba951649771700ce6ccc4be7fb400546607e96
refs: #4340
diff --git a/tests/test-link-state-calculator.cpp b/tests/test-link-state-calculator.cpp
index 8aee304..d0605f3 100644
--- a/tests/test-link-state-calculator.cpp
+++ b/tests/test-link-state-calculator.cpp
@@ -175,7 +175,7 @@
BOOST_AUTO_TEST_CASE(Asymmetric)
{
// Asymmetric link cost between B and C
- ndn::Name key = ndn::Name(ROUTER_B_NAME).append(AdjLsa::TYPE_STRING);
+ ndn::Name key = ndn::Name(ROUTER_B_NAME).append(std::to_string(Lsa::Type::ADJACENCY));
AdjLsa* lsa = nlsr.getLsdb().findAdjLsa(key);
BOOST_REQUIRE(lsa != nullptr);
@@ -224,7 +224,7 @@
BOOST_AUTO_TEST_CASE(AsymmetricZeroCost)
{
// Asymmetric link cost between B and C
- ndn::Name key = ndn::Name(ROUTER_B_NAME).append(AdjLsa::TYPE_STRING);
+ ndn::Name key = ndn::Name(ROUTER_B_NAME).append(std::to_string(Lsa::Type::ADJACENCY));
AdjLsa* lsa = nlsr.getLsdb().findAdjLsa(key);
BOOST_REQUIRE(lsa != nullptr);
diff --git a/tests/test-lsa-rule.cpp b/tests/test-lsa-rule.cpp
index e7f6a69..0ec3ff5 100644
--- a/tests/test-lsa-rule.cpp
+++ b/tests/test-lsa-rule.cpp
@@ -171,7 +171,7 @@
lsaInterestName.append(nlsr.getConfParameter().getRouterName());
// Append LSA type
- lsaInterestName.append(ndn::Name("name"));
+ lsaInterestName.append(std::to_string(Lsa::Type::NAME));
// This would be the sequence number of its own NameLsa
lsaInterestName.appendNumber(nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
@@ -202,7 +202,7 @@
lsaInterestName.append(nlsr.getConfParameter().getRouterName());
// Append LSA type
- lsaInterestName.append(ndn::Name("name"));
+ lsaInterestName.append(std::to_string(Lsa::Type::NAME));
// This would be the sequence number of its own NameLsa
lsaInterestName.appendNumber(nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
diff --git a/tests/test-lsa.cpp b/tests/test-lsa.cpp
index 2750bb4..c7851f8 100644
--- a/tests/test-lsa.cpp
+++ b/tests/test-lsa.cpp
@@ -47,7 +47,7 @@
NameLsa nlsa1("router1", 12, testTimePoint, npl1);
NameLsa nlsa2("router2", 12, testTimePoint, npl1);
- BOOST_CHECK_EQUAL(nlsa1.getLsType(), NameLsa::TYPE_STRING);
+ BOOST_CHECK_EQUAL(nlsa1.getType(), Lsa::Type::NAME);
BOOST_CHECK(nlsa1.getExpirationTimePoint() == nlsa2.getExpirationTimePoint());
@@ -70,7 +70,7 @@
AdjLsa alsa1(routerName, seqNo, testTimePoint,
activeAdjacencies.size(), activeAdjacencies);
BOOST_CHECK_EQUAL(alsa1.getAdl().size(), 1);
- BOOST_CHECK_EQUAL(alsa1.getLsType(), AdjLsa::TYPE_STRING);
+ BOOST_CHECK_EQUAL(alsa1.getType(), Lsa::Type::ADJACENCY);
BOOST_CHECK_EQUAL(alsa1.getLsSeqNo(), seqNo);
BOOST_CHECK_EQUAL(alsa1.getExpirationTimePoint(), testTimePoint);
BOOST_CHECK_EQUAL(alsa1.getNoLink(), 1);
@@ -135,7 +135,7 @@
std::string EXPECTED_OUTPUT =
"Adj Lsa:\n"
" Origination Router: /router1\n"
- " Ls Type: adjacency\n"
+ " Ls Type: ADJACENCY\n"
" Ls Seq No: 12\n"
" Ls Lifetime: " + TEST_TIME_POINT_STRING + "\n"
" Adjacents: \n"
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 866c91b..e04c74b 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -187,7 +187,7 @@
std::string expectedDataContent = lsa.getData();
lsdb.installNameLsa(lsa);
- ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/name/");
+ ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/NAME/");
interestName.appendNumber(seqNo);
ndn::Interest interest(interestName);
@@ -223,7 +223,7 @@
lsa.addName(ndn::Name(prefix).appendNumber(nPrefixes));
}
- ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/name/");
+ ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/NAME/");
interestName.appendNumber(seqNo);
const ndn::ConstBufferPtr bufferPtr = std::make_shared<ndn::Buffer>(lsa.getData().c_str(),
@@ -258,11 +258,11 @@
lsdb1.installNameLsa(nlsa1);
lsdb1.writeNameLsdbLog();
- BOOST_CHECK(lsdb1.doesLsaExist(ndn::Name("/router1/1/name"), NameLsa::TYPE_STRING));
+ BOOST_CHECK(lsdb1.doesLsaExist(ndn::Name("/router1/1/NAME"), Lsa::Type::NAME));
lsdb1.removeNameLsa(router1);
- BOOST_CHECK_EQUAL(lsdb1.doesLsaExist(ndn::Name("/router1/1"), NameLsa::TYPE_STRING), false);
+ BOOST_CHECK_EQUAL(lsdb1.doesLsaExist(ndn::Name("/router1/1"), Lsa::Type::NAME), false);
}
BOOST_AUTO_TEST_CASE(InstallNameLsa)
@@ -281,8 +281,8 @@
NameLsa lsa(otherRouter, 1, MAX_TIME, prefixes);
lsdb.installNameLsa(lsa);
- BOOST_REQUIRE_EQUAL(lsdb.doesLsaExist(otherRouter + "/name", NameLsa::TYPE_STRING), true);
- NamePrefixList& nameList = lsdb.findNameLsa(otherRouter + "/name")->getNpl();
+ BOOST_REQUIRE_EQUAL(lsdb.doesLsaExist(otherRouter + "/NAME", Lsa::Type::NAME), true);
+ NamePrefixList& nameList = lsdb.findNameLsa(otherRouter + "/NAME")->getNpl();
BOOST_CHECK_EQUAL(nameList, prefixes);
//areNamePrefixListsEqual(nameList, prefixes);
@@ -346,15 +346,15 @@
// Lower NameLSA sequence number
uint64_t lowerSeqNo = 998;
- BOOST_CHECK(!lsdb.isLsaNew(originRouter, NameLsa::TYPE_STRING, lowerSeqNo));
+ BOOST_CHECK(!lsdb.isLsaNew(originRouter, Lsa::Type::NAME, lowerSeqNo));
// Same NameLSA sequence number
uint64_t sameSeqNo = 999;
- BOOST_CHECK(!lsdb.isLsaNew(originRouter, NameLsa::TYPE_STRING, sameSeqNo));
+ BOOST_CHECK(!lsdb.isLsaNew(originRouter, Lsa::Type::NAME, sameSeqNo));
// Higher NameLSA sequence number
uint64_t higherSeqNo = 1000;
- BOOST_CHECK(lsdb.isLsaNew(originRouter, NameLsa::TYPE_STRING, higherSeqNo));
+ BOOST_CHECK(lsdb.isLsaNew(originRouter, Lsa::Type::NAME, higherSeqNo));
}
BOOST_AUTO_TEST_SUITE_END() // TestLsdb
diff --git a/tests/test-nlsr.cpp b/tests/test-nlsr.cpp
index 48cd7bf..fe30864 100644
--- a/tests/test-nlsr.cpp
+++ b/tests/test-nlsr.cpp
@@ -68,13 +68,16 @@
BOOST_AUTO_TEST_CASE(HyperbolicOn_ZeroCostNeighbors)
{
// Simulate loading configuration file
- Adjacent neighborA("/ndn/neighborA", ndn::util::FaceUri("udp4://10.0.0.1"), 25, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighborA("/ndn/neighborA", ndn::util::FaceUri("udp4://10.0.0.1"), 25,
+ Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborA);
- Adjacent neighborB("/ndn/neighborB", ndn::util::FaceUri("udp4://10.0.0.2"), 10, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighborB("/ndn/neighborB", ndn::util::FaceUri("udp4://10.0.0.2"), 10,
+ Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborB);
- Adjacent neighborC("/ndn/neighborC", ndn::util::FaceUri("udp4://10.0.0.3"), 17, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighborC("/ndn/neighborC", ndn::util::FaceUri("udp4://10.0.0.3"), 17,
+ Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborC);
nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_ON);
@@ -91,13 +94,16 @@
BOOST_AUTO_TEST_CASE(HyperbolicOff_LinkStateCost)
{
// Simulate loading configuration file
- Adjacent neighborA("/ndn/neighborA", ndn::util::FaceUri("udp4://10.0.0.1"), 25, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighborA("/ndn/neighborA", ndn::util::FaceUri("udp4://10.0.0.1"), 25,
+ Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborA);
- Adjacent neighborB("/ndn/neighborB", ndn::util::FaceUri("udp4://10.0.0.2"), 10, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighborB("/ndn/neighborB", ndn::util::FaceUri("udp4://10.0.0.2"), 10,
+ Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborB);
- Adjacent neighborC("/ndn/neighborC", ndn::util::FaceUri("udp4://10.0.0.3"), 17, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighborC("/ndn/neighborC", ndn::util::FaceUri("udp4://10.0.0.3"), 17,
+ Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborC);
nlsr.initialize();
@@ -131,7 +137,8 @@
// Setting constants for the unit test
const uint32_t faceId = 1;
const std::string faceUri = "udp4://10.0.0.1:6363";
- Adjacent neighbor("/ndn/neighborA", ndn::util::FaceUri(faceUri), 10, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighbor("/ndn/neighborA", ndn::util::FaceUri(faceUri), 10,
+ Adjacent::STATUS_INACTIVE, 0, 0);
BOOST_REQUIRE_EQUAL(nlsr.getAdjacencyList().insert(neighbor), 0);
this->advanceClocks(ndn::time::milliseconds(1));
@@ -162,7 +169,8 @@
const uint32_t faceId = 1;
const std::string eventUri = "udp4://10.0.0.1:6363";
const std::string neighborUri = "udp4://10.0.0.2:6363";
- Adjacent neighbor("/ndn/neighborA", ndn::util::FaceUri(neighborUri), 10, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighbor("/ndn/neighborA", ndn::util::FaceUri(neighborUri), 10,
+ Adjacent::STATUS_INACTIVE, 0, 0);
nlsr.getAdjacencyList().insert(neighbor);
// Build, sign, and send the Face Event
@@ -190,7 +198,8 @@
const uint32_t eventFaceId = 1;
const uint32_t neighborFaceId = 2;
const std::string faceUri = "udp4://10.0.0.1:6363";
- Adjacent neighbor("/ndn/neighborA", ndn::util::FaceUri(faceUri), 10, Adjacent::STATUS_ACTIVE, 0, neighborFaceId);
+ Adjacent neighbor("/ndn/neighborA", ndn::util::FaceUri(faceUri), 10,
+ Adjacent::STATUS_ACTIVE, 0, neighborFaceId);
nlsr.getAdjacencyList().insert(neighbor);
// Build, sign, and send the Face Event
@@ -214,7 +223,8 @@
BOOST_FIXTURE_TEST_CASE(FaceDestroyEvent, UnitTestTimeFixture)
{
- std::shared_ptr<ndn::util::DummyClientFace> face = std::make_shared<ndn::util::DummyClientFace>(g_ioService);
+ std::shared_ptr<ndn::util::DummyClientFace> face =
+ std::make_shared<ndn::util::DummyClientFace>(g_ioService);
Nlsr nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain);
Lsdb& lsdb = nlsr.getLsdb();
@@ -236,7 +246,8 @@
neighbors.insert(failNeighbor);
// Create an additional neighbor so an adjacency LSA can be built after the face is destroyed
- Adjacent otherNeighbor("/ndn/neighborB", ndn::util::FaceUri("udp4://10.0.0.2"), 10, Adjacent::STATUS_ACTIVE, 0, 256);
+ Adjacent otherNeighbor("/ndn/neighborB", ndn::util::FaceUri("udp4://10.0.0.2"), 10,
+ Adjacent::STATUS_ACTIVE, 0, 256);
neighbors.insert(otherNeighbor);
nlsr.initialize();
@@ -246,7 +257,8 @@
// Set up adjacency LSAs
// This router
- Adjacent thisRouter(conf.getRouterPrefix(), ndn::util::FaceUri("udp4://10.0.0.3"), 10, Adjacent::STATUS_ACTIVE, 0, 256);
+ Adjacent thisRouter(conf.getRouterPrefix(), ndn::util::FaceUri("udp4://10.0.0.3"), 10,
+ Adjacent::STATUS_ACTIVE, 0, 256);
AdjLsa ownAdjLsa(conf.getRouterPrefix(), 10, ndn::time::system_clock::now(), 1, neighbors);
lsdb.installAdjLsa(ownAdjLsa);
@@ -273,7 +285,8 @@
this->advanceClocks(ndn::time::milliseconds(1));
// Make sure an adjacency LSA was built
- ndn::Name key = ndn::Name(nlsr.getConfParameter().getRouterPrefix()).append(AdjLsa::TYPE_STRING);
+ ndn::Name key = ndn::Name(nlsr.getConfParameter().getRouterPrefix())
+ .append(std::to_string(Lsa::Type::ADJACENCY));
AdjLsa* lsa = lsdb.findAdjLsa(key);
BOOST_REQUIRE(lsa != nullptr);
@@ -374,12 +387,14 @@
// Add neighbors
// Router A
ndn::Name neighborAName("/ndn/site/%C1.router/routerA");
- Adjacent neighborA(neighborAName, ndn::util::FaceUri("udp4://10.0.0.1"), 0, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighborA(neighborAName, ndn::util::FaceUri("udp4://10.0.0.1"), 0,
+ Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborA);
// Router B
ndn::Name neighborBName("/ndn/site/%C1.router/routerB");
- Adjacent neighborB(neighborBName, ndn::util::FaceUri("udp4://10.0.0.1"), 0, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighborB(neighborBName, ndn::util::FaceUri("udp4://10.0.0.1"), 0,
+ Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborB);
nlsr.initialize();
@@ -389,7 +404,7 @@
receiveHelloData(neighborAName, conf.getRouterPrefix());
this->advanceClocks(ndn::time::seconds(1));
- ndn::Name lsaKey = ndn::Name(conf.getRouterPrefix()).append(AdjLsa::TYPE_STRING);
+ ndn::Name lsaKey = ndn::Name(conf.getRouterPrefix()).append(std::to_string(Lsa::Type::ADJACENCY));
// Adjacency LSA should be built even though other router is INACTIVE
AdjLsa* lsa = lsdb.findAdjLsa(lsaKey);
@@ -440,12 +455,14 @@
nlsr.initialize();
};
std::function<void(std::list<Adjacent>::iterator)> thenCallback =
- [this, &thenCallback, &finallyCallback, &nCanonizationsLeft] (std::list<Adjacent>::iterator iterator) {
+ [this, &thenCallback, &finallyCallback, &nCanonizationsLeft]
+ (std::list<Adjacent>::iterator iterator) {
nCanonizationsLeft--;
nlsr.canonizeNeighborUris(iterator, thenCallback, finallyCallback);
};
nlsr.canonizeNeighborUris(nlsr.getAdjacencyList().getAdjList().begin(),
- [&thenCallback, &finallyCallback] (std::list<Adjacent>::iterator iterator) {
+ [&thenCallback, &finallyCallback]
+ (std::list<Adjacent>::iterator iterator) {
thenCallback(iterator);
},
finallyCallback);
@@ -504,10 +521,12 @@
BOOST_AUTO_TEST_CASE(FaceDatasetProcess)
{
- Adjacent neighborA("/ndn/neighborA", ndn::util::FaceUri("udp4://192.168.0.100:6363"), 25, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighborA("/ndn/neighborA", ndn::util::FaceUri("udp4://192.168.0.100:6363"), 25,
+ Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborA);
- Adjacent neighborB("/ndn/neighborB", ndn::util::FaceUri("udp4://192.168.0.101:6363"), 10, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighborB("/ndn/neighborB", ndn::util::FaceUri("udp4://192.168.0.101:6363"), 10,
+ Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborB);
ndn::nfd::FaceStatus payload1;
@@ -529,7 +548,8 @@
BOOST_AUTO_TEST_CASE(UnconfiguredNeighbor)
{
- Adjacent neighborA("/ndn/neighborA", ndn::util::FaceUri("udp4://192.168.0.100:6363"), 25, Adjacent::STATUS_INACTIVE, 0, 0);
+ Adjacent neighborA("/ndn/neighborA", ndn::util::FaceUri("udp4://192.168.0.100:6363"), 25,
+ Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborA);
ndn::nfd::FaceStatus payload;
diff --git a/tests/test-statistics.cpp b/tests/test-statistics.cpp
index bcfc29c..ad2f0d9 100644
--- a/tests/test-statistics.cpp
+++ b/tests/test-statistics.cpp
@@ -200,21 +200,25 @@
uint32_t seqNo = 1;
// Adjacency LSA
- sendInterestAndCheckStats(interestPrefix, AdjLsa::TYPE_STRING, seqNo, Statistics::PacketType::SENT_ADJ_LSA_INTEREST);
+ sendInterestAndCheckStats(interestPrefix, std::to_string(Lsa::Type::ADJACENCY), seqNo,
+ Statistics::PacketType::SENT_ADJ_LSA_INTEREST);
// Coordinate LSA
- sendInterestAndCheckStats(interestPrefix, CoordinateLsa::TYPE_STRING, seqNo, Statistics::PacketType::SENT_COORD_LSA_INTEREST);
+ sendInterestAndCheckStats(interestPrefix, std::to_string(Lsa::Type::COORDINATE), seqNo,
+ Statistics::PacketType::SENT_COORD_LSA_INTEREST);
// Name LSA
- sendInterestAndCheckStats(interestPrefix, NameLsa::TYPE_STRING, seqNo, Statistics::PacketType::SENT_NAME_LSA_INTEREST);
+ sendInterestAndCheckStats(interestPrefix, std::to_string(Lsa::Type::NAME), seqNo,
+ Statistics::PacketType::SENT_NAME_LSA_INTEREST);
// 3 total lsa interests were sent
BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::SENT_LSA_INTEREST), 3);
}
/*
- * Tests the statistics collected upon processing incoming lsa interests and respective outgoing data.
- * This process will trigger both an increment for received lsa interest and sent lsa data.
+ * Tests the statistics collected upon processing incoming lsa
+ * interests and respective outgoing data. This process will trigger
+ * both an increment for received lsa interest and sent lsa data.
*
* /sa receiveInterestAndCheckSentStats
*/
@@ -238,7 +242,7 @@
// Receive Adjacency LSA Interest
receiveInterestAndCheckSentStats(interestPrefix,
- AdjLsa::TYPE_STRING,
+ std::to_string(Lsa::Type::ADJACENCY),
seqNo,
Statistics::PacketType::RCV_ADJ_LSA_INTEREST,
Statistics::PacketType::SENT_ADJ_LSA_DATA);
@@ -252,7 +256,7 @@
// Receive Name LSA Interest
receiveInterestAndCheckSentStats(interestPrefix,
- NameLsa::TYPE_STRING,
+ std::to_string(Lsa::Type::NAME),
seqNo,
Statistics::PacketType::RCV_NAME_LSA_INTEREST,
Statistics::PacketType::SENT_NAME_LSA_DATA);
@@ -264,7 +268,7 @@
// Receive Adjacency LSA Interest
receiveInterestAndCheckSentStats(interestPrefix,
- CoordinateLsa::TYPE_STRING,
+ std::to_string(Lsa::Type::COORDINATE),
seqNo,
Statistics::PacketType::RCV_COORD_LSA_INTEREST,
Statistics::PacketType::SENT_COORD_LSA_DATA);
@@ -287,7 +291,7 @@
ndn::time::system_clock::TimePoint MAX_TIME = ndn::time::system_clock::TimePoint::max();
// adjacency lsa
- ndn::Name adjInterest("/ndn/NLSR/LSA/cs/%C1.Router/router1/adjacency/");
+ ndn::Name adjInterest("/ndn/NLSR/LSA/cs/%C1.Router/router1/ADJACENCY/");
adjInterest.appendNumber(seqNo);
AdjLsa aLsa(routerName, seqNo, MAX_TIME, 1, nlsr.getAdjacencyList());
lsdb.installAdjLsa(aLsa);
@@ -298,7 +302,7 @@
BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::RCV_ADJ_LSA_DATA), 1);
// coordinate lsa
- ndn::Name coordInterest("/ndn/NLSR/LSA/cs/%C1.Router/router1/coordinate/");
+ ndn::Name coordInterest("/ndn/NLSR/LSA/cs/%C1.Router/router1/COORDINATE/");
coordInterest.appendNumber(seqNo);
std::vector<double> angles = {20.0, 30.0};
CoordinateLsa cLsa(routerName, seqNo, MAX_TIME, 2.5, angles);
@@ -310,7 +314,7 @@
BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::RCV_COORD_LSA_DATA), 1);
// name lsa
- ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/name/");
+ ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/NAME/");
interestName.appendNumber(seqNo);
NameLsa nLsa(routerName, seqNo, MAX_TIME, nlsr.getNamePrefixList());
lsdb.installNameLsa(nLsa);
diff --git a/tests/test-sync-logic-handler.cpp b/tests/test-sync-logic-handler.cpp
index bb6a6db..e660a5d 100644
--- a/tests/test-sync-logic-handler.cpp
+++ b/tests/test-sync-logic-handler.cpp
@@ -23,6 +23,7 @@
#include "test-common.hpp"
#include "common.hpp"
#include "nlsr.hpp"
+#include "lsa.hpp"
#include "logger.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
@@ -38,7 +39,7 @@
SyncLogicFixture()
: face(std::make_shared<ndn::util::DummyClientFace>())
, nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
- , testIsLsaNew([] (const ndn::Name& name, const std::string& lsaType,
+ , testIsLsaNew([] (const ndn::Name& name, const Lsa::Type& lsaType,
const uint64_t sequenceNumber) {
return true;
})
@@ -79,14 +80,14 @@
std::shared_ptr<ndn::util::DummyClientFace> face;
Nlsr nlsr;
ConfParameter conf;
- IsLsaNew testIsLsaNew;
+ SyncLogicHandler::IsLsaNew testIsLsaNew;
const std::string CONFIG_NETWORK;
const std::string CONFIG_SITE;
const std::string CONFIG_ROUTER_NAME;
const std::string OTHER_ROUTER_NAME;
- const std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, AdjLsa::TYPE_STRING,
- CoordinateLsa::TYPE_STRING};
+ const std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::ADJACENCY,
+ Lsa::Type::COORDINATE};
};
BOOST_FIXTURE_TEST_SUITE(TestSyncLogicHandler, SyncLogicFixture)
@@ -100,13 +101,13 @@
SyncLogicHandler sync{std::ref(*face), testIsLsaNew, conf};
sync.createSyncSocket(conf.getChronosyncPrefix());
- std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, AdjLsa::TYPE_STRING};
+ std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::ADJACENCY};
uint64_t syncSeqNo = 1;
- for (const std::string& lsaType : lsaTypes) {
+ for (const Lsa::Type& lsaType : lsaTypes) {
std::string updateName = conf.getLsaPrefix().toUri() + CONFIG_SITE
- + OTHER_ROUTER_NAME + lsaType;
+ + OTHER_ROUTER_NAME + std::to_string(lsaType);
// Actual testing done here -- signal function callback
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
@@ -131,11 +132,11 @@
sync.createSyncSocket(conf.getChronosyncPrefix());
uint64_t syncSeqNo = 1;
- std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, CoordinateLsa::TYPE_STRING};
+ std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::COORDINATE};
- for (const std::string& lsaType : lsaTypes) {
+ for (const Lsa::Type& lsaType : lsaTypes) {
std::string updateName = conf.getLsaPrefix().toUri() + CONFIG_SITE
- + OTHER_ROUTER_NAME + lsaType;
+ + OTHER_ROUTER_NAME + std::to_string(lsaType);
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
@@ -158,11 +159,11 @@
SyncLogicHandler sync{std::ref(*face), testIsLsaNew, conf};
sync.createSyncSocket(conf.getChronosyncPrefix());
- for (const std::string& lsaType : lsaTypes) {
+ for (const Lsa::Type& lsaType : lsaTypes) {
uint64_t syncSeqNo = 1;
std::string updateName = conf.getLsaPrefix().toUri() + CONFIG_SITE
- + OTHER_ROUTER_NAME + lsaType;
+ + OTHER_ROUTER_NAME + std::to_string(lsaType);
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
@@ -185,11 +186,11 @@
SyncLogicHandler sync{std::ref(*face), testIsLsaNew, conf};
sync.createSyncSocket(conf.getChronosyncPrefix());
- for (const std::string& lsaType : lsaTypes) {
+ for (const Lsa::Type& lsaType : lsaTypes) {
// To ensure that we get correctly-separated components, create
// and modify a Name to hand off.
ndn::Name updateName = ndn::Name{conf.getLsaPrefix()};
- updateName.append(CONFIG_SITE).append(CONFIG_ROUTER_NAME).append(lsaType);
+ updateName.append(CONFIG_SITE).append(CONFIG_ROUTER_NAME).append(std::to_string(lsaType));
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
@@ -211,9 +212,9 @@
SyncLogicHandler sync{std::ref(*face), testIsLsaNew, conf};
sync.createSyncSocket(conf.getChronosyncPrefix());
- for (const std::string& lsaType : lsaTypes) {
+ for (const Lsa::Type& lsaType : lsaTypes) {
ndn::Name updateName{CONFIG_SITE};
- updateName.append(CONFIG_ROUTER_NAME).append(lsaType);
+ updateName.append(CONFIG_ROUTER_NAME).append(std::to_string(lsaType));
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
@@ -230,7 +231,7 @@
*/
BOOST_AUTO_TEST_CASE(LsaNotNew)
{
- auto testLsaAlwaysFalse = [] (const ndn::Name& routerName, const std::string& lsaType,
+ auto testLsaAlwaysFalse = [] (const ndn::Name& routerName, const Lsa::Type& lsaType,
const uint64_t& sequenceNumber) {
return false;
};
@@ -244,7 +245,8 @@
});
std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
- CONFIG_SITE + "/%C1.Router/other-router/" + NameLsa::TYPE_STRING;
+ CONFIG_SITE + "/%C1.Router/other-router/" +
+ std::to_string(Lsa::Type::NAME);
receiveUpdate(updateName, sequenceNumber, sync);
}
@@ -265,32 +267,32 @@
sync.buildUpdatePrefix();
BOOST_CHECK_EQUAL(sync.m_nameLsaUserPrefix,
- ndn::Name(expectedPrefix).append(NameLsa::TYPE_STRING));
+ ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::NAME)));
BOOST_CHECK_EQUAL(sync.m_adjLsaUserPrefix,
- ndn::Name(expectedPrefix).append(AdjLsa::TYPE_STRING));
+ ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::ADJACENCY)));
BOOST_CHECK_EQUAL(sync.m_coorLsaUserPrefix,
- ndn::Name(expectedPrefix).append(CoordinateLsa::TYPE_STRING));
+ ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::COORDINATE)));
}
/* Tests that SyncLogicHandler's socket will be created when
Nlsr::initialize is called, preventing use of sync before the
socket is created.
- NB: This test is as much an Nlsr class test as a SyncLogicHandler
- class test, but it rides the line and ends up here.
+ NB: This test is as much an Nlsr class test as a
+ SyncLogicHandler class test, but it rides the line and ends up here.
*/
BOOST_AUTO_TEST_CASE(CreateSyncSocketOnInitialization) // Bug #2649
{
nlsr.initialize();
// Make sure an adjacency LSA has not been built yet
- ndn::Name key = ndn::Name(nlsr.getConfParameter().getRouterPrefix()).append(AdjLsa::TYPE_STRING);
+ ndn::Name key = ndn::Name(nlsr.getConfParameter().getRouterPrefix()).append(std::to_string(Lsa::Type::ADJACENCY));
AdjLsa* lsa = nlsr.getLsdb().findAdjLsa(key);
BOOST_REQUIRE(lsa == nullptr);
// Publish a routing update before an Adjacency LSA is built
BOOST_CHECK_NO_THROW(nlsr.getLsdb().getSyncLogicHandler()
- .publishRoutingUpdate(AdjLsa::TYPE_STRING, 0));
+ .publishRoutingUpdate(Lsa::Type::ADJACENCY, 0));
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/tlv/test-lsa-info.cpp b/tests/tlv/test-lsa-info.cpp
index 2997231..a179e2c 100644
--- a/tests/tlv/test-lsa-info.cpp
+++ b/tests/tlv/test-lsa-info.cpp
@@ -24,7 +24,7 @@
#include "../boost-test.hpp"
namespace nlsr {
-namespace tlv {
+namespace tlv {
namespace test {
BOOST_AUTO_TEST_SUITE(TlvTestLsaInfo)
@@ -125,7 +125,7 @@
BOOST_AUTO_TEST_CASE(LsaInfoMake)
{
- Lsa lsa("lsa-type");
+ Lsa lsa;
lsa.setOrigRouter("/test/lsa/info/tlv");
lsa.setLsSeqNo(128);
lsa.setExpirationTimePoint(ndn::time::system_clock::now());
diff --git a/tests/update/test-nfd-rib-command-processor.cpp b/tests/update/test-nfd-rib-command-processor.cpp
index 20856fe..53c77a1 100644
--- a/tests/update/test-nfd-rib-command-processor.cpp
+++ b/tests/update/test-nfd-rib-command-processor.cpp
@@ -75,7 +75,7 @@
// 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);
+ lsaInterestName.append(std::to_string(Lsa::Type::NAME));
// The part after LSA is Chronosync getSession
lsaInterestName.append(sessionTime);
diff --git a/tests/update/test-prefix-update-processor.cpp b/tests/update/test-prefix-update-processor.cpp
index 8fb4c27..62ec8f6 100644
--- a/tests/update/test-prefix-update-processor.cpp
+++ b/tests/update/test-prefix-update-processor.cpp
@@ -163,7 +163,7 @@
// 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);
+ lsaInterestName.append(std::to_string(Lsa::Type::NAME));
// The part after LSA is Chronosync getSession
lsaInterestName.append(sessionTime);