blob: 66c1826be8d93ca0ddd2bb41ea5f3c3ee095abf1 [file] [log] [blame]
Vince Lehmancae33b62015-06-05 09:21:30 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Ashlesh Gawande57a87172020-05-09 19:47:06 -07002/*
Junxiao Shib8752932024-01-07 15:18:46 +00003 * Copyright (c) 2014-2024, The University of Memphis,
Vince Lehmancae33b62015-06-05 09:21:30 -05004 * Regents of the University of California,
5 * Arizona Board of Regents.
6 *
7 * This file is part of NLSR (Named-data Link State Routing).
8 * See AUTHORS.md for complete list of NLSR authors and contributors.
9 *
10 * NLSR is free software: you can redistribute it and/or modify it under the terms
11 * of the GNU General Public License as published by the Free Software Foundation,
12 * either version 3 of the License, or (at your option) any later version.
13 *
14 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Ashlesh Gawande57a87172020-05-09 19:47:06 -070020 */
Vince Lehmancae33b62015-06-05 09:21:30 -050021
Nick Gordonc0c6bcf2017-08-15 18:11:21 -050022#include "route/name-prefix-table.hpp"
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -070023#include "route/fib.hpp"
24#include "route/routing-table.hpp"
25#include "lsdb.hpp"
Vince Lehmancae33b62015-06-05 09:21:30 -050026
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040027#include "tests/io-key-chain-fixture.hpp"
28#include "tests/test-common.hpp"
Vince Lehmancae33b62015-06-05 09:21:30 -050029
Davide Pesavento288141a2024-02-13 17:30:35 -050030namespace nlsr::tests {
Vince Lehmancae33b62015-06-05 09:21:30 -050031
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040032class NamePrefixTableFixture : public IoKeyChainFixture
Vince Lehmancae33b62015-06-05 09:21:30 -050033{
34public:
35 NamePrefixTableFixture()
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040036 : lsdb(face, m_keyChain, conf)
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -070037 , fib(face, m_scheduler, conf.getAdjacencyList(), conf, m_keyChain)
38 , rt(m_scheduler, lsdb, conf)
39 , npt(conf.getRouterPrefix(), fib, rt, rt.afterRoutingChange, lsdb.onLsdbModified)
Vince Lehmancae33b62015-06-05 09:21:30 -050040 {
Vince Lehmancae33b62015-06-05 09:21:30 -050041 }
42
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -070043 bool
44 isNameInNpt(const ndn::Name& name)
45 {
46 auto it = std::find_if(npt.begin(), npt.end(),
47 [&] (const auto& entry) { return name == entry->getNamePrefix(); });
48 return it != npt.end();
49 }
50
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040051private:
52 ndn::Scheduler m_scheduler{m_io};
53
Vince Lehmancae33b62015-06-05 09:21:30 -050054public:
Junxiao Shi43f37a02023-08-09 00:09:00 +000055 ndn::DummyClientFace face{m_io, m_keyChain};
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040056 ConfParameter conf{face, m_keyChain};
57 DummyConfFileProcessor confProcessor{conf};
Vince Lehmancae33b62015-06-05 09:21:30 -050058
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -070059 Lsdb lsdb;
60 Fib fib;
61 RoutingTable rt;
62 NamePrefixTable npt;
Vince Lehmancae33b62015-06-05 09:21:30 -050063};
64
65BOOST_AUTO_TEST_SUITE(TestNamePrefixTable)
66
67BOOST_FIXTURE_TEST_CASE(Bupt, NamePrefixTableFixture)
68{
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -070069 rt.m_routingCalcInterval = 0_s;
Vince Lehmancae33b62015-06-05 09:21:30 -050070
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050071 Adjacent thisRouter(conf.getRouterPrefix(), ndn::FaceUri("udp4://10.0.0.1"), 0, Adjacent::STATUS_ACTIVE, 0, 0);
Vince Lehmancae33b62015-06-05 09:21:30 -050072
73 ndn::Name buptRouterName("/ndn/cn/edu/bupt/%C1.Router/bupthub");
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050074 Adjacent bupt(buptRouterName, ndn::FaceUri("udp4://10.0.0.2"), 0, Adjacent::STATUS_ACTIVE, 0, 0);
Vince Lehmancae33b62015-06-05 09:21:30 -050075
76 // This router's Adjacency LSA
Ashlesh Gawande85998a12017-12-07 22:22:13 -060077 conf.getAdjacencyList().insert(bupt);
Davide Pesavento288141a2024-02-13 17:30:35 -050078 AdjLsa thisRouterAdjLsa(thisRouter.getName(), 1, time::system_clock::now() + 3600_s, conf.getAdjacencyList());
Ashlesh Gawande57a87172020-05-09 19:47:06 -070079 lsdb.installLsa(std::make_shared<AdjLsa>(thisRouterAdjLsa));
Vince Lehmancae33b62015-06-05 09:21:30 -050080
81 // BUPT Adjacency LSA
82 AdjacencyList buptAdjacencies;
83 buptAdjacencies.insert(thisRouter);
Davide Pesavento288141a2024-02-13 17:30:35 -050084 AdjLsa buptAdjLsa(buptRouterName, 1, time::system_clock::now() + 5_s, buptAdjacencies);
Ashlesh Gawande57a87172020-05-09 19:47:06 -070085 lsdb.installLsa(std::make_shared<AdjLsa>(buptAdjLsa));
Vince Lehmancae33b62015-06-05 09:21:30 -050086
87 // BUPT Name LSA
88 ndn::Name buptAdvertisedName("/ndn/cn/edu/bupt");
Nick Gordon96861ca2017-10-17 18:25:21 -050089 NamePrefixList buptNames{buptAdvertisedName};
Davide Pesavento288141a2024-02-13 17:30:35 -050090 NameLsa buptNameLsa(buptRouterName, 1, time::system_clock::now() + 5_s, buptNames);
Ashlesh Gawande57a87172020-05-09 19:47:06 -070091 lsdb.installLsa(std::make_shared<NameLsa>(buptNameLsa));
Vince Lehmancae33b62015-06-05 09:21:30 -050092
93 // Advance clocks to expire LSAs
Davide Pesavento288141a2024-02-13 17:30:35 -050094 this->advanceClocks(15_s);
Vince Lehmancae33b62015-06-05 09:21:30 -050095
96 // LSA expirations should cause NPT entries to be completely removed
Davide Pesavento288141a2024-02-13 17:30:35 -050097 auto it = npt.begin();
98 BOOST_CHECK(it == npt.end());
Vince Lehmancae33b62015-06-05 09:21:30 -050099
100 // Install new name LSA
Davide Pesavento288141a2024-02-13 17:30:35 -0500101 NameLsa buptNewNameLsa(buptRouterName, 12, time::system_clock::now() + 3600_s, buptNames);
Ashlesh Gawande57a87172020-05-09 19:47:06 -0700102 lsdb.installLsa(std::make_shared<NameLsa>(buptNewNameLsa));
Vince Lehmancae33b62015-06-05 09:21:30 -0500103
Davide Pesavento288141a2024-02-13 17:30:35 -0500104 this->advanceClocks(1_s);
Vince Lehmancae33b62015-06-05 09:21:30 -0500105
106 // Install new adjacency LSA
Davide Pesavento288141a2024-02-13 17:30:35 -0500107 AdjLsa buptNewAdjLsa(buptRouterName, 12, time::system_clock::now() + 3600_s, buptAdjacencies);
Ashlesh Gawande57a87172020-05-09 19:47:06 -0700108 lsdb.installLsa(std::make_shared<AdjLsa>(buptNewAdjLsa));
Vince Lehmancae33b62015-06-05 09:21:30 -0500109
Davide Pesavento288141a2024-02-13 17:30:35 -0500110 this->advanceClocks(1_s);
Vince Lehmancae33b62015-06-05 09:21:30 -0500111
112 // Each NPT entry should have a destination router
113 it = npt.begin();
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500114 BOOST_REQUIRE_EQUAL((*it)->getNamePrefix(), buptRouterName);
115 BOOST_REQUIRE_EQUAL((*it)->getRteList().size(), 1);
116 BOOST_CHECK_EQUAL((*(*it)->getRteList().begin())->getDestination(), buptRouterName);
Vince Lehmancae33b62015-06-05 09:21:30 -0500117
118 ++it;
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500119 BOOST_REQUIRE_EQUAL((*it)->getNamePrefix(), buptAdvertisedName);
120 BOOST_REQUIRE_EQUAL((*it)->getRteList().size(), 1);
121 BOOST_CHECK_EQUAL((*(*it)->getRteList().begin())->getDestination(), buptRouterName);
Nick Gordonb50e51b2016-07-22 16:05:57 -0500122}
123
124BOOST_FIXTURE_TEST_CASE(AddEntryToPool, NamePrefixTableFixture)
125{
Nick Gordonb50e51b2016-07-22 16:05:57 -0500126 RoutingTablePoolEntry rtpe1("router1");
127
128 npt.addRtpeToPool(rtpe1);
129
130 BOOST_CHECK_EQUAL(npt.m_rtpool.size(), 1);
131 BOOST_CHECK_EQUAL(*(npt.m_rtpool.find("router1")->second), rtpe1);
132}
133
134BOOST_FIXTURE_TEST_CASE(RemoveEntryFromPool, NamePrefixTableFixture)
135{
Nick Gordonb50e51b2016-07-22 16:05:57 -0500136 RoutingTablePoolEntry rtpe1("router1", 0);
dmcoomes9f936662017-03-02 10:33:09 -0600137 std::shared_ptr<RoutingTablePoolEntry> rtpePtr = npt.addRtpeToPool(rtpe1);
Nick Gordonb50e51b2016-07-22 16:05:57 -0500138
139 npt.addRtpeToPool(rtpe1);
140
141 npt.deleteRtpeFromPool(rtpePtr);
142
143 BOOST_CHECK_EQUAL(npt.m_rtpool.size(), 0);
144 BOOST_CHECK_EQUAL(npt.m_rtpool.count("router1"), 0);
145}
146
147BOOST_FIXTURE_TEST_CASE(AddRoutingEntryToNptEntry, NamePrefixTableFixture)
148{
Nick Gordonb50e51b2016-07-22 16:05:57 -0500149 RoutingTablePoolEntry rtpe1("/ndn/memphis/rtr1", 0);
dmcoomes9f936662017-03-02 10:33:09 -0600150 std::shared_ptr<RoutingTablePoolEntry> rtpePtr = npt.addRtpeToPool(rtpe1);
Nick Gordonb50e51b2016-07-22 16:05:57 -0500151 NamePrefixTableEntry npte1("/ndn/memphis/rtr2");
152
153 npt.addEntry("/ndn/memphis/rtr2", "/ndn/memphis/rtr1");
154
Davide Pesavento288141a2024-02-13 17:30:35 -0500155 auto nItr = std::find_if(npt.m_table.begin(),
156 npt.m_table.end(),
157 [&] (const auto& entry) {
158 return entry->getNamePrefix() == npte1.getNamePrefix();
159 });
Nick Gordonb50e51b2016-07-22 16:05:57 -0500160
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500161 std::list<std::shared_ptr<RoutingTablePoolEntry>> rtpeList = (*nItr)->getRteList();
Davide Pesavento288141a2024-02-13 17:30:35 -0500162 auto rItr = std::find(rtpeList.begin(), rtpeList.end(), rtpePtr);
Nick Gordonb50e51b2016-07-22 16:05:57 -0500163 BOOST_CHECK_EQUAL(**rItr, *rtpePtr);
164}
165
166BOOST_FIXTURE_TEST_CASE(RemoveRoutingEntryFromNptEntry, NamePrefixTableFixture)
167{
Nick Gordonb50e51b2016-07-22 16:05:57 -0500168 RoutingTablePoolEntry rtpe1("/ndn/memphis/rtr1", 0);
169
170 NamePrefixTableEntry npte1("/ndn/memphis/rtr2");
Davide Pesaventod90338d2021-01-07 17:50:05 -0500171 npt.m_table.push_back(std::make_shared<NamePrefixTableEntry>(npte1));
Nick Gordonb50e51b2016-07-22 16:05:57 -0500172
173 npt.addEntry("/ndn/memphis/rtr2", "/ndn/memphis/rtr1");
174 npt.addEntry("/ndn/memphis/rtr2", "/ndn/memphis/altrtr");
175
176 npt.removeEntry("/ndn/memphis/rtr2", "/ndn/memphis/rtr1");
177
Davide Pesavento288141a2024-02-13 17:30:35 -0500178 auto nItr = std::find_if(npt.m_table.begin(),
179 npt.m_table.end(),
180 [&] (const auto& entry) {
181 return entry->getNamePrefix() == npte1.getNamePrefix();
182 });
Nick Gordonb50e51b2016-07-22 16:05:57 -0500183
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500184 std::list<std::shared_ptr<RoutingTablePoolEntry>> rtpeList = (*nItr)->getRteList();
Nick Gordonb50e51b2016-07-22 16:05:57 -0500185
186 BOOST_CHECK_EQUAL(rtpeList.size(), 1);
187 BOOST_CHECK_EQUAL(npt.m_rtpool.size(), 1);
Vince Lehmancae33b62015-06-05 09:21:30 -0500188}
189
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500190BOOST_FIXTURE_TEST_CASE(AddNptEntryPtrToRoutingEntry, NamePrefixTableFixture)
191{
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500192 NamePrefixTableEntry npte1("/ndn/memphis/rtr2");
Davide Pesaventod90338d2021-01-07 17:50:05 -0500193 npt.m_table.push_back(std::make_shared<NamePrefixTableEntry>(npte1));
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500194
195 npt.addEntry("/ndn/memphis/rtr2", "/ndn/memphis/rtr1");
196
Davide Pesavento288141a2024-02-13 17:30:35 -0500197 auto nItr = std::find_if(npt.m_table.begin(),
198 npt.m_table.end(),
199 [&] (const auto& entry) {
200 return entry->getNamePrefix() == npte1.getNamePrefix();
201 });
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500202
203 std::list<std::shared_ptr<RoutingTablePoolEntry>> rtpeList = (*nItr)->getRteList();
204
205 BOOST_CHECK_EQUAL(rtpeList.size(), 1);
206
207 auto& namePrefixPtrs = rtpeList.front()->namePrefixTableEntries;
208
209 auto nptIterator = namePrefixPtrs.find(npte1.getNamePrefix());
210 BOOST_REQUIRE(nptIterator != namePrefixPtrs.end());
211 auto nptSharedPtr = nptIterator->second.lock();
212 BOOST_CHECK_EQUAL(*nptSharedPtr, npte1);
213}
214
215BOOST_FIXTURE_TEST_CASE(RemoveNptEntryPtrFromRoutingEntry, NamePrefixTableFixture)
216{
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500217 NamePrefixTableEntry npte1("/ndn/memphis/rtr1");
218 NamePrefixTableEntry npte2("/ndn/memphis/rtr2");
219 RoutingTableEntry rte1("/ndn/memphis/destination1");
Davide Pesaventod90338d2021-01-07 17:50:05 -0500220 npt.m_table.push_back(std::make_shared<NamePrefixTableEntry>(npte1));
221 npt.m_table.push_back(std::make_shared<NamePrefixTableEntry>(npte2));
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500222
223 npt.addEntry(npte1.getNamePrefix(), rte1.getDestination());
224 // We have to add two entries, otherwise the routing pool entry will be deleted.
225 npt.addEntry(npte2.getNamePrefix(), rte1.getDestination());
226 npt.removeEntry(npte2.getNamePrefix(), rte1.getDestination());
227
Davide Pesavento288141a2024-02-13 17:30:35 -0500228 auto nItr = std::find_if(npt.m_table.begin(),
229 npt.m_table.end(),
230 [&] (const auto& entry) {
231 return entry->getNamePrefix() == npte1.getNamePrefix();
232 });
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500233
234 std::list<std::shared_ptr<RoutingTablePoolEntry>> rtpeList = (*nItr)->getRteList();
235
236 BOOST_CHECK_EQUAL(rtpeList.size(), 1);
237
238 auto& namePrefixPtrs = rtpeList.front()->namePrefixTableEntries;
239
240 // We should have removed the second one
241 BOOST_CHECK_EQUAL(namePrefixPtrs.size(), 1);
242
243 auto nptIterator = namePrefixPtrs.find(npte1.getNamePrefix());
244
245 BOOST_REQUIRE(nptIterator != namePrefixPtrs.end());
246 auto nptSharedPtr = nptIterator->second.lock();
247 BOOST_CHECK_EQUAL(*nptSharedPtr, npte1);
248}
249
250BOOST_FIXTURE_TEST_CASE(RoutingTableUpdate, NamePrefixTableFixture)
251{
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500252 const ndn::Name destination = ndn::Name{"/ndn/destination1"};
Junxiao Shi6593a432023-08-21 10:50:28 +0000253 NextHop hop1{ndn::FaceUri("upd4://10.0.0.1"), 0};
254 NextHop hop2{ndn::FaceUri("upd4://10.0.0.2"), 1};
255 NextHop hop3{ndn::FaceUri("upd4://10.0.0.3"), 2};
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500256 const NamePrefixTableEntry entry1{"/ndn/router1"};
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600257 npt.addEntry(entry1.getNamePrefix(), destination);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500258
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -0700259 rt.addNextHop(destination, hop1);
260 rt.addNextHop(destination, hop2);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500261
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -0700262 npt.updateWithNewRoute(rt.m_rTable);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500263
264 // At this point the NamePrefixTableEntry should have two NextHops.
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600265 auto nameIterator = std::find_if(npt.begin(), npt.end(),
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500266 [&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
267 return entry1.getNamePrefix() == entry->getNamePrefix();
268 });
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600269 BOOST_REQUIRE(nameIterator != npt.end());
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500270
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600271 auto iterator = npt.m_rtpool.find(destination);
272 BOOST_REQUIRE(iterator != npt.m_rtpool.end());
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500273 auto nextHops = (iterator->second)->getNexthopList();
Nick Gordonff9a6272017-10-12 13:38:29 -0500274 BOOST_CHECK_EQUAL(nextHops.size(), 2);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500275
276 // Add the other NextHop
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -0700277 rt.addNextHop(destination, hop3);
278 npt.updateWithNewRoute(rt.m_rTable);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500279
280 // At this point the NamePrefixTableEntry should have three NextHops.
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600281 nameIterator = std::find_if(npt.begin(), npt.end(),
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500282 [&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
283 return entry1.getNamePrefix() == entry->getNamePrefix();
284 });
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600285 BOOST_REQUIRE(nameIterator != npt.end());
286 iterator = npt.m_rtpool.find(destination);
287 BOOST_REQUIRE(iterator != npt.m_rtpool.end());
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500288 nextHops = (iterator->second)->getNexthopList();
Nick Gordonff9a6272017-10-12 13:38:29 -0500289 BOOST_CHECK_EQUAL(nextHops.size(), 3);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500290}
291
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -0700292BOOST_FIXTURE_TEST_CASE(UpdateFromLsdb, NamePrefixTableFixture)
293{
Davide Pesavento288141a2024-02-13 17:30:35 -0500294 auto testTimePoint = time::system_clock::now();
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -0700295 NamePrefixList npl1;
296 ndn::Name n1("name1");
297 ndn::Name n2("name2");
298 ndn::Name router1("/router1/1");
299
300 npl1.insert(n1);
301 npl1.insert(n2);
302
303 NameLsa nlsa1(router1, 12, testTimePoint, npl1);
304 std::shared_ptr<Lsa> lsaPtr = std::make_shared<NameLsa>(nlsa1);
305
306 BOOST_CHECK(npt.begin() == npt.end());
307 npt.updateFromLsdb(lsaPtr, LsdbUpdate::INSTALLED, {}, {});
308 BOOST_CHECK_EQUAL(npt.m_table.size(), 3); // Router + 2 names
309
310 BOOST_CHECK(isNameInNpt(n1));
311 BOOST_CHECK(isNameInNpt(n2));
312
313 ndn::Name n3("name3");
314 auto nlsa = std::static_pointer_cast<NameLsa>(lsaPtr);
315 nlsa->removeName(n2);
316 nlsa->addName(n3);
317 npt.updateFromLsdb(lsaPtr, LsdbUpdate::UPDATED, {n3}, {n2});
318 BOOST_CHECK(isNameInNpt(n1));
319 BOOST_CHECK(!isNameInNpt(n2)); // Removed
320 BOOST_CHECK(isNameInNpt(n3));
321
322 BOOST_CHECK_EQUAL(npt.m_table.size(), 3); // Still router + 2 names
323
324 npt.updateFromLsdb(lsaPtr, LsdbUpdate::REMOVED, {}, {});
325 BOOST_CHECK_EQUAL(npt.m_table.size(), 0);
326
327 // Adj and Coordinate LSAs router
328 ndn::Name router2("/router2/2");
Junxiao Shib8752932024-01-07 15:18:46 +0000329 AdjLsa adjLsa(router2, 12, testTimePoint, conf.getAdjacencyList());
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -0700330 lsaPtr = std::make_shared<AdjLsa>(adjLsa);
331 BOOST_CHECK(npt.begin() == npt.end());
332 npt.updateFromLsdb(lsaPtr, LsdbUpdate::INSTALLED, {}, {});
333 BOOST_CHECK_EQUAL(npt.m_table.size(), 1);
334 BOOST_CHECK(isNameInNpt(router2));
335
336 npt.updateFromLsdb(lsaPtr, LsdbUpdate::REMOVED, {}, {});
337 BOOST_CHECK_EQUAL(npt.m_table.size(), 0);
338
339 ndn::Name router3("/router3/3");
340 CoordinateLsa corLsa(router3, 12, testTimePoint, 2, {3});
341 lsaPtr = std::make_shared<CoordinateLsa>(corLsa);
342 BOOST_CHECK(npt.begin() == npt.end());
343 npt.updateFromLsdb(lsaPtr, LsdbUpdate::INSTALLED, {}, {});
344 BOOST_CHECK_EQUAL(npt.m_table.size(), 1);
345 BOOST_CHECK(isNameInNpt(router3));
346
347 npt.updateFromLsdb(lsaPtr, LsdbUpdate::REMOVED, {}, {});
348 BOOST_CHECK_EQUAL(npt.m_table.size(), 0);
349}
350
Vince Lehmancae33b62015-06-05 09:21:30 -0500351BOOST_AUTO_TEST_SUITE_END()
352
Davide Pesavento288141a2024-02-13 17:30:35 -0500353} // namespace nlsr::tests