**breaking** consolidate src/tlv/*lsa* into src/lsa/*lsa*
Lsa de/serialize functions are replaced by wireEncode/Decode.
Update LSA wire formats. Change TLV assignments as required.
Update nlsrc to print using new encoding.
refs: #4787
Change-Id: Ie8d40b7836d51ea5bb444c8db208dc2b3a0d1cec
diff --git a/tests/communication/test-sync-logic-handler.cpp b/tests/communication/test-sync-logic-handler.cpp
index de99239..bdd8a3e 100644
--- a/tests/communication/test-sync-logic-handler.cpp
+++ b/tests/communication/test-sync-logic-handler.cpp
@@ -23,7 +23,6 @@
#include "tests/test-common.hpp"
#include "common.hpp"
#include "nlsr.hpp"
-#include "lsa.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
@@ -101,7 +100,7 @@
uint64_t syncSeqNo = 1;
for (const Lsa::Type& lsaType : lsaTypes) {
- std::string updateName = this->updateNamePrefix + std::to_string(lsaType);
+ std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
// Actual testing done here -- signal function callback
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
@@ -127,7 +126,7 @@
std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::COORDINATE};
for (const Lsa::Type& lsaType : lsaTypes) {
- std::string updateName = this->updateNamePrefix + std::to_string(lsaType);
+ std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
[&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
@@ -151,7 +150,7 @@
uint64_t syncSeqNo = 1;
for (const Lsa::Type& lsaType : this->lsaTypes) {
- std::string updateName = this->updateNamePrefix + std::to_string(lsaType);
+ std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
[&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
@@ -178,7 +177,7 @@
ndn::Name updateName = ndn::Name{this->conf.getLsaPrefix()};
updateName.append(this->conf.getSiteName())
.append(this->conf.getRouterName())
- .append(std::to_string(lsaType));
+ .append(boost::lexical_cast<std::string>(lsaType));
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
[&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
@@ -200,7 +199,7 @@
for (const Lsa::Type& lsaType : this->lsaTypes) {
ndn::Name updateName{this->conf.getSiteName()};
- updateName.append(this->conf.getRouterName()).append(std::to_string(lsaType));
+ updateName.append(this->conf.getRouterName()).append(boost::lexical_cast<std::string>(lsaType));
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
[&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
@@ -231,7 +230,7 @@
BOOST_FAIL("An update for an LSA with non-new sequence number should not emit!");
});
- std::string updateName = this->updateNamePrefix + std::to_string(Lsa::Type::NAME);
+ std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(Lsa::Type::NAME);
this->receiveUpdate(updateName, sequenceNumber);
}
@@ -247,11 +246,11 @@
expectedPrefix.append(this->conf.getRouterName());
BOOST_CHECK_EQUAL(this->sync.m_nameLsaUserPrefix,
- ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::NAME)));
+ ndn::Name(expectedPrefix).append(boost::lexical_cast<std::string>(Lsa::Type::NAME)));
BOOST_CHECK_EQUAL(this->sync.m_adjLsaUserPrefix,
- ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::ADJACENCY)));
+ ndn::Name(expectedPrefix).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY)));
BOOST_CHECK_EQUAL(this->sync.m_coorLsaUserPrefix,
- ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::COORDINATE)));
+ ndn::Name(expectedPrefix).append(boost::lexical_cast<std::string>(Lsa::Type::COORDINATE)));
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/mocks/lsa.cpp b/tests/mocks/lsa.cpp
deleted file mode 100644
index a9ea498..0000000
--- a/tests/mocks/lsa.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, The University of Memphis,
- * Regents of the University of California,
- * Arizona Board of Regents.
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "./lsa.hpp"
-
-namespace nlsr {
-namespace test {
-
-std::string
-MockLsa::serialize() const
-{
- return "";
-}
-
-bool
-MockLsa::deserialize(const std::string& content) noexcept
-{
- boost::char_separator<char> sep("|");
- boost::tokenizer<boost::char_separator<char> >tokens(content, sep);
- boost::tokenizer<boost::char_separator<char> >::iterator tok_iter =
- tokens.begin();
-
- try {
- deserializeCommon(tok_iter);
- }
- catch (const std::exception& e) {
- return false;
- }
- return true;
-}
-
-void
-MockLsa::writeLog() const
-{
-}
-
-} // namespace test
-} // namespace nlsr
diff --git a/tests/mocks/lsa.hpp b/tests/mocks/lsa.hpp
deleted file mode 100644
index e1ee2aa..0000000
--- a/tests/mocks/lsa.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, The University of Memphis,
- * Regents of the University of California,
- * Arizona Board of Regents.
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#ifndef NLSR_TESTS_MOCKS_LSA_HPP
-#define NLSR_TESTS_MOCKS_LSA_HPP
-
-#include "src/lsa.hpp"
-
-#include <boost/tokenizer.hpp>
-#include <boost/algorithm/string.hpp>
-#include <boost/lexical_cast.hpp>
-
-namespace nlsr {
-namespace test {
-
-class MockLsa : public Lsa
-{
-public:
- MockLsa()
- {
- }
-
- std::string
- serialize() const override;
-
- bool
- deserialize(const std::string& content) noexcept override;
-
- void
- writeLog() const override;
-};
-
-} // namespace test
-} // namespace nlsr
-
-#endif // NLSR_TESTS_MOCKS_LSA_HPP
diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index be97a34..18a51f0 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -64,40 +64,6 @@
lsa.addAdjacent(std::move(adjacency));
}
- void
- checkTlvLsaInfo(const tlv::LsaInfo& info, Lsa& lsa)
- {
- BOOST_CHECK_EQUAL(info.getOriginRouter(), lsa.getOrigRouter());
- BOOST_CHECK_EQUAL(info.getSequenceNumber(), lsa.getLsSeqNo());
- BOOST_CHECK_LE(info.getExpirationPeriod(), ndn::time::milliseconds(0));
- }
-
- void
- checkTlvAdjLsa(const ndn::Block& block, AdjLsa& lsa)
- {
- BOOST_CHECK_EQUAL(block.type(), ndn::tlv::nlsr::AdjacencyLsa);
-
- tlv::AdjacencyLsa tlvLsa;
- BOOST_REQUIRE_NO_THROW(tlvLsa.wireDecode(block));
-
- checkTlvAdjLsa(tlvLsa, lsa);
- }
-
- void
- checkTlvAdjLsa(const tlv::AdjacencyLsa& tlvLsa, AdjLsa& lsa)
- {
- checkTlvLsaInfo(tlvLsa.getLsaInfo(), lsa);
-
- std::list<tlv::Adjacency>::const_iterator it = tlvLsa.getAdjacencies().begin();
-
- for (const Adjacent& adjacency : lsa.getAdl().getAdjList()) {
- BOOST_CHECK_EQUAL(it->getName(), adjacency.getName());
- BOOST_CHECK_EQUAL(it->getUri(), adjacency.getFaceUri().toString());
- BOOST_CHECK_EQUAL(it->getCost(), adjacency.getLinkCost());
- ++it;
- }
- }
-
NextHop
createNextHop(const std::string& faceUri, double cost)
{
@@ -113,50 +79,6 @@
return lsa;
}
- void
- checkTlvCoordinateLsa(const ndn::Block& block, CoordinateLsa& lsa)
- {
- BOOST_CHECK_EQUAL(block.type(), ndn::tlv::nlsr::CoordinateLsa);
-
- tlv::CoordinateLsa tlvLsa;
- BOOST_REQUIRE_NO_THROW(tlvLsa.wireDecode(block));
-
- checkTlvCoordinateLsa(tlvLsa, lsa);
- }
-
- void
- checkTlvCoordinateLsa(const tlv::CoordinateLsa& tlvLsa, CoordinateLsa& lsa)
- {
- checkTlvLsaInfo(tlvLsa.getLsaInfo(), lsa);
-
- BOOST_CHECK_EQUAL(tlvLsa.getHyperbolicRadius(), lsa.getCorRadius());
- BOOST_CHECK(tlvLsa.getHyperbolicAngle() == lsa.getCorTheta());
- }
-
- void
- checkTlvNameLsa(const ndn::Block& block, NameLsa& lsa)
- {
- BOOST_CHECK_EQUAL(block.type(), ndn::tlv::nlsr::NameLsa);
-
- tlv::NameLsa tlvLsa;
- BOOST_REQUIRE_NO_THROW(tlvLsa.wireDecode(block));
-
- checkTlvNameLsa(tlvLsa, lsa);
- }
-
- void
- checkTlvNameLsa(const tlv::NameLsa& tlvLsa, NameLsa& lsa)
- {
- checkTlvLsaInfo(tlvLsa.getLsaInfo(), lsa);
-
- std::list<ndn::Name>::const_iterator it = tlvLsa.getNames().begin();
-
- for (const ndn::Name& name : lsa.getNpl().getNames()) {
- BOOST_CHECK_EQUAL(*it, name);
- ++it;
- }
- }
-
public:
ndn::util::DummyClientFace face;
ConfParameter conf;
diff --git a/tests/publisher/test-dataset-interest-handler.cpp b/tests/publisher/test-dataset-interest-handler.cpp
index b25576f..7342f62 100644
--- a/tests/publisher/test-dataset-interest-handler.cpp
+++ b/tests/publisher/test-dataset-interest-handler.cpp
@@ -56,7 +56,7 @@
// Install adjacency LSA
AdjLsa adjLsa;
- adjLsa.setOrigRouter("/RouterA");
+ adjLsa.m_originRouter = "/RouterA";
addAdjacency(adjLsa, "/RouterA/adjacency1", "udp://face-1", 10);
lsdb.installAdjLsa(adjLsa);
@@ -68,7 +68,7 @@
// Install Name LSA
NameLsa nameLsa;
- nameLsa.setOrigRouter("/RouterA");
+ nameLsa.m_originRouter = "/RouterA";
nameLsa.addName("/RouterA/name1");
lsdb.installNameLsa(nameLsa);
@@ -113,7 +113,7 @@
// Install adjacencies LSA
AdjLsa adjLsa;
- adjLsa.setOrigRouter("/RouterA");
+ adjLsa.m_originRouter = "/RouterA";
addAdjacency(adjLsa, "/RouterA/adjacency1", "udp://face-1", 10);
lsdb.installAdjLsa(adjLsa);
diff --git a/tests/security/test-certificate-store.cpp b/tests/security/test-certificate-store.cpp
index b09bd5a..0009c17 100644
--- a/tests/security/test-certificate-store.cpp
+++ b/tests/security/test-certificate-store.cpp
@@ -174,7 +174,7 @@
lsaInterestName.append(conf.getLsaPrefix().getSubName(1));
lsaInterestName.append(conf.getSiteName());
lsaInterestName.append(conf.getRouterName());
- lsaInterestName.append(std::to_string(Lsa::Type::NAME));
+ lsaInterestName.append(boost::lexical_cast<std::string>(Lsa::Type::NAME));
lsaInterestName.appendNumber(nlsr.m_lsdb.m_sequencingManager.getNameLsaSeq() + 1);
lsdb.expressInterest(lsaInterestName, 0);
@@ -188,8 +188,8 @@
ndn::Data data(lsaDataName);
data.setFreshnessPeriod(ndn::time::seconds(10));
- ndn::Data dummyData;
- data.setContent(dummyData.getContent());
+ NameLsa nameLsa;
+ data.setContent(nameLsa.wireEncode());
data.setFinalBlock(lsaDataName[-1]);
// Sign data with this NLSR's key (in real it would be different NLSR)
@@ -200,10 +200,10 @@
// Make NLSR validate data signed by its own key
conf.getValidator().validate(data,
- [] (const ndn::Data&) { BOOST_CHECK(true); },
- [] (const ndn::Data&, const ndn::security::v2::ValidationError&) {
- BOOST_CHECK(false);
- });
+ [] (const ndn::Data&) { BOOST_CHECK(true); },
+ [] (const ndn::Data&, const ndn::security::v2::ValidationError&) {
+ BOOST_CHECK(false);
+ });
lsdb.emitSegmentValidatedSignal(data);
const auto keyName = data.getSignature().getKeyLocator().getName();
diff --git a/tests/test-adjacent.cpp b/tests/test-adjacent.cpp
index a65ef97..3d61a3a 100644
--- a/tests/test-adjacent.cpp
+++ b/tests/test-adjacent.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2019, The University of Memphis,
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
diff --git a/tests/test-hyperbolic-calculator.cpp b/tests/test-hyperbolic-calculator.cpp
index 0011ce9..2a787ba 100644
--- a/tests/test-hyperbolic-calculator.cpp
+++ b/tests/test-hyperbolic-calculator.cpp
@@ -24,7 +24,7 @@
#include "route/routing-table-calculator.hpp"
#include "adjacency-list.hpp"
-#include "lsa.hpp"
+//#include "lsa.hpp"
#include "lsdb.hpp"
#include "nlsr.hpp"
#include "route/map.hpp"
@@ -68,7 +68,7 @@
lsdb.installAdjLsa(adjA);
- CoordinateLsa coordA(adjA.getOrigRouter(), 1, MAX_TIME, 16.23, anglesA);
+ CoordinateLsa coordA(adjA.getOriginRouter(), 1, MAX_TIME, 16.23, anglesA);
lsdb.installCoordinateLsa(coordA);
// Router B
@@ -82,7 +82,7 @@
AdjLsa adjB(b.getName(), 1, MAX_TIME, 2, adjacencyListB);
lsdb.installAdjLsa(adjB);
- CoordinateLsa coordB(adjB.getOrigRouter(), 1, MAX_TIME, 16.59, anglesB);
+ CoordinateLsa coordB(adjB.getOriginRouter(), 1, MAX_TIME, 16.59, anglesB);
lsdb.installCoordinateLsa(coordB);
// Router C
@@ -96,7 +96,7 @@
AdjLsa adjC(c.getName(), 1, MAX_TIME, 2, adjacencyListC);
lsdb.installAdjLsa(adjC);
- CoordinateLsa coordC(adjC.getOrigRouter(), 1, MAX_TIME, 14.11, anglesC);
+ CoordinateLsa coordC(adjC.getOriginRouter(), 1, MAX_TIME, 14.11, anglesC);
lsdb.installCoordinateLsa(coordC);
map.createFromAdjLsdb(lsdb.getAdjLsdb().begin(), lsdb.getAdjLsdb().end());
diff --git a/tests/test-link-state-calculator.cpp b/tests/test-link-state-calculator.cpp
index 2d8ee1b..f43c4f6 100644
--- a/tests/test-link-state-calculator.cpp
+++ b/tests/test-link-state-calculator.cpp
@@ -22,7 +22,7 @@
#include "route/routing-table-calculator.hpp"
#include "adjacency-list.hpp"
-#include "lsa.hpp"
+//#include "lsa.hpp"
#include "lsdb.hpp"
#include "nlsr.hpp"
#include "test-common.hpp"
@@ -172,11 +172,11 @@
BOOST_AUTO_TEST_CASE(Asymmetric)
{
// Asymmetric link cost between B and C
- ndn::Name key = ndn::Name(ROUTER_B_NAME).append(std::to_string(Lsa::Type::ADJACENCY));
+ ndn::Name key = ndn::Name(ROUTER_B_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
AdjLsa* lsa = nlsr.m_lsdb.findAdjLsa(key);
BOOST_REQUIRE(lsa != nullptr);
- auto c = lsa->getAdl().findAdjacent(ROUTER_C_NAME);
+ auto c = lsa->m_adl.findAdjacent(ROUTER_C_NAME);
BOOST_REQUIRE(c != conf.getAdjacencyList().end());
double higherLinkCost = LINK_BC_COST + 1;
@@ -221,11 +221,11 @@
BOOST_AUTO_TEST_CASE(NonAdjacentCost)
{
// Asymmetric link cost between B and C
- ndn::Name key = ndn::Name(ROUTER_B_NAME).append(std::to_string(Lsa::Type::ADJACENCY));
+ ndn::Name key = ndn::Name(ROUTER_B_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
auto lsa = nlsr.m_lsdb.findAdjLsa(key);
BOOST_REQUIRE(lsa != nullptr);
- auto c = lsa->getAdl().findAdjacent(ROUTER_C_NAME);
+ auto c = lsa->m_adl.findAdjacent(ROUTER_C_NAME);
BOOST_REQUIRE(c != conf.getAdjacencyList().end());
// Break the link between B - C by setting it to a NON_ADJACENT_COST.
@@ -263,24 +263,24 @@
BOOST_AUTO_TEST_CASE(AsymmetricZeroCostLink)
{
// Asymmetric and zero link cost between B - C, and B - A.
- ndn::Name keyB = ndn::Name(ROUTER_B_NAME).append(std::to_string(Lsa::Type::ADJACENCY));
+ ndn::Name keyB = ndn::Name(ROUTER_B_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
auto lsaB = nlsr.m_lsdb.findAdjLsa(keyB);
BOOST_REQUIRE(lsaB != nullptr);
- auto c = lsaB->getAdl().findAdjacent(ROUTER_C_NAME);
+ auto c = lsaB->m_adl.findAdjacent(ROUTER_C_NAME);
BOOST_REQUIRE(c != conf.getAdjacencyList().end());
// Re-adjust link cost to 0 from B-C. However, this should not set B-C cost 0 because C-B
// cost is greater that 0 i.e. 17
c->setLinkCost(0);
- auto a = lsaB->getAdl().findAdjacent(ROUTER_A_NAME);
+ auto a = lsaB->m_adl.findAdjacent(ROUTER_A_NAME);
BOOST_REQUIRE(a != conf.getAdjacencyList().end());
- ndn::Name keyA = ndn::Name(ROUTER_A_NAME).append(std::to_string(Lsa::Type::ADJACENCY));
+ ndn::Name keyA = ndn::Name(ROUTER_A_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
auto lsaA = nlsr.m_lsdb.findAdjLsa(keyA);
BOOST_REQUIRE(lsaA != nullptr);
- auto b = lsaA->getAdl().findAdjacent(ROUTER_B_NAME);
+ auto b = lsaA->m_adl.findAdjacent(ROUTER_B_NAME);
BOOST_REQUIRE(b != conf.getAdjacencyList().end());
// Re-adjust link cost to 0 from both the direction i.e B-A and A-B
diff --git a/tests/test-lsa-rule.cpp b/tests/test-lsa-rule.cpp
index dffe174..00c0ded 100644
--- a/tests/test-lsa-rule.cpp
+++ b/tests/test-lsa-rule.cpp
@@ -119,7 +119,7 @@
lsaDataName.append(confParam.getRouterName());
// Append LSA type
- lsaDataName.append(std::to_string(Lsa::Type::NAME));
+ lsaDataName.append(boost::lexical_cast<std::string>(Lsa::Type::NAME));
// This would be the sequence number of its own NameLsa
lsaDataName.appendNumber(nlsr.m_lsdb.m_sequencingManager.getNameLsaSeq());
@@ -149,7 +149,7 @@
lsaDataName.append(confParam.getRouterName());
// Append LSA type
- lsaDataName.append(std::to_string(Lsa::Type::NAME));
+ lsaDataName.append(boost::lexical_cast<std::string>(Lsa::Type::NAME));
// This would be the sequence number of its own NameLsa
lsaDataName.appendNumber(nlsr.m_lsdb.m_sequencingManager.getNameLsaSeq());
diff --git a/tests/test-lsa-segment-storage.cpp b/tests/test-lsa-segment-storage.cpp
index 2881d88..7862e45 100644
--- a/tests/test-lsa-segment-storage.cpp
+++ b/tests/test-lsa-segment-storage.cpp
@@ -26,7 +26,7 @@
#include "test-common.hpp"
#include "nlsr.hpp"
#include "name-prefix-list.hpp"
-#include "lsa.hpp"
+// #include "lsa.hpp"
namespace nlsr {
namespace test {
@@ -68,9 +68,9 @@
npl1.insert("name1-" + std::to_string(i));
}
NameLsa nameLsa("/ndn/other-site/%C1.Router/other-router", 12,
- ndn::time::system_clock::now() + ndn::time::seconds(LSA_REFRESH_TIME_DEFAULT), npl1);
- segmentPublisher.publish(interestName, interestName,
- ndn::encoding::makeStringBlock(ndn::tlv::Content, nameLsa.serialize()),
+ ndn::time::system_clock::now() + ndn::time::seconds(LSA_REFRESH_TIME_DEFAULT),
+ npl1);
+ segmentPublisher.publish(interestName, interestName, nameLsa.wireEncode(),
ndn::time::seconds(LSA_REFRESH_TIME_DEFAULT));
}
diff --git a/tests/test-lsa.cpp b/tests/test-lsa.cpp
index 20fc1c1..fb08473 100644
--- a/tests/test-lsa.cpp
+++ b/tests/test-lsa.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -19,43 +19,162 @@
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
-#include "lsa.hpp"
+#include "lsa/name-lsa.hpp"
+#include "lsa/adj-lsa.hpp"
+#include "lsa/coordinate-lsa.hpp"
#include "test-common.hpp"
#include "adjacent.hpp"
#include "name-prefix-list.hpp"
#include <ndn-cxx/util/time.hpp>
-#include <sstream>
namespace nlsr {
namespace test {
+/*static void
+printBytes(const uint8_t* buf, size_t size)
+{
+ std::string hex = ndn::toHex(buf, size);
+
+ for (size_t i = 0; i < hex.size(); i++) {
+ if (i > 0 && i % 30 == 0)
+ std::cout << "\n ";
+
+ std::cout << "0x" << hex[i];
+ std::cout << hex[++i];
+
+ if ((i + 1) != hex.size())
+ std::cout << ", ";
+ }
+ std::cout << "\n" << "};" << std::endl;
+}
+
+printBytes(wire.wire(), wire.size());*/
+
BOOST_AUTO_TEST_SUITE(TestLsa)
+const uint8_t NAME_LSA1[] = {
+ 0x89, 0x37, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
+ 0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32
+};
+
+const uint8_t NAME_LSA_EXTRA_NAME[] = {
+ 0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
+ 0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
+ 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
+};
+
+const uint8_t NAME_LSA_DIFF_SEQ[] = {
+ 0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
+ 0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
+ 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
+};
+
+const uint8_t NAME_LSA_DIFF_TS[] = {
+ 0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x34, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
+ 0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
+ 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
+};
+
BOOST_AUTO_TEST_CASE(NameLsaBasic)
{
ndn::Name s1{"name1"};
ndn::Name s2{"name2"};
NamePrefixList npl1{s1, s2};
- ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
+ ndn::time::system_clock::TimePoint testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
- //3rd arg is seqNo. which will be a random number I just put in 12.
+ // 3rd argument is seqNo
NameLsa nlsa1("router1", 12, testTimePoint, npl1);
NameLsa nlsa2("router2", 12, testTimePoint, npl1);
BOOST_CHECK_EQUAL(nlsa1.getType(), Lsa::Type::NAME);
-
BOOST_CHECK(nlsa1.getExpirationTimePoint() == nlsa2.getExpirationTimePoint());
-
BOOST_CHECK(nlsa1.getKey() != nlsa2.getKey());
+
+ auto wire = nlsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA1, NAME_LSA1 + sizeof(NAME_LSA1),
+ wire.begin(), wire.end());
+
+ nlsa1.addName("name3");
+ wire = nlsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA_EXTRA_NAME,
+ NAME_LSA_EXTRA_NAME + sizeof(NAME_LSA_EXTRA_NAME),
+ wire.begin(), wire.end());
+
+ nlsa1.setSeqNo(14);
+ wire = nlsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA_DIFF_SEQ, NAME_LSA_DIFF_SEQ + sizeof(NAME_LSA_DIFF_SEQ),
+ wire.begin(), wire.end());
+
+ testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
+ nlsa1.setExpirationTimePoint(testTimePoint);
+ wire = nlsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA_DIFF_TS, NAME_LSA_DIFF_TS + sizeof(NAME_LSA_DIFF_TS),
+ wire.begin(), wire.end());
+ // Not testing router name as not sure if that will ever change once set
}
-BOOST_AUTO_TEST_CASE(AdjacentLsaConstructorAndGetters)
+const uint8_t ADJ_LSA1[] = {
+ 0x83, 0x58, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
+ 0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0C, 0x8B, 0x13,
+ 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
+ 0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
+ 0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
+ 0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t ADJ_LSA_EXTRA_NEIGHBOR[] = {
+ 0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
+ 0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0C, 0x8B, 0x13,
+ 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
+ 0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
+ 0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
+ 0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
+ 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
+ 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t ADJ_LSA_DIFF_SEQ[] = {
+ 0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
+ 0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0E, 0x8B, 0x13,
+ 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
+ 0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
+ 0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
+ 0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
+ 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
+ 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+const uint8_t ADJ_LSA_DIFF_TS[] = {
+ 0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
+ 0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0E, 0x8B, 0x13,
+ 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
+ 0x33, 0x3A, 0x34, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
+ 0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
+ 0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
+ 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
+ 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+BOOST_AUTO_TEST_CASE(AdjLsaBasic)
{
ndn::Name routerName("/ndn/site/router");
ndn::Name adjacencyName("/ndn/site/adjacency");
- ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
+ ndn::time::system_clock::TimePoint testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
uint32_t seqNo = 12;
// An AdjLsa initialized with ACTIVE adjacencies should copy the adjacencies
@@ -68,7 +187,7 @@
activeAdjacencies.size(), activeAdjacencies);
BOOST_CHECK_EQUAL(alsa1.getAdl().size(), 1);
BOOST_CHECK_EQUAL(alsa1.getType(), Lsa::Type::ADJACENCY);
- BOOST_CHECK_EQUAL(alsa1.getLsSeqNo(), seqNo);
+ BOOST_CHECK_EQUAL(alsa1.getSeqNo(), seqNo);
BOOST_CHECK_EQUAL(alsa1.getExpirationTimePoint(), testTimePoint);
BOOST_CHECK_EQUAL(alsa1.getNoLink(), 1);
BOOST_CHECK(alsa1.getAdl().isNeighbor(activeAdjacency.getName()));
@@ -90,12 +209,73 @@
AdjLsa alsa3(routerName, seqNo, testTimePoint,
activeAdjacencies.size(), activeAdjacencies);
BOOST_CHECK(alsa1.isEqualContent(alsa3));
+
+ auto wire = alsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA1, ADJ_LSA1 + sizeof(ADJ_LSA1),
+ wire.begin(), wire.end());
+
+ Adjacent activeAdjacency2("/ndn/edu/adjacency");
+ activeAdjacency2.setStatus(Adjacent::STATUS_ACTIVE);
+ alsa1.addAdjacent(activeAdjacency2);
+ wire = alsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA_EXTRA_NEIGHBOR,
+ ADJ_LSA_EXTRA_NEIGHBOR + sizeof(ADJ_LSA_EXTRA_NEIGHBOR),
+ wire.begin(), wire.end());
+
+ alsa1.setSeqNo(14);
+ wire = alsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA_DIFF_SEQ, ADJ_LSA_DIFF_SEQ + sizeof(ADJ_LSA_DIFF_SEQ),
+ wire.begin(), wire.end());
+
+ testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
+ alsa1.setExpirationTimePoint(testTimePoint);
+ wire = alsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA_DIFF_TS, ADJ_LSA_DIFF_TS + sizeof(ADJ_LSA_DIFF_TS),
+ wire.begin(), wire.end());
}
-BOOST_AUTO_TEST_CASE(CoordinateLsaConstructorAndGetters)
+const uint8_t COORDINATE_LSA1[] = {
+ 0x85, 0x43, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x04, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x88, 0x08, 0x40, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88,
+ 0x08, 0x40, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t COORDINATE_LSA_DIFF_ANGLE[] = {
+ 0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x04, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t COORDINATE_LSA_DIFF_RADIUS[] = {
+ 0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t COORDINATE_LSA_DIFF_SEQ[] = {
+ 0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t COORDINATE_LSA_DIFF_TS[] = {
+ 0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x34, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+BOOST_AUTO_TEST_CASE(CoordinateLsaBasic)
{
- ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
- std::vector<double> angles1, angles2;
+ ndn::time::system_clock::TimePoint testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
+ std::vector<double> angles1 {30.0}, angles2 {30.0};
angles1.push_back(30.0);
angles2.push_back(30.0);
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles1);
@@ -106,7 +286,38 @@
BOOST_CHECK(clsa1.isEqualContent(clsa2));
- BOOST_CHECK_EQUAL(clsa1.serialize(), clsa2.serialize());
+ BOOST_CHECK_EQUAL(clsa1.wireEncode(), clsa2.wireEncode());
+
+ auto wire = clsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA1, COORDINATE_LSA1 + sizeof(COORDINATE_LSA1),
+ wire.begin(), wire.end());
+
+ std::vector<double> angles3{40.0};
+ clsa1.setCorTheta(angles3);
+ wire = clsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_ANGLE,
+ COORDINATE_LSA_DIFF_ANGLE + sizeof(COORDINATE_LSA_DIFF_ANGLE),
+ wire.begin(), wire.end());
+
+ clsa1.setCorRadius(2.3);
+ wire = clsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_RADIUS,
+ COORDINATE_LSA_DIFF_RADIUS + sizeof(COORDINATE_LSA_DIFF_RADIUS),
+ wire.begin(), wire.end());
+
+ clsa1.setSeqNo(14);
+ wire = clsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_SEQ,
+ COORDINATE_LSA_DIFF_SEQ + sizeof(COORDINATE_LSA_DIFF_SEQ),
+ wire.begin(), wire.end());
+
+ testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
+ clsa1.setExpirationTimePoint(testTimePoint);
+ wire = clsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_TS,
+ COORDINATE_LSA_DIFF_TS + sizeof(COORDINATE_LSA_DIFF_TS),
+ wire.begin(), wire.end());
}
BOOST_AUTO_TEST_CASE(IncrementAdjacentNumber)
@@ -121,7 +332,7 @@
adjList.insert(adj1);
adjList.insert(adj2);
- ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
+ ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now() + ndn::time::seconds(3600);
std::ostringstream ss;
ss << testTimePoint;
@@ -130,19 +341,13 @@
AdjLsa lsa("router1", 12, testTimePoint, adjList.size(), adjList);
std::string EXPECTED_OUTPUT =
- "LSA of type ADJACENCY:\n"
- "-Origin Router: /router1\n"
- "-Sequence Number: 12\n"
- "-Expiration Point: " + TEST_TIME_POINT_STRING + "\n"
- "-Adjacents:--Adjacent1:\n"
- "---Adjacent Name: /adjacent1\n"
- "---Connecting FaceUri: ://\n"
- "---Link Cost: 10\n"
- "--Adjacent2:\n"
- "---Adjacent Name: /adjacent2\n"
- "---Connecting FaceUri: ://\n"
- "---Link Cost: 10\n"
- "adj_lsa_end";
+ " ADJACENCY LSA:\n"
+ " Origin Router : /router1\n"
+ " Sequence Number : 12\n"
+ " Expires in : 3599999 milliseconds\n"
+ " Adjacents:\n"
+ " Adjacent 0: (name=/adjacent1, uri=://, cost=10)\n"
+ " Adjacent 1: (name=/adjacent2, uri=://, cost=10)\n";
std::ostringstream os;
os << lsa;
@@ -172,10 +377,7 @@
ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
AdjLsa adjlsa1("router1", 1, testTimePoint, adjList.size(), adjList);
- AdjLsa adjlsa2;
-
- BOOST_CHECK(adjlsa2.deserialize(adjlsa1.serialize()));
-
+ AdjLsa adjlsa2(adjlsa1.wireEncode());
BOOST_CHECK(adjlsa1.isEqualContent(adjlsa2));
//Name LSA
@@ -184,24 +386,16 @@
NamePrefixList npl1{s1, s2};
NameLsa nlsa1("router1", 1, testTimePoint, npl1);
- NameLsa nlsa2;
-
- BOOST_CHECK(nlsa2.deserialize(nlsa1.serialize()));
-
- BOOST_CHECK_EQUAL(nlsa1.serialize(), nlsa2.serialize());
+ NameLsa nlsa2(nlsa1.wireEncode());
+ BOOST_CHECK_EQUAL(nlsa1.wireEncode(), nlsa2.wireEncode());
//Coordinate LSA
std::vector<double> angles = {30, 40.0};
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles);
- CoordinateLsa clsa2;
-
- BOOST_CHECK(clsa2.deserialize(clsa1.serialize()));
-
- BOOST_CHECK_EQUAL(clsa1.serialize(), clsa2.serialize());
+ CoordinateLsa clsa2(clsa1.wireEncode());
+ BOOST_CHECK_EQUAL(clsa1.wireEncode(), clsa2.wireEncode());
}
-BOOST_AUTO_TEST_SUITE(TestNameLsa)
-
BOOST_AUTO_TEST_CASE(OperatorEquals)
{
NameLsa lsa1;
@@ -221,8 +415,6 @@
BOOST_CHECK(lsa1.isEqualContent(lsa2));
}
-BOOST_AUTO_TEST_SUITE_END() // TestNameLsa
-
BOOST_AUTO_TEST_SUITE_END()
} // namespace test
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 56e862b..9ed1f26 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -23,7 +23,7 @@
#include "test-common.hpp"
#include "nlsr.hpp"
-#include "lsa.hpp"
+#include "lsa/lsa.hpp"
#include "name-prefix-list.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
@@ -175,12 +175,13 @@
ndn::Name lsaKey("/ndn/site/%C1.Router/this-router/NAME");
NameLsa* nameLsa = lsdb.findNameLsa(lsaKey);
- uint64_t seqNo = nameLsa->getLsSeqNo();
+ BOOST_REQUIRE(nameLsa != nullptr);
+ uint64_t seqNo = nameLsa->getSeqNo();
ndn::Name prefix("/ndn/edu/memphis/netlab/research/nlsr/test/prefix/");
int nPrefixes = 0;
- while (nameLsa->serialize().size() < ndn::MAX_NDN_PACKET_SIZE) {
+ while (nameLsa->wireEncode().size() < ndn::MAX_NDN_PACKET_SIZE) {
nameLsa->addName(ndn::Name(prefix).appendNumber(++nPrefixes));
break;
}
@@ -218,17 +219,17 @@
ndn::Name lsaKey("/ndn/site/%C1.Router/this-router/NAME");
NameLsa* lsa = lsdb.findNameLsa(lsaKey);
- uint64_t seqNo = lsa->getLsSeqNo();
+ uint64_t seqNo = lsa->getSeqNo();
ndn::Name prefix("/ndn/edu/memphis/netlab/research/nlsr/test/prefix/");
int nPrefixes = 0;
- while (lsa->serialize().size() < ndn::MAX_NDN_PACKET_SIZE) {
+ while (lsa->wireEncode().size() < ndn::MAX_NDN_PACKET_SIZE) {
lsa->addName(ndn::Name(prefix).appendNumber(++nPrefixes));
}
lsdb.installNameLsa(*lsa);
- std::string expectedDataContent = lsa->serialize();
+ ndn::Block expectedDataContent = lsa->wireEncode();
ndn::Name interestName("/localhop/ndn/nlsr/LSA/site/%C1.Router/this-router/NAME/");
interestName.appendNumber(seqNo);
@@ -240,7 +241,7 @@
ndn::security::v2::getAcceptAllValidator());
fetcher->onComplete.connect([&expectedDataContent] (ndn::ConstBufferPtr bufferPtr) {
ndn::Block block(bufferPtr);
- BOOST_CHECK_EQUAL(expectedDataContent, readString(block));
+ BOOST_CHECK_EQUAL(expectedDataContent, block);
});
advanceClocks(ndn::time::milliseconds(1), 100);
@@ -264,13 +265,13 @@
ndn::Name interestName("/localhop/ndn/nlsr/LSA/cs/%C1.Router/router1/NAME/");
interestName.appendNumber(seqNo);
- ndn::Block block = ndn::encoding::makeStringBlock(ndn::tlv::Content, lsa.serialize());
+ ndn::Block block = lsa.wireEncode();
lsdb.afterFetchLsa(block.getBuffer(), interestName);
NameLsa* foundLsa = lsdb.findNameLsa(lsa.getKey());
BOOST_REQUIRE(foundLsa != nullptr);
- BOOST_CHECK_EQUAL(foundLsa->serialize(), lsa.serialize());
+ BOOST_CHECK_EQUAL(foundLsa->wireEncode(), lsa.wireEncode());
}
BOOST_AUTO_TEST_CASE(LsdbRemoveAndExists)
diff --git a/tests/test-name-prefix-list.cpp b/tests/test-name-prefix-list.cpp
index 3bb93b7..687d6c3 100644
--- a/tests/test-name-prefix-list.cpp
+++ b/tests/test-name-prefix-list.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2019, The University of Memphis,
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
diff --git a/tests/test-nlsr.cpp b/tests/test-nlsr.cpp
index ab69692..ab5fd15 100644
--- a/tests/test-nlsr.cpp
+++ b/tests/test-nlsr.cpp
@@ -142,7 +142,7 @@
Adjacent neighbor("/ndn/neighborA", ndn::FaceUri(faceUri), 10,
Adjacent::STATUS_INACTIVE, 0, 0);
- BOOST_REQUIRE_EQUAL(conf.getAdjacencyList().insert(neighbor), 0);
+ BOOST_REQUIRE_EQUAL(conf.getAdjacencyList().insert(neighbor), true);
this->advanceClocks(10_ms);
@@ -306,11 +306,11 @@
// Make sure an adjacency LSA was built
ndn::Name key = ndn::Name(conf.getRouterPrefix())
- .append(std::to_string(Lsa::Type::ADJACENCY));
+ .append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
AdjLsa* lsa = lsdb.findAdjLsa(key);
BOOST_REQUIRE(lsa != nullptr);
- uint32_t lastAdjLsaSeqNo = lsa->getLsSeqNo();
+ uint32_t lastAdjLsaSeqNo = lsa->getSeqNo();
nlsr.m_lsdb.m_sequencingManager.setAdjLsaSeq(lastAdjLsaSeqNo);
this->advanceClocks(1500_ms, 10);
@@ -345,7 +345,7 @@
lsa = lsdb.findAdjLsa(key);
BOOST_REQUIRE(lsa != nullptr);
- BOOST_CHECK_EQUAL(lsa->getLsSeqNo(), lastAdjLsaSeqNo + 1);
+ BOOST_CHECK_EQUAL(lsa->getSeqNo(), lastAdjLsaSeqNo + 1);
this->advanceClocks(15_s, 10);
@@ -381,7 +381,7 @@
receiveHelloData(neighborAName, conf.getRouterPrefix());
this->advanceClocks(1_s, 10);
- ndn::Name lsaKey = ndn::Name(conf.getRouterPrefix()).append(std::to_string(Lsa::Type::ADJACENCY));
+ ndn::Name lsaKey = ndn::Name(conf.getRouterPrefix()).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
// Adjacency LSA should be built even though other router is INACTIVE
AdjLsa* lsa = lsdb.findAdjLsa(lsaKey);
diff --git a/tests/test-sequencing-manager.cpp b/tests/test-sequencing-manager.cpp
index 6bbcb00..218952a 100644
--- a/tests/test-sequencing-manager.cpp
+++ b/tests/test-sequencing-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2019, The University of Memphis,
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
diff --git a/tests/test-statistics.cpp b/tests/test-statistics.cpp
index 0dbe274..cfd82b6 100644
--- a/tests/test-statistics.cpp
+++ b/tests/test-statistics.cpp
@@ -198,16 +198,16 @@
uint32_t seqNo = 1;
// Adjacency LSA
- sendInterestAndCheckStats(interestPrefix, std::to_string(Lsa::Type::ADJACENCY), seqNo,
- Statistics::PacketType::SENT_ADJ_LSA_INTEREST);
+ sendInterestAndCheckStats(interestPrefix, boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY),
+ seqNo, Statistics::PacketType::SENT_ADJ_LSA_INTEREST);
// Coordinate LSA
- sendInterestAndCheckStats(interestPrefix, std::to_string(Lsa::Type::COORDINATE), seqNo,
- Statistics::PacketType::SENT_COORD_LSA_INTEREST);
+ sendInterestAndCheckStats(interestPrefix, boost::lexical_cast<std::string>(Lsa::Type::COORDINATE),
+ seqNo, Statistics::PacketType::SENT_COORD_LSA_INTEREST);
// Name LSA
- sendInterestAndCheckStats(interestPrefix, std::to_string(Lsa::Type::NAME), seqNo,
- Statistics::PacketType::SENT_NAME_LSA_INTEREST);
+ sendInterestAndCheckStats(interestPrefix, boost::lexical_cast<std::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);
@@ -226,10 +226,10 @@
lsdb.buildAndInstallOwnAdjLsa();
ndn::Name adjLsaKey = conf.getRouterPrefix();
- adjLsaKey.append(std::to_string(Lsa::Type::ADJACENCY));
+ adjLsaKey.append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
AdjLsa* adjLsa = lsdb.findAdjLsa(adjLsaKey);
- uint32_t seqNo = adjLsa->getLsSeqNo();
+ uint32_t seqNo = adjLsa->getSeqNo();
Adjacent adjacency("adjacency");
adjacency.setStatus(Adjacent::STATUS_ACTIVE);
@@ -242,26 +242,26 @@
// Receive Adjacency LSA Interest
receiveInterestAndCheckSentStats(interestPrefix,
- std::to_string(Lsa::Type::ADJACENCY),
+ boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY),
seqNo,
Statistics::PacketType::RCV_ADJ_LSA_INTEREST,
Statistics::PacketType::SENT_ADJ_LSA_DATA);
// Name LSA
ndn::Name nameLsaKey = conf.getRouterPrefix();
- nameLsaKey.append(std::to_string(Lsa::Type::NAME));
+ nameLsaKey.append(boost::lexical_cast<std::string>(Lsa::Type::NAME));
NameLsa* nameLsa = lsdb.findNameLsa(nameLsaKey);
BOOST_ASSERT(nameLsa != nullptr);
- seqNo = nameLsa->getLsSeqNo();
+ seqNo = nameLsa->getSeqNo();
nameLsa->addName(ndn::Name("/ndn/name"));
lsdb.installNameLsa(*nameLsa);
// Receive Name LSA Interest
receiveInterestAndCheckSentStats(interestPrefix,
- std::to_string(Lsa::Type::NAME),
+ boost::lexical_cast<std::string>(Lsa::Type::NAME),
seqNo,
Statistics::PacketType::RCV_NAME_LSA_INTEREST,
Statistics::PacketType::SENT_NAME_LSA_DATA);
@@ -269,16 +269,16 @@
// // Coordinate LSA
lsdb.buildAndInstallOwnCoordinateLsa();
ndn::Name coorLsaKey = conf.getRouterPrefix();
- coorLsaKey.append(std::to_string(Lsa::Type::COORDINATE));
+ coorLsaKey.append(boost::lexical_cast<std::string>(Lsa::Type::COORDINATE));
CoordinateLsa* coorLsa = lsdb.findCoordinateLsa(coorLsaKey);
- seqNo = coorLsa->getLsSeqNo();
+ seqNo = coorLsa->getSeqNo();
coorLsa->setCorTheta({20.0, 30.0});
lsdb.installCoordinateLsa(*coorLsa);
// Receive Adjacency LSA Interest
receiveInterestAndCheckSentStats(interestPrefix,
- std::to_string(Lsa::Type::COORDINATE),
+ boost::lexical_cast<std::string>(Lsa::Type::COORDINATE),
seqNo,
Statistics::PacketType::RCV_COORD_LSA_INTEREST,
Statistics::PacketType::SENT_COORD_LSA_DATA);
@@ -306,9 +306,7 @@
AdjLsa aLsa(routerName, seqNo, MAX_TIME, 1, conf.getAdjacencyList());
lsdb.installAdjLsa(aLsa);
- ndn::Block block = ndn::encoding::makeStringBlock(ndn::tlv::Content, aLsa.serialize());
-
- lsdb.afterFetchLsa(block.getBuffer(), adjInterest);
+ lsdb.afterFetchLsa(aLsa.wireEncode().getBuffer(), adjInterest);
BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::RCV_ADJ_LSA_DATA), 1);
// coordinate lsa
@@ -318,20 +316,16 @@
CoordinateLsa cLsa(routerName, seqNo, MAX_TIME, 2.5, angles);
lsdb.installCoordinateLsa(cLsa);
- block = ndn::encoding::makeStringBlock(ndn::tlv::Content, cLsa.serialize());
-
- lsdb.afterFetchLsa(block.getBuffer(), coordInterest);
+ lsdb.afterFetchLsa(cLsa.wireEncode().getBuffer(), coordInterest);
BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::RCV_COORD_LSA_DATA), 1);
// name lsa
ndn::Name interestName("/localhop/ndn/nlsr/LSA/cs/%C1.Router/router1/NAME/");
interestName.appendNumber(seqNo);
- NameLsa nLsa(routerName, seqNo, MAX_TIME, conf.getNamePrefixList());
- lsdb.installNameLsa(nLsa);
+ NameLsa nlsa(routerName, seqNo, MAX_TIME, conf.getNamePrefixList());
+ lsdb.installNameLsa(nlsa);
- block = ndn::encoding::makeStringBlock(ndn::tlv::Content, nLsa.serialize());
-
- lsdb.afterFetchLsa(block.getBuffer(), interestName);
+ lsdb.afterFetchLsa(nlsa.wireEncode().getBuffer(), interestName);
BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::RCV_NAME_LSA_DATA), 1);
// 3 lsa data types should be received
diff --git a/tests/tlv/test-adjacency-lsa.cpp b/tests/tlv/test-adjacency-lsa.cpp
deleted file mode 100644
index 531e1a4..0000000
--- a/tests/tlv/test-adjacency-lsa.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019, The University of Memphis,
- * Regents of the University of California,
- * Arizona Board of Regents.
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "tlv/adjacency-lsa.hpp"
-
-#include "tests/boost-test.hpp"
-
-namespace nlsr {
-namespace tlv {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TlvTestAdjacencyLsa)
-
-const uint8_t AdjacencyLsaWithAdjacenciesData[] =
-{
- // Header
- 0x83, 0x3d,
- // LsaInfo
- 0x80, 0x11, 0x81, 0x08, 0x07, 0x06, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x82, 0x01,
- 0x80, 0x8b, 0x02, 0x27, 0x10,
- // Adjacency
- 0x84, 0x13, 0x07, 0x07, 0x08, 0x05, 0x74, 0x65, 0x73, 0x74, 0x31, 0x8d, 0x05, 0x74,
- 0x65, 0x73, 0x74, 0x31, 0x8c, 0x01, 0x80,
- // Adjacency
- 0x84, 0x13, 0x07, 0x07, 0x08, 0x05, 0x74, 0x65, 0x73, 0x74, 0x32, 0x8d, 0x05, 0x74,
- 0x65, 0x73, 0x74, 0x32, 0x8c, 0x01, 0x80
-};
-
-const uint8_t AdjacencyLsaWithoutAdjacenciesData[] =
-{
- // Header
- 0x83, 0x13,
- // LsaInfo
- 0x80, 0x11, 0x81, 0x08, 0x07, 0x06, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x82, 0x01,
- 0x80, 0x8b, 0x02, 0x27, 0x10
-};
-
-BOOST_AUTO_TEST_CASE(AdjacencyLsaEncodeWithAdjacencies)
-{
- AdjacencyLsa adjacencyLsa;
-
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("test");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
- adjacencyLsa.setLsaInfo(lsaInfo);
-
- Adjacency adjacency1;
- adjacency1.setName("test1");
- adjacency1.setUri("test1");
- adjacency1.setCost(128);
- adjacencyLsa.addAdjacency(adjacency1);
-
- Adjacency adjacency2;
- adjacency2.setName("test2");
- adjacency2.setUri("test2");
- adjacency2.setCost(128);
- adjacencyLsa.addAdjacency(adjacency2);
-
- const ndn::Block& wire = adjacencyLsa.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(AdjacencyLsaWithAdjacenciesData,
- AdjacencyLsaWithAdjacenciesData +
- sizeof(AdjacencyLsaWithAdjacenciesData),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(AdjacencyLsaDecodeWithAdjacencies)
-{
- AdjacencyLsa adjacencyLsa;
-
- adjacencyLsa.wireDecode(ndn::Block(AdjacencyLsaWithAdjacenciesData,
- sizeof(AdjacencyLsaWithAdjacenciesData)));
-
- LsaInfo lsaInfo = adjacencyLsa.getLsaInfo();
- BOOST_CHECK_EQUAL(lsaInfo.getOriginRouter(), "test");
- BOOST_CHECK_EQUAL(lsaInfo.getSequenceNumber(), 128);
- BOOST_CHECK_EQUAL(lsaInfo.getExpirationPeriod(), ndn::time::milliseconds(10000));
-
- BOOST_CHECK_EQUAL(adjacencyLsa.hasAdjacencies(), true);
- std::list<Adjacency> adjacencies = adjacencyLsa.getAdjacencies();
- std::list<Adjacency>::const_iterator it = adjacencies.begin();
- BOOST_CHECK_EQUAL(it->getName(), "test1");
- BOOST_CHECK_EQUAL(it->getUri(), "test1");
- BOOST_CHECK_EQUAL(it->getCost(), 128);
-
- it++;
- BOOST_CHECK_EQUAL(it->getName(), "test2");
- BOOST_CHECK_EQUAL(it->getUri(), "test2");
- BOOST_CHECK_EQUAL(it->getCost(), 128);
-}
-
-BOOST_AUTO_TEST_CASE(AdjacencyLsaEncodeWithoutAdjacencies)
-{
- AdjacencyLsa adjacencyLsa;
-
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("test");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
- adjacencyLsa.setLsaInfo(lsaInfo);
-
- const ndn::Block& wire = adjacencyLsa.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(AdjacencyLsaWithoutAdjacenciesData,
- AdjacencyLsaWithoutAdjacenciesData +
- sizeof(AdjacencyLsaWithoutAdjacenciesData),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(AdjacencyLsaDecodeWithoutAdjacencies)
-{
- AdjacencyLsa adjacencyLsa;
-
- adjacencyLsa.wireDecode(ndn::Block(AdjacencyLsaWithoutAdjacenciesData,
- sizeof(AdjacencyLsaWithoutAdjacenciesData)));
-
- LsaInfo lsaInfo = adjacencyLsa.getLsaInfo();
- BOOST_CHECK_EQUAL(lsaInfo.getOriginRouter(), "test");
- BOOST_CHECK_EQUAL(lsaInfo.getSequenceNumber(), 128);
- BOOST_CHECK_EQUAL(lsaInfo.getExpirationPeriod(), ndn::time::milliseconds(10000));
-
- BOOST_CHECK_EQUAL(adjacencyLsa.hasAdjacencies(), false);
-}
-
-
-BOOST_AUTO_TEST_CASE(AdjacencyLsaClear)
-{
- AdjacencyLsa adjacencyLsa;
-
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("test");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
- adjacencyLsa.setLsaInfo(lsaInfo);
-
- Adjacency adjacency1;
- adjacency1.setName("test1");
- adjacency1.setUri("test1");
- adjacency1.setCost(128);
- adjacencyLsa.addAdjacency(adjacency1);
- BOOST_CHECK_EQUAL(adjacencyLsa.getAdjacencies().size(), 1);
-
- std::list<Adjacency> adjacencies = adjacencyLsa.getAdjacencies();
- std::list<Adjacency>::const_iterator it = adjacencies.begin();
- BOOST_CHECK_EQUAL(it->getName(), "test1");
- BOOST_CHECK_EQUAL(it->getUri(), "test1");
- BOOST_CHECK_EQUAL(it->getCost(), 128);
-
- adjacencyLsa.clearAdjacencies();
- BOOST_CHECK_EQUAL(adjacencyLsa.getAdjacencies().size(), 0);
-
- Adjacency adjacency2;
- adjacency2.setName("test2");
- adjacency2.setUri("test2");
- adjacency2.setCost(128);
- adjacencyLsa.addAdjacency(adjacency2);
- BOOST_CHECK_EQUAL(adjacencyLsa.getAdjacencies().size(), 1);
-
- adjacencies = adjacencyLsa.getAdjacencies();
- it = adjacencies.begin();
- BOOST_CHECK_EQUAL(it->getName(), "test2");
- BOOST_CHECK_EQUAL(it->getUri(), "test2");
- BOOST_CHECK_EQUAL(it->getCost(), 128);
-}
-
-BOOST_AUTO_TEST_CASE(AdjacencyLsaOutputStream)
-{
- AdjacencyLsa adjacencyLsa;
-
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("test");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
- adjacencyLsa.setLsaInfo(lsaInfo);
-
- Adjacency adjacency1;
- adjacency1.setName("test1");
- adjacency1.setUri("test1");
- adjacency1.setCost(128);
- adjacencyLsa.addAdjacency(adjacency1);
-
- Adjacency adjacency2;
- adjacency2.setName("test2");
- adjacency2.setUri("test2");
- adjacency2.setCost(128);
- adjacencyLsa.addAdjacency(adjacency2);
-
- std::ostringstream os;
- os << adjacencyLsa;
-
- BOOST_CHECK_EQUAL(os.str(), "AdjacencyLsa("
- "LsaInfo("
- "OriginRouter: /test, "
- "SequenceNumber: 128, "
- "ExpirationPeriod: 10000 milliseconds), "
- "Adjacency(Name: /test1, Uri: test1, Cost: 128), "
- "Adjacency(Name: /test2, Uri: test2, Cost: 128))");
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace tlv
-} // namespace nlsr
diff --git a/tests/tlv/test-adjacency.cpp b/tests/tlv/test-adjacency.cpp
deleted file mode 100644
index 6e3b754..0000000
--- a/tests/tlv/test-adjacency.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019, The University of Memphis,
- * Regents of the University of California,
- * Arizona Board of Regents.
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "tlv/adjacency.hpp"
-
-#include "tests/boost-test.hpp"
-
-namespace nlsr {
-namespace tlv {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TlvTestAdjacency)
-
-const uint8_t AdjacencyData[] =
-{
- // Header
- 0x84, 0x30,
- // Name
- 0x07, 0x16, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x09, 0x61, 0x64, 0x6a, 0x61,
- 0x63, 0x65, 0x6e, 0x63, 0x79, 0x08, 0x03, 0x74, 0x6c, 0x76,
- // Uri
- 0x8d, 0x13, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x61, 0x64, 0x6a, 0x61, 0x63, 0x65,
- 0x6e, 0x63, 0x79, 0x2f, 0x74, 0x6c, 0x76,
- // Cost
- 0x8c, 0x01, 0x80
-};
-
-BOOST_AUTO_TEST_CASE(AdjacencyEncode)
-{
- Adjacency adjacency;
- adjacency.setName("/test/adjacency/tlv");
- adjacency.setUri("/test/adjacency/tlv");
- adjacency.setCost(128);
-
- const ndn::Block& wire = adjacency.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(AdjacencyData,
- AdjacencyData + sizeof(AdjacencyData),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(AdjacencyDecode)
-{
- Adjacency adjacency;
-
- adjacency.wireDecode(ndn::Block(AdjacencyData, sizeof(AdjacencyData)));
-
- ndn::Name name("/test/adjacency/tlv");
- BOOST_REQUIRE_EQUAL(adjacency.getName(), name);
- BOOST_REQUIRE_EQUAL(adjacency.getUri(), "/test/adjacency/tlv");
- BOOST_REQUIRE_EQUAL(adjacency.getCost(), 128);
-}
-
-BOOST_AUTO_TEST_CASE(AdjacencyOutputStream)
-{
- Adjacency adjacency;
- adjacency.setName("/test/adjacency/tlv");
- adjacency.setUri("/test/adjacency/tlv");
- adjacency.setCost(128);
-
- std::ostringstream os;
- os << adjacency;
-
- BOOST_CHECK_EQUAL(os.str(), "Adjacency(Name: /test/adjacency/tlv, "
- "Uri: /test/adjacency/tlv, "
- "Cost: 128)");
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace tlv
-} // namespace nlsr
diff --git a/tests/tlv/test-coordinate-lsa.cpp b/tests/tlv/test-coordinate-lsa.cpp
deleted file mode 100644
index 225c708..0000000
--- a/tests/tlv/test-coordinate-lsa.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019, The University of Memphis,
- * Regents of the University of California,
- * Arizona Board of Regents.
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "tlv/coordinate-lsa.hpp"
-
-#include "tests/boost-test.hpp"
-
-namespace nlsr {
-namespace tlv {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TlvTestCoordinateLsa)
-
-const uint8_t CoordinateLsaData[] =
-{
- // Header
- 0x85, 0x27,
- // LsaInfo
- 0x80, 0x11, 0x81, 0x08, 0x07, 0x06, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x82, 0x01,
- 0x80, 0x8b, 0x02, 0x27, 0x10,
- // HyperbolicRadius
- 0x87, 0x08, 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
- // HyperbolicAngle
- 0x88, 0x08, 0x3f, 0xfc, 0x7a, 0xe1, 0x47, 0xae, 0x14, 0x7b
-
-};
-
-BOOST_AUTO_TEST_CASE(CoordinateLsaEncode)
-{
- CoordinateLsa coordinateLsa;
-
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("test");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
- coordinateLsa.setLsaInfo(lsaInfo);
-
- coordinateLsa.setHyperbolicRadius(1.65);
- std::vector<double> angles;
- angles.push_back(1.78);
- coordinateLsa.setHyperbolicAngle(angles);
-
- const ndn::Block& wire = coordinateLsa.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(CoordinateLsaData,
- CoordinateLsaData + sizeof(CoordinateLsaData),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(CoordinateLsaDecode)
-{
- CoordinateLsa coordinateLsa;
-
- coordinateLsa.wireDecode(ndn::Block(CoordinateLsaData, sizeof(CoordinateLsaData)));
-
- BOOST_REQUIRE_EQUAL(coordinateLsa.getLsaInfo().getOriginRouter(), "test");
- BOOST_REQUIRE_EQUAL(coordinateLsa.getLsaInfo().getSequenceNumber(), 128);
- BOOST_REQUIRE_EQUAL(coordinateLsa.getLsaInfo().getExpirationPeriod(),
- ndn::time::milliseconds(10000));
- BOOST_REQUIRE_EQUAL(coordinateLsa.getHyperbolicRadius(), 1.65);
- std::vector<double> angles = {1.78};
- BOOST_REQUIRE(coordinateLsa.getHyperbolicAngle() == angles);
-}
-
-BOOST_AUTO_TEST_CASE(CoordinateLsaOutputStream)
-{
- CoordinateLsa coordinateLsa;
-
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("test");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
- coordinateLsa.setLsaInfo(lsaInfo);
-
- coordinateLsa.setHyperbolicRadius(1.65);
- std::vector<double> angles = {1.78};
- coordinateLsa.setHyperbolicAngle(angles);
-
- std::ostringstream os;
- os << coordinateLsa;
-
- BOOST_CHECK_EQUAL(os.str(), "CoordinateLsa("
- "LsaInfo(OriginRouter: /test, "
- "SequenceNumber: 128, "
- "ExpirationPeriod: 10000 milliseconds), "
- "HyperbolicRadius: 1.65, "
- "HyperbolicAngles: 1.78)");
-
- angles.push_back(3.21);
- coordinateLsa.setHyperbolicAngle(angles);
-
- std::ostringstream os2;
- os2 << coordinateLsa;
-
- BOOST_CHECK_EQUAL(os2.str(), "CoordinateLsa("
- "LsaInfo(OriginRouter: /test, "
- "SequenceNumber: 128, "
- "ExpirationPeriod: 10000 milliseconds), "
- "HyperbolicRadius: 1.65, "
- "HyperbolicAngles: 1.78, 3.21)");
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace tlv
-} // namespace nlsr
diff --git a/tests/tlv/test-destination.cpp b/tests/tlv/test-destination.cpp
index 8e2d177..adc153e 100644
--- a/tests/tlv/test-destination.cpp
+++ b/tests/tlv/test-destination.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2019, The University of Memphis,
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
diff --git a/tests/tlv/test-lsa-info.cpp b/tests/tlv/test-lsa-info.cpp
deleted file mode 100644
index 46157a5..0000000
--- a/tests/tlv/test-lsa-info.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019, The University of Memphis,
- * Regents of the University of California,
- * Arizona Board of Regents.
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "tlv/lsa-info.hpp"
-
-#include "tests/boost-test.hpp"
-#include "tests/mocks/lsa.hpp"
-
-namespace nlsr {
-namespace tlv {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TlvTestLsaInfo)
-
-const uint8_t LsaInfoData[] =
-{
- // Header
- 0x80, 0x21,
- // OriginRouter
- 0x81, 0x18, 0x07, 0x16, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6c, 0x73,
- 0x61, 0x08, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x08, 0x03, 0x74, 0x6c, 0x76,
- // SequenceNumber
- 0x82, 0x01, 0x80,
- // ExpirationPeriod
- 0x8b, 0x02, 0x27, 0x10
-};
-
-const uint8_t LsaInfoDataInfiniteExpirationPeriod[] =
-{
- // Header
- 0x80, 0x1d,
- // OriginRouter
- 0x81, 0x18, 0x07, 0x16, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6c, 0x73,
- 0x61, 0x08, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x08, 0x03, 0x74, 0x6c, 0x76,
- // SequenceNumber
- 0x82, 0x1, 0x80
-};
-
-BOOST_AUTO_TEST_CASE(LsaInfoEncode)
-{
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("/test/lsa/info/tlv");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
-
- const ndn::Block& wire = lsaInfo.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(LsaInfoData,
- LsaInfoData + sizeof(LsaInfoData),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(LsaInfoDecode)
-{
- LsaInfo lsaInfo;
-
- lsaInfo.wireDecode(ndn::Block(LsaInfoData, sizeof(LsaInfoData)));
-
- ndn::Name originRouter("/test/lsa/info/tlv");
- BOOST_REQUIRE_EQUAL(lsaInfo.getOriginRouter(), originRouter);
- BOOST_REQUIRE_EQUAL(lsaInfo.getSequenceNumber(), 128);
- BOOST_REQUIRE_EQUAL(lsaInfo.getExpirationPeriod(), ndn::time::milliseconds(10000));
- BOOST_REQUIRE_EQUAL(lsaInfo.hasInfiniteExpirationPeriod(), false);
-}
-
-BOOST_AUTO_TEST_CASE(LsaInfoInfiniteExpirationPeriodEncode)
-{
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("/test/lsa/info/tlv");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(LsaInfo::INFINITE_EXPIRATION_PERIOD);
-
- const ndn::Block& wire = lsaInfo.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(LsaInfoDataInfiniteExpirationPeriod,
- LsaInfoDataInfiniteExpirationPeriod +
- sizeof(LsaInfoDataInfiniteExpirationPeriod),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(LsaInfoInfiniteExpirationPeriodDecode)
-{
- LsaInfo lsaInfo;
-
- lsaInfo.wireDecode(ndn::Block(LsaInfoDataInfiniteExpirationPeriod,
- sizeof(LsaInfoDataInfiniteExpirationPeriod)));
-
- ndn::Name originRouter("/test/lsa/info/tlv");
- BOOST_REQUIRE_EQUAL(lsaInfo.getOriginRouter(), originRouter);
- BOOST_REQUIRE_EQUAL(lsaInfo.getSequenceNumber(), 128);
- BOOST_REQUIRE_EQUAL(lsaInfo.getExpirationPeriod(), LsaInfo::INFINITE_EXPIRATION_PERIOD);
- BOOST_REQUIRE_EQUAL(lsaInfo.hasInfiniteExpirationPeriod(), true);
-}
-
-BOOST_AUTO_TEST_CASE(LsaInfoOutputStream)
-{
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("/test/lsa/info/tlv");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
-
- std::ostringstream os;
- os << lsaInfo;
-
- BOOST_CHECK_EQUAL(os.str(), "LsaInfo(OriginRouter: /test/lsa/info/tlv, SequenceNumber: 128, "
- "ExpirationPeriod: 10000 milliseconds)");
-}
-
-BOOST_AUTO_TEST_CASE(LsaInfoMake)
-{
- nlsr::test::MockLsa lsa;
- lsa.setOrigRouter("/test/lsa/info/tlv");
- lsa.setLsSeqNo(128);
- lsa.setExpirationTimePoint(ndn::time::system_clock::now());
-
- std::shared_ptr<LsaInfo> lsaInfo = makeLsaInfo(lsa);
- BOOST_CHECK_EQUAL(lsaInfo->getOriginRouter(), lsa.getOrigRouter());
- BOOST_CHECK_EQUAL(lsaInfo->getSequenceNumber(), lsa.getLsSeqNo());
- BOOST_CHECK_LE(lsaInfo->getExpirationPeriod(), ndn::time::milliseconds(0));
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace tlv
-} // namespace nlsr
diff --git a/tests/tlv/test-name-lsa.cpp b/tests/tlv/test-name-lsa.cpp
deleted file mode 100644
index 885d225..0000000
--- a/tests/tlv/test-name-lsa.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019, The University of Memphis,
- * Regents of the University of California,
- * Arizona Board of Regents.
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "tlv/name-lsa.hpp"
-
-#include "tests/boost-test.hpp"
-
-namespace nlsr {
-namespace tlv {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TlvTestNameLsa)
-
-const uint8_t NameLsaWithNamesData[] =
-{
- // Header
- 0x89, 0x25,
- // LsaInfo
- 0x80, 0x11, 0x81, 0x08, 0x07, 0x06, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x82, 0x01,
- 0x80, 0x8b, 0x02, 0x27, 0x10,
- // Name
- 0x07, 0x07, 0x08, 0x05, 0x74, 0x65, 0x73, 0x74, 0x31,
- // Name
- 0x07, 0x07, 0x08, 0x05, 0x74, 0x65, 0x73, 0x74, 0x32
-};
-
-const uint8_t NameLsaWithoutNamesData[] =
-{
- // Header
- 0x89, 0x13,
- // LsaInfo
- 0x80, 0x11, 0x81, 0x08, 0x07, 0x06, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x82, 0x01,
- 0x80, 0x8b, 0x02, 0x27, 0x10,
-};
-
-BOOST_AUTO_TEST_CASE(NameLsaEncodeWithNames)
-{
- NameLsa nameLsa;
-
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("test");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
- nameLsa.setLsaInfo(lsaInfo);
-
- nameLsa.addName("test1");
- nameLsa.addName("test2");
-
- const ndn::Block& wire = nameLsa.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(NameLsaWithNamesData,
- NameLsaWithNamesData + sizeof(NameLsaWithNamesData),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(NameLsaDecodeWithNames)
-{
- NameLsa nameLsa;
-
- nameLsa.wireDecode(ndn::Block(NameLsaWithNamesData, sizeof(NameLsaWithNamesData)));
-
- LsaInfo lsaInfo = nameLsa.getLsaInfo();
- BOOST_CHECK_EQUAL(lsaInfo.getOriginRouter(), "test");
- BOOST_CHECK_EQUAL(lsaInfo.getSequenceNumber(), 128);
- BOOST_CHECK_EQUAL(lsaInfo.getExpirationPeriod(), ndn::time::milliseconds(10000));
-
- BOOST_CHECK_EQUAL(nameLsa.hasNames(), true);
- std::list<ndn::Name> names = nameLsa.getNames();
- std::list<ndn::Name>::const_iterator it = names.begin();
- BOOST_CHECK_EQUAL(*it, "test1");
-
- it++;
- BOOST_CHECK_EQUAL(*it, "test2");
-}
-
-BOOST_AUTO_TEST_CASE(NameLsaEncodeWithoutNames)
-{
- NameLsa nameLsa;
-
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("test");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
- nameLsa.setLsaInfo(lsaInfo);
-
- const ndn::Block& wire = nameLsa.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(NameLsaWithoutNamesData,
- NameLsaWithoutNamesData + sizeof(NameLsaWithoutNamesData),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(NameLsaDecodeWithoutNames)
-{
- NameLsa nameLsa;
-
- nameLsa.wireDecode(ndn::Block(NameLsaWithoutNamesData, sizeof(NameLsaWithoutNamesData)));
-
- LsaInfo lsaInfo = nameLsa.getLsaInfo();
- BOOST_CHECK_EQUAL(lsaInfo.getOriginRouter(), "test");
- BOOST_CHECK_EQUAL(lsaInfo.getSequenceNumber(), 128);
- BOOST_CHECK_EQUAL(lsaInfo.getExpirationPeriod(), ndn::time::milliseconds(10000));
-
- BOOST_CHECK_EQUAL(nameLsa.hasNames(), false);
-}
-
-BOOST_AUTO_TEST_CASE(NameLsaClear)
-{
- NameLsa nameLsa;
-
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("test");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
- nameLsa.setLsaInfo(lsaInfo);
-
- nameLsa.addName("test1");
- BOOST_CHECK_EQUAL(nameLsa.getNames().size(), 1);
-
- std::list<ndn::Name> names = nameLsa.getNames();
- std::list<ndn::Name>::const_iterator it = names.begin();
- BOOST_CHECK_EQUAL(*it, "test1");
-
- nameLsa.clearNames();
- BOOST_CHECK_EQUAL(nameLsa.getNames().size(), 0);
-
- nameLsa.addName("test2");
- BOOST_CHECK_EQUAL(nameLsa.getNames().size(), 1);
-
- names = nameLsa.getNames();
- it = names.begin();
- BOOST_CHECK_EQUAL(*it, "test2");
-}
-
-BOOST_AUTO_TEST_CASE(AdjacencyLsaOutputStream)
-{
- NameLsa nameLsa;
-
- LsaInfo lsaInfo;
- lsaInfo.setOriginRouter("test");
- lsaInfo.setSequenceNumber(128);
- lsaInfo.setExpirationPeriod(ndn::time::milliseconds(10000));
- nameLsa.setLsaInfo(lsaInfo);
-
- nameLsa.addName("test1");
- nameLsa.addName("test2");
-
- std::ostringstream os;
- os << nameLsa;
-
- BOOST_CHECK_EQUAL(os.str(), "NameLsa("
- "LsaInfo("
- "OriginRouter: /test, "
- "SequenceNumber: 128, "
- "ExpirationPeriod: 10000 milliseconds), "
- "Name: /test1, "
- "Name: /test2)");
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace tlv
-} // namespace nlsr
diff --git a/tests/tlv/test-nexthops.cpp b/tests/tlv/test-nexthops.cpp
index 12a479e..f5b4d29 100644
--- a/tests/tlv/test-nexthops.cpp
+++ b/tests/tlv/test-nexthops.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2019, The University of Memphis,
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
diff --git a/tests/tlv/test-routing-table-entry.cpp b/tests/tlv/test-routing-table-entry.cpp
index 378dfd9..338945b 100644
--- a/tests/tlv/test-routing-table-entry.cpp
+++ b/tests/tlv/test-routing-table-entry.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2019, The University of Memphis,
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
diff --git a/tests/tlv/test-routing-table.cpp b/tests/tlv/test-routing-table.cpp
index ba8cef6..70c25c9 100644
--- a/tests/tlv/test-routing-table.cpp
+++ b/tests/tlv/test-routing-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2019, The University of Memphis,
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -107,7 +107,6 @@
BOOST_AUTO_TEST_CASE(RoutingTableDecode2)
{
RoutingTableStatus rtStatus;
-
rtStatus.wireDecode(ndn::Block(RoutingTableData2, sizeof(RoutingTableData2)));
BOOST_CHECK_EQUAL(rtStatus.hasRoutingTable(), false);
diff --git a/tests/update/test-nfd-rib-command-processor.cpp b/tests/update/test-nfd-rib-command-processor.cpp
index 514fa1c..47f02c5 100644
--- a/tests/update/test-nfd-rib-command-processor.cpp
+++ b/tests/update/test-nfd-rib-command-processor.cpp
@@ -66,7 +66,7 @@
ndn::Name lsaInterestName = conf.getLsaPrefix();
lsaInterestName.append(conf.getSiteName());
lsaInterestName.append(conf.getRouterName());
- lsaInterestName.append(std::to_string(Lsa::Type::NAME));
+ lsaInterestName.append(boost::lexical_cast<std::string>(Lsa::Type::NAME));
lsaInterestName.appendNumber(nlsr.m_lsdb.m_sequencingManager.getNameLsaSeq());
face.receive(ndn::Interest(lsaInterestName).setCanBePrefix(true));
diff --git a/tests/update/test-prefix-update-processor.cpp b/tests/update/test-prefix-update-processor.cpp
index 711935f..ca887d1 100644
--- a/tests/update/test-prefix-update-processor.cpp
+++ b/tests/update/test-prefix-update-processor.cpp
@@ -102,7 +102,7 @@
ndn::Name lsaInterestName = conf.getLsaPrefix();
lsaInterestName.append(conf.getSiteName());
lsaInterestName.append(conf.getRouterName());
- lsaInterestName.append(std::to_string(Lsa::Type::NAME));
+ lsaInterestName.append(boost::lexical_cast<std::string>(Lsa::Type::NAME));
lsaInterestName.appendNumber(nlsr.m_lsdb.m_sequencingManager.getNameLsaSeq());