lsdb: emit signals when modified
RoutingTable and NamePrefixTable consume the signal
and behave accordingly.
refs: #4127
Change-Id: I6540f30f0222f804b01dc7d9640831c84e5264cc
diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index 18a51f0..3dcf103 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020, The University of Memphis,
+/*
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* 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_PUBLISHER_FIXTURE_HPP
#define NLSR_PUBLISHER_FIXTURE_HPP
@@ -52,8 +52,6 @@
, rt1(nlsr.m_routingTable)
{
routerId = addIdentity(conf.getRouterPrefix());
-
- nlsr.initialize();
face.processEvents(ndn::time::milliseconds(100));
}
diff --git a/tests/route/test-name-prefix-table.cpp b/tests/route/test-name-prefix-table.cpp
index 9585106..fbe6c5a 100644
--- a/tests/route/test-name-prefix-table.cpp
+++ b/tests/route/test-name-prefix-table.cpp
@@ -20,7 +20,9 @@
*/
#include "route/name-prefix-table.hpp"
-#include "nlsr.hpp"
+#include "route/fib.hpp"
+#include "route/routing-table.hpp"
+#include "lsdb.hpp"
#include "../test-common.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
@@ -34,32 +36,38 @@
NamePrefixTableFixture()
: face(m_ioService, m_keyChain)
, conf(face, m_keyChain)
- , nlsr(face, m_keyChain, conf)
- , lsdb(nlsr.m_lsdb)
- , npt(nlsr.m_namePrefixTable)
+ , confProcessor(conf)
+ , lsdb(face, m_keyChain, conf)
+ , fib(face, m_scheduler, conf.getAdjacencyList(), conf, m_keyChain)
+ , rt(m_scheduler, lsdb, conf)
+ , npt(conf.getRouterPrefix(), fib, rt, rt.afterRoutingChange, lsdb.onLsdbModified)
{
}
+ bool
+ isNameInNpt(const ndn::Name& name)
+ {
+ auto it = std::find_if(npt.begin(), npt.end(),
+ [&] (const auto& entry) { return name == entry->getNamePrefix(); });
+ return it != npt.end();
+ }
+
public:
ndn::util::DummyClientFace face;
ConfParameter conf;
- Nlsr nlsr;
+ DummyConfFileProcessor confProcessor;
- Lsdb& lsdb;
- NamePrefixTable& npt;
+ Lsdb lsdb;
+ Fib fib;
+ RoutingTable rt;
+ NamePrefixTable npt;
};
BOOST_AUTO_TEST_SUITE(TestNamePrefixTable)
BOOST_FIXTURE_TEST_CASE(Bupt, NamePrefixTableFixture)
{
- conf.setNetwork("/ndn");
- conf.setSiteName("/router");
- conf.setRouterName("/a");
- conf.buildRouterAndSyncUserPrefix();
-
- RoutingTable& routingTable = nlsr.m_routingTable;
- routingTable.setRoutingCalcInterval(0);
+ rt.m_routingCalcInterval = 0_s;
Adjacent thisRouter(conf.getRouterPrefix(), ndn::FaceUri("udp4://10.0.0.1"), 0, Adjacent::STATUS_ACTIVE, 0, 0);
@@ -265,7 +273,6 @@
BOOST_FIXTURE_TEST_CASE(RoutingTableUpdate, NamePrefixTableFixture)
{
- RoutingTable& routingTable = nlsr.m_routingTable;
const ndn::Name destination = ndn::Name{"/ndn/destination1"};
NextHop hop1{"upd4://10.0.0.1", 0};
NextHop hop2{"udp4://10.0.0.2", 1};
@@ -273,10 +280,10 @@
const NamePrefixTableEntry entry1{"/ndn/router1"};
npt.addEntry(entry1.getNamePrefix(), destination);
- routingTable.addNextHop(destination, hop1);
- routingTable.addNextHop(destination, hop2);
+ rt.addNextHop(destination, hop1);
+ rt.addNextHop(destination, hop2);
- npt.updateWithNewRoute(routingTable.m_rTable);
+ npt.updateWithNewRoute(rt.m_rTable);
// At this point the NamePrefixTableEntry should have two NextHops.
auto nameIterator = std::find_if(npt.begin(), npt.end(),
@@ -291,8 +298,8 @@
BOOST_CHECK_EQUAL(nextHops.size(), 2);
// Add the other NextHop
- routingTable.addNextHop(destination, hop3);
- npt.updateWithNewRoute(routingTable.m_rTable);
+ rt.addNextHop(destination, hop3);
+ npt.updateWithNewRoute(rt.m_rTable);
// At this point the NamePrefixTableEntry should have three NextHops.
nameIterator = std::find_if(npt.begin(), npt.end(),
@@ -306,6 +313,65 @@
BOOST_CHECK_EQUAL(nextHops.size(), 3);
}
+BOOST_FIXTURE_TEST_CASE(UpdateFromLsdb, NamePrefixTableFixture)
+{
+ ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
+ NamePrefixList npl1;
+ ndn::Name n1("name1");
+ ndn::Name n2("name2");
+ ndn::Name router1("/router1/1");
+
+ npl1.insert(n1);
+ npl1.insert(n2);
+
+ NameLsa nlsa1(router1, 12, testTimePoint, npl1);
+ std::shared_ptr<Lsa> lsaPtr = std::make_shared<NameLsa>(nlsa1);
+
+ BOOST_CHECK(npt.begin() == npt.end());
+ npt.updateFromLsdb(lsaPtr, LsdbUpdate::INSTALLED, {}, {});
+ BOOST_CHECK_EQUAL(npt.m_table.size(), 3); // Router + 2 names
+
+ BOOST_CHECK(isNameInNpt(n1));
+ BOOST_CHECK(isNameInNpt(n2));
+
+ ndn::Name n3("name3");
+ auto nlsa = std::static_pointer_cast<NameLsa>(lsaPtr);
+ nlsa->removeName(n2);
+ nlsa->addName(n3);
+ npt.updateFromLsdb(lsaPtr, LsdbUpdate::UPDATED, {n3}, {n2});
+ BOOST_CHECK(isNameInNpt(n1));
+ BOOST_CHECK(!isNameInNpt(n2)); // Removed
+ BOOST_CHECK(isNameInNpt(n3));
+
+ BOOST_CHECK_EQUAL(npt.m_table.size(), 3); // Still router + 2 names
+
+ npt.updateFromLsdb(lsaPtr, LsdbUpdate::REMOVED, {}, {});
+ BOOST_CHECK_EQUAL(npt.m_table.size(), 0);
+
+ // Adj and Coordinate LSAs router
+ ndn::Name router2("/router2/2");
+ AdjLsa adjLsa(router2, 12, testTimePoint, 2, conf.getAdjacencyList());
+ lsaPtr = std::make_shared<AdjLsa>(adjLsa);
+ BOOST_CHECK(npt.begin() == npt.end());
+ npt.updateFromLsdb(lsaPtr, LsdbUpdate::INSTALLED, {}, {});
+ BOOST_CHECK_EQUAL(npt.m_table.size(), 1);
+ BOOST_CHECK(isNameInNpt(router2));
+
+ npt.updateFromLsdb(lsaPtr, LsdbUpdate::REMOVED, {}, {});
+ BOOST_CHECK_EQUAL(npt.m_table.size(), 0);
+
+ ndn::Name router3("/router3/3");
+ CoordinateLsa corLsa(router3, 12, testTimePoint, 2, {3});
+ lsaPtr = std::make_shared<CoordinateLsa>(corLsa);
+ BOOST_CHECK(npt.begin() == npt.end());
+ npt.updateFromLsdb(lsaPtr, LsdbUpdate::INSTALLED, {}, {});
+ BOOST_CHECK_EQUAL(npt.m_table.size(), 1);
+ BOOST_CHECK(isNameInNpt(router3));
+
+ npt.updateFromLsdb(lsaPtr, LsdbUpdate::REMOVED, {}, {});
+ BOOST_CHECK_EQUAL(npt.m_table.size(), 0);
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace test
diff --git a/tests/route/test-routing-table.cpp b/tests/route/test-routing-table.cpp
index 0bce153..6a2971e 100644
--- a/tests/route/test-routing-table.cpp
+++ b/tests/route/test-routing-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -28,23 +28,25 @@
namespace nlsr {
namespace test {
-class RoutingTableFixture
+class RoutingTableFixture : public UnitTestTimeFixture
{
public:
RoutingTableFixture()
- : conf(face, keyChain)
- , nlsr(face, keyChain, conf)
- , rt(nlsr.m_routingTable)
+ : face(m_ioService, m_keyChain, {true, true})
+ , conf(face, m_keyChain)
+ , confProcessor(conf)
+ , lsdb(face, m_keyChain, conf)
+ , rt(m_scheduler, lsdb, conf)
{
}
public:
ndn::util::DummyClientFace face;
- ndn::KeyChain keyChain;
ConfParameter conf;
- Nlsr nlsr;
+ DummyConfFileProcessor confProcessor;
- RoutingTable& rt;
+ Lsdb lsdb;
+ RoutingTable rt;
};
BOOST_AUTO_TEST_SUITE(TestRoutingTable)
@@ -130,6 +132,83 @@
" NextHop(Uri: nexthop, Cost: 99)\n");
}
+BOOST_FIXTURE_TEST_CASE(UpdateFromLsdb, RoutingTableFixture)
+{
+ ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now() + 3600_s;
+ ndn::Name router2("/router2");
+ AdjLsa adjLsa(router2, 12, testTimePoint, 2, conf.getAdjacencyList());
+ std::shared_ptr<Lsa> lsaPtr = std::make_shared<AdjLsa>(adjLsa);
+ BOOST_CHECK(!rt.m_isRouteCalculationScheduled);
+ lsdb.installLsa(lsaPtr);
+ BOOST_CHECK(rt.m_isRouteCalculationScheduled);
+
+ // After 15_s (by default) routing table calculation is done
+ advanceClocks(15_s);
+ BOOST_CHECK(!rt.m_isRouteCalculationScheduled);
+
+ // Update to installed LSA
+ std::shared_ptr<Lsa> lsaPtr2 = std::make_shared<AdjLsa>(adjLsa);
+ auto adjPtr = std::static_pointer_cast<AdjLsa>(lsaPtr2);
+ adjPtr->addAdjacent(Adjacent("router3"));
+ adjPtr->setSeqNo(13);
+ lsdb.installLsa(lsaPtr2);
+ BOOST_CHECK(rt.m_isRouteCalculationScheduled);
+
+ // Insert a neighbor so that AdjLsa can be installed
+ AdjacencyList adjl;
+ Adjacent ownAdj(conf.getRouterPrefix());
+ ownAdj.setStatus(Adjacent::STATUS_ACTIVE);
+ adjl.insert(ownAdj);
+ AdjLsa adjLsa4("/router4", 12, testTimePoint, 2, adjl);
+ lsaPtr = std::make_shared<AdjLsa>(adjLsa4);
+ lsdb.installLsa(lsaPtr);
+
+ Adjacent adj("/router4");
+ adj.setStatus(Adjacent::STATUS_ACTIVE);
+ conf.getAdjacencyList().insert(adj);
+ lsdb.scheduleAdjLsaBuild();
+ BOOST_CHECK_EQUAL(rt.m_rTable.size(), 0);
+ advanceClocks(15_s);
+ BOOST_CHECK_EQUAL(rt.m_rTable.size(), 1);
+
+ rt.wireEncode();
+ BOOST_CHECK(rt.m_wire.isValid());
+ BOOST_CHECK_GT(rt.m_wire.size(), 0);
+
+ // Remove own Adj Lsa - Make sure routing table is wiped out
+ conf.getAdjacencyList().setStatusOfNeighbor("/router4", Adjacent::STATUS_INACTIVE);
+ conf.getAdjacencyList().setTimedOutInterestCount("/router4", HELLO_RETRIES_MAX);
+ lsdb.scheduleAdjLsaBuild();
+ advanceClocks(15_s);
+ BOOST_CHECK_EQUAL(rt.m_rTable.size(), 0);
+ BOOST_CHECK(!rt.m_wire.isValid());
+
+ // Check that HR routing is scheduled, once Coordinate LSA is added
+ BOOST_CHECK(!rt.m_isRouteCalculationScheduled);
+ rt.m_hyperbolicState = HYPERBOLIC_STATE_ON;
+ CoordinateLsa clsa("router5", 12, testTimePoint, 2.5, {30.0});
+ auto clsaPtr = std::make_shared<CoordinateLsa>(clsa);
+ lsdb.installLsa(clsaPtr);
+ BOOST_CHECK(rt.m_isRouteCalculationScheduled);
+
+ Adjacent router5("/router5");
+ router5.setStatus(Adjacent::STATUS_ACTIVE);
+ conf.getAdjacencyList().insert(router5);
+ conf.getAdjacencyList().setStatusOfNeighbor("/router5", Adjacent::STATUS_ACTIVE);
+ advanceClocks(15_s);
+ rt.wireEncode();
+ BOOST_CHECK(rt.m_wire.isValid());
+ BOOST_CHECK_GT(rt.m_wire.size(), 0);
+ BOOST_CHECK(!rt.m_isRouteCalculationScheduled);
+
+ // Emulate HelloProtocol neighbor down
+ conf.getAdjacencyList().setStatusOfNeighbor("/router5", Adjacent::STATUS_INACTIVE);
+ rt.scheduleRoutingTableCalculation();
+ advanceClocks(15_s);
+ BOOST_CHECK_EQUAL(rt.m_rTable.size(), 0);
+ BOOST_CHECK(!rt.m_wire.isValid());
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace test
diff --git a/tests/test-hello-protocol.cpp b/tests/test-hello-protocol.cpp
index 67bf272..f5aee2b 100644
--- a/tests/test-hello-protocol.cpp
+++ b/tests/test-hello-protocol.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -68,7 +68,7 @@
BOOST_CHECK_EQUAL(nlsr.m_routingTable.m_isRouteCalculationScheduled, false);
}
else {
- BOOST_CHECK_EQUAL(nlsr.m_lsdb.m_isBuildAdjLsaSheduled, false);
+ BOOST_CHECK_EQUAL(nlsr.m_lsdb.m_isBuildAdjLsaScheduled, false);
}
BOOST_CHECK_EQUAL(adjList.findAdjacent(ndn::Name(ACTIVE_NEIGHBOR))->getStatus(),
Adjacent::STATUS_ACTIVE);
@@ -79,7 +79,7 @@
BOOST_CHECK_EQUAL(nlsr.m_routingTable.m_isRouteCalculationScheduled, true);
}
else {
- BOOST_CHECK_EQUAL(nlsr.m_lsdb.m_isBuildAdjLsaSheduled, true);
+ BOOST_CHECK_EQUAL(nlsr.m_lsdb.m_isBuildAdjLsaScheduled, true);
}
BOOST_CHECK_EQUAL(adjList.findAdjacent(ndn::Name(ACTIVE_NEIGHBOR))->getStatus(),
Adjacent::STATUS_INACTIVE);
diff --git a/tests/test-lsa-rule.cpp b/tests/test-lsa-rule.cpp
index 2827cd1..e6d4458 100644
--- a/tests/test-lsa-rule.cpp
+++ b/tests/test-lsa-rule.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -50,7 +50,7 @@
, confParam(face, m_keyChain)
, confProcessor(confParam, SYNC_PROTOCOL_PSYNC, HYPERBOLIC_STATE_OFF,
"/ndn/", "/edu/test-site", "/%C1.Router/router1")
- , nlsr(face, m_keyChain, confParam)
+ , lsdb(face, m_keyChain, confParam)
, ROOT_CERT_PATH(boost::filesystem::current_path() / std::string("root.cert"))
{
rootId = addIdentity(rootIdName);
@@ -90,9 +90,6 @@
}
inputFile.close();
- // Initialize NLSR to initialize the keyChain
- nlsr.initialize();
-
this->advanceClocks(ndn::time::milliseconds(10));
face.sentInterests.clear();
@@ -105,7 +102,7 @@
ndn::security::pib::Identity rootId, siteIdentity, opIdentity, routerId;
ConfParameter confParam;
DummyConfFileProcessor confProcessor;
- Nlsr nlsr;
+ Lsdb lsdb;
const boost::filesystem::path ROOT_CERT_PATH;
};
@@ -122,7 +119,7 @@
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());
+ lsaDataName.appendNumber(lsdb.m_sequencingManager.getNameLsaSeq());
// Append version, segmentNo
lsaDataName.appendNumber(1).appendNumber(1);
@@ -152,7 +149,7 @@
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());
+ lsaDataName.appendNumber(lsdb.m_sequencingManager.getNameLsaSeq());
// Append version, segmentNo
lsaDataName.appendNumber(1).appendNumber(1);
diff --git a/tests/test-lsa-segment-storage.cpp b/tests/test-lsa-segment-storage.cpp
index 7862e45..3110e87 100644
--- a/tests/test-lsa-segment-storage.cpp
+++ b/tests/test-lsa-segment-storage.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -53,10 +53,7 @@
)CONF";
conf.m_validator.load(config, "config-file-from-string");
- nlsr.initialize();
-
this->advanceClocks(ndn::time::milliseconds(10));
-
face.sentInterests.clear();
}
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 317cc6b..db1c60b 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -22,7 +22,6 @@
#include "lsdb.hpp"
#include "test-common.hpp"
-#include "nlsr.hpp"
#include "lsa/lsa.hpp"
#include "name-prefix-list.hpp"
@@ -41,15 +40,12 @@
: face(m_ioService, m_keyChain, {true, true})
, conf(face, m_keyChain)
, confProcessor(conf)
- , nlsr(face, m_keyChain, conf)
- , lsdb(nlsr.m_lsdb)
+ , lsdb(face, m_keyChain, conf)
, REGISTER_COMMAND_PREFIX("/localhost/nfd/rib")
, REGISTER_VERB("register")
{
addIdentity("/ndn/site/%C1.Router/this-router");
- nlsr.initialize();
-
advanceClocks(10_ms);
face.sentInterests.clear();
}
@@ -100,15 +96,50 @@
BOOST_CHECK(false);
}
+ void
+ checkSignalResult(LsdbUpdate updateType,
+ const std::shared_ptr<Lsa>& lsaPtr,
+ const std::list<ndn::Name>& namesToAdd,
+ const std::list<ndn::Name>& namesToRemove)
+ {
+ BOOST_CHECK(updateHappened);
+ BOOST_CHECK_EQUAL(lsaPtrCheck->getOriginRouter(), lsaPtr->getOriginRouter());
+ BOOST_CHECK_EQUAL(lsaPtrCheck->getType(), lsaPtr->getType());
+ BOOST_CHECK(updateType == updateTypeCheck);
+ BOOST_CHECK(namesToAdd == namesToAddCheck);
+ BOOST_CHECK(namesToRemove == namesToRemoveCheck);
+ updateHappened = false;
+ }
+
+ void
+ connectSignal()
+ {
+ lsdb.onLsdbModified.connect(
+ [&] (std::shared_ptr<Lsa> lsa, LsdbUpdate updateType,
+ const auto& namesToAdd, const auto& namesToRemove) {
+ lsaPtrCheck = lsa;
+ updateTypeCheck = updateType;
+ namesToAddCheck = namesToAdd;
+ namesToRemoveCheck = namesToRemove;
+ updateHappened = true;
+ }
+ );
+ }
+
public:
ndn::util::DummyClientFace face;
ConfParameter conf;
DummyConfFileProcessor confProcessor;
- Nlsr nlsr;
- Lsdb& lsdb;
+ Lsdb lsdb;
ndn::Name REGISTER_COMMAND_PREFIX;
ndn::Name::Component REGISTER_VERB;
+
+ LsdbUpdate updateTypeCheck = LsdbUpdate::INSTALLED;
+ std::list<ndn::Name> namesToAddCheck;
+ std::list<ndn::Name> namesToRemoveCheck;
+ std::shared_ptr<Lsa> lsaPtrCheck = nullptr;
+ bool updateHappened = false;
};
BOOST_FIXTURE_TEST_SUITE(TestLsdb, LsdbFixture)
@@ -212,9 +243,8 @@
}
)CONF";
conf2.getValidator().load(config, "config-file-from-string");
- Nlsr nlsr2(face2, m_keyChain, conf2);
- Lsdb& lsdb2(nlsr2.m_lsdb);
+ Lsdb lsdb2(face2, m_keyChain, conf2);
advanceClocks(ndn::time::milliseconds(10), 10);
@@ -304,7 +334,7 @@
// 1800 seconds is the default life time.
NameLsa nlsa1(router1, 12, testTimePoint, npl1);
- Lsdb& lsdb1(nlsr.m_lsdb);
+ Lsdb& lsdb1(lsdb);
lsdb1.installLsa(std::make_shared<NameLsa>(nlsa1));
@@ -404,6 +434,70 @@
BOOST_CHECK(lsdb.isLsaNew(originRouter, Lsa::Type::NAME, higherSeqNo));
}
+BOOST_AUTO_TEST_CASE(LsdbSignals)
+{
+ connectSignal();
+ auto testTimePoint = ndn::time::system_clock::now() + 3600_s;
+ ndn::Name router2("/router2");
+ AdjLsa adjLsa(router2, 12, testTimePoint, 2, conf.getAdjacencyList());
+ std::shared_ptr<Lsa> lsaPtr = std::make_shared<AdjLsa>(adjLsa);
+ lsdb.installLsa(lsaPtr);
+ checkSignalResult(LsdbUpdate::INSTALLED, lsaPtr, {}, {});
+
+ adjLsa.setSeqNo(13);
+ updateHappened = false;
+ lsaPtr = std::make_shared<AdjLsa>(adjLsa);
+ lsdb.installLsa(lsaPtr);
+ BOOST_CHECK(!updateHappened);
+
+ Adjacent adj("Neighbor1");
+ adjLsa.setSeqNo(14);
+ adjLsa.addAdjacent(adj);
+ lsaPtr = std::make_shared<AdjLsa>(adjLsa);
+ lsdb.installLsa(lsaPtr);
+ checkSignalResult(LsdbUpdate::UPDATED, lsaPtr, {}, {});
+
+ lsdb.removeLsa(lsaPtrCheck->getOriginRouter(), Lsa::Type::ADJACENCY);
+ checkSignalResult(LsdbUpdate::REMOVED, lsaPtr, {}, {});
+
+ // Name LSA
+ NamePrefixList npl1{"name1", "name2"};
+ NameLsa nameLsa(router2, 12, testTimePoint, npl1);
+ lsaPtr = std::make_shared<NameLsa>(nameLsa);
+ lsdb.installLsa(lsaPtr);
+ checkSignalResult(LsdbUpdate::INSTALLED, lsaPtr, {}, {});
+
+ nameLsa.setSeqNo(13);
+ lsaPtr = std::make_shared<NameLsa>(nameLsa);
+ lsdb.installLsa(lsaPtr);
+ BOOST_CHECK(!updateHappened);
+
+ NamePrefixList npl2{"name2", "name3"};
+ NameLsa nameLsa2(router2, 14, testTimePoint, npl2);
+ lsaPtr = std::make_shared<NameLsa>(nameLsa2);
+ lsdb.installLsa(lsaPtr);
+ checkSignalResult(LsdbUpdate::UPDATED, lsaPtr, {"name3"}, {"name1"});
+
+ lsdb.removeLsa(lsaPtrCheck->getOriginRouter(), Lsa::Type::NAME);
+ checkSignalResult(LsdbUpdate::REMOVED, lsaPtr, {}, {});
+
+ // Coordinate LSA
+ lsaPtr = std::make_shared<CoordinateLsa>(CoordinateLsa("router1", 12, testTimePoint, 2.5, {30}));
+ lsdb.installLsa(lsaPtr);
+ checkSignalResult(LsdbUpdate::INSTALLED, lsaPtr, {}, {});
+
+ lsaPtr = std::make_shared<CoordinateLsa>(CoordinateLsa("router1", 13, testTimePoint, 2.5, {30}));
+ lsdb.installLsa(lsaPtr);
+ BOOST_CHECK(!updateHappened);
+
+ lsaPtr = std::make_shared<CoordinateLsa>(CoordinateLsa("router1", 14, testTimePoint, 2.5, {40}));
+ lsdb.installLsa(lsaPtr);
+ checkSignalResult(LsdbUpdate::UPDATED, lsaPtr, {}, {});
+
+ lsdb.removeLsa(lsaPtrCheck->getOriginRouter(), Lsa::Type::COORDINATE);
+ checkSignalResult(LsdbUpdate::REMOVED, lsaPtr, {}, {});
+}
+
BOOST_AUTO_TEST_SUITE_END() // TestLsdb
} // namespace test
diff --git a/tests/test-nlsr.cpp b/tests/test-nlsr.cpp
index dc91c73..1f6c23c 100644
--- a/tests/test-nlsr.cpp
+++ b/tests/test-nlsr.cpp
@@ -85,7 +85,7 @@
conf.setHyperbolicState(HYPERBOLIC_STATE_ON);
- nlsr.initialize();
+ Nlsr nlsr2(m_face, m_keyChain, conf);
for (const auto& neighbor : neighbors.getAdjList()) {
BOOST_CHECK_EQUAL(neighbor.getLinkCost(), 0);
@@ -107,7 +107,7 @@
Adjacent::STATUS_INACTIVE, 0, 0);
neighbors.insert(neighborC);
- nlsr.initialize();
+ Nlsr nlsr2(m_face, m_keyChain, conf);
for (const auto& neighbor : neighbors.getAdjList()) {
BOOST_CHECK_NE(neighbor.getLinkCost(), 0);
@@ -125,8 +125,8 @@
const Lsdb& lsdb = nlsr2.m_lsdb;
const RoutingTable& rt = nlsr2.m_routingTable;
- BOOST_CHECK_EQUAL(lsdb.m_adjLsaBuildInterval, ndn::time::seconds(3));
- BOOST_CHECK_EQUAL(rt.getRoutingCalcInterval(), ndn::time::seconds(9));
+ BOOST_CHECK_EQUAL(lsdb.m_adjLsaBuildInterval, 3_s);
+ BOOST_CHECK_EQUAL(rt.m_routingCalcInterval, 9_s);
}
BOOST_AUTO_TEST_CASE(FaceCreateEvent)
@@ -263,7 +263,6 @@
// Set HelloInterest lifetime as 10 seconds so that neighbors are not marked INACTIVE
// upon timeout before this test ends
conf.setInterestResendTime(10);
- nlsr.initialize();
// Simulate successful HELLO responses
lsdb.scheduleAdjLsaBuild();
@@ -367,8 +366,6 @@
neighbors.insert(neighborB);
- nlsr.initialize();
-
this->advanceClocks(10_ms);
// Receive HELLO response from Router A
diff --git a/tests/test-statistics.cpp b/tests/test-statistics.cpp
index 016d51e..0000fb0 100644
--- a/tests/test-statistics.cpp
+++ b/tests/test-statistics.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -47,8 +47,6 @@
addIdentity(conf.getRouterPrefix());
- nlsr.initialize();
-
this->advanceClocks(ndn::time::milliseconds(1), 10);
face.sentInterests.clear();
}
diff --git a/tests/update/test-advertise-crash.cpp b/tests/update/test-advertise-crash.cpp
index 4e8f112..d6aea8a 100644
--- a/tests/update/test-advertise-crash.cpp
+++ b/tests/update/test-advertise-crash.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020, The University of Memphis,
+/*
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* 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 "nlsr.hpp"
@@ -51,9 +51,6 @@
addIdentity(conf.getRouterPrefix());
- // So that NLSR starts listening on prefixes
- nlsr.initialize();
-
// Simulate a callback with fake response
// This will trigger the undefined behavior found
// in fib.cpp if an operation is done on non-existent faceUri
diff --git a/tests/update/test-nfd-rib-command-processor.cpp b/tests/update/test-nfd-rib-command-processor.cpp
index 47f02c5..d5fa0c8 100644
--- a/tests/update/test-nfd-rib-command-processor.cpp
+++ b/tests/update/test-nfd-rib-command-processor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020, The University of Memphis,
+/*
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* 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 "update/nfd-rib-command-processor.hpp"
#include "adjacency-list.hpp"
@@ -43,9 +43,6 @@
{
addIdentity(conf.getRouterPrefix());
- // Initialize NLSR so a sync socket is created
- nlsr.initialize();
-
this->advanceClocks(ndn::time::milliseconds(10), 10);
face.sentInterests.clear();
diff --git a/tests/update/test-prefix-update-processor.cpp b/tests/update/test-prefix-update-processor.cpp
index ca887d1..e5a5890 100644
--- a/tests/update/test-prefix-update-processor.cpp
+++ b/tests/update/test-prefix-update-processor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020, The University of Memphis,
+/*
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* 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 "update/prefix-update-processor.hpp"
#include "nlsr.hpp"
@@ -86,9 +86,6 @@
addIdentity(conf.getRouterPrefix());
- // Initialize NLSR so a sync socket is created
- nlsr.initialize();
-
this->advanceClocks(ndn::time::milliseconds(10));
face.sentInterests.clear();
diff --git a/tests/update/test-save-delete-prefix.cpp b/tests/update/test-save-delete-prefix.cpp
index 1bcca79..336ec8a 100644
--- a/tests/update/test-save-delete-prefix.cpp
+++ b/tests/update/test-save-delete-prefix.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020, The University of Memphis,
+/*
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* 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 "update/prefix-update-processor.hpp"
#include "nlsr.hpp"
@@ -100,8 +100,6 @@
// Set the network so the LSA prefix is constructed
addIdentity(conf.getRouterPrefix());
- // Initialize NLSR so a sync socket is created
- nlsr.initialize();
this->advanceClocks(ndn::time::milliseconds(10));
face.sentInterests.clear();
}