blob: 14256038dd95cfd7ae910125b5cbb80fc45e4b8e [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/*
Davide Pesavento658fd852023-05-10 22:15:03 -04003 * Copyright (c) 2014-2023, 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
30namespace nlsr {
31namespace test {
32
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040033class NamePrefixTableFixture : public IoKeyChainFixture
Vince Lehmancae33b62015-06-05 09:21:30 -050034{
35public:
36 NamePrefixTableFixture()
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040037 : lsdb(face, m_keyChain, conf)
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -070038 , fib(face, m_scheduler, conf.getAdjacencyList(), conf, m_keyChain)
39 , rt(m_scheduler, lsdb, conf)
40 , npt(conf.getRouterPrefix(), fib, rt, rt.afterRoutingChange, lsdb.onLsdbModified)
Vince Lehmancae33b62015-06-05 09:21:30 -050041 {
Vince Lehmancae33b62015-06-05 09:21:30 -050042 }
43
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -070044 bool
45 isNameInNpt(const ndn::Name& name)
46 {
47 auto it = std::find_if(npt.begin(), npt.end(),
48 [&] (const auto& entry) { return name == entry->getNamePrefix(); });
49 return it != npt.end();
50 }
51
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040052private:
53 ndn::Scheduler m_scheduler{m_io};
54
Vince Lehmancae33b62015-06-05 09:21:30 -050055public:
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040056 ndn::util::DummyClientFace face{m_io, m_keyChain};
57 ConfParameter conf{face, m_keyChain};
58 DummyConfFileProcessor confProcessor{conf};
Vince Lehmancae33b62015-06-05 09:21:30 -050059
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -070060 Lsdb lsdb;
61 Fib fib;
62 RoutingTable rt;
63 NamePrefixTable npt;
Vince Lehmancae33b62015-06-05 09:21:30 -050064};
65
66BOOST_AUTO_TEST_SUITE(TestNamePrefixTable)
67
68BOOST_FIXTURE_TEST_CASE(Bupt, NamePrefixTableFixture)
69{
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -070070 rt.m_routingCalcInterval = 0_s;
Vince Lehmancae33b62015-06-05 09:21:30 -050071
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050072 Adjacent thisRouter(conf.getRouterPrefix(), ndn::FaceUri("udp4://10.0.0.1"), 0, Adjacent::STATUS_ACTIVE, 0, 0);
Vince Lehmancae33b62015-06-05 09:21:30 -050073
74 ndn::Name buptRouterName("/ndn/cn/edu/bupt/%C1.Router/bupthub");
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050075 Adjacent bupt(buptRouterName, ndn::FaceUri("udp4://10.0.0.2"), 0, Adjacent::STATUS_ACTIVE, 0, 0);
Vince Lehmancae33b62015-06-05 09:21:30 -050076
77 // This router's Adjacency LSA
Ashlesh Gawande85998a12017-12-07 22:22:13 -060078 conf.getAdjacencyList().insert(bupt);
Ashlesh Gawanded02c3882015-12-29 16:02:51 -060079 AdjLsa thisRouterAdjLsa(thisRouter.getName(), 1,
Ashlesh Gawande57a87172020-05-09 19:47:06 -070080 ndn::time::system_clock::now() + 3600_s,
Vince Lehmancae33b62015-06-05 09:21:30 -050081 2,
Ashlesh Gawande85998a12017-12-07 22:22:13 -060082 conf.getAdjacencyList());
Vince Lehmancae33b62015-06-05 09:21:30 -050083
Ashlesh Gawande57a87172020-05-09 19:47:06 -070084 lsdb.installLsa(std::make_shared<AdjLsa>(thisRouterAdjLsa));
Vince Lehmancae33b62015-06-05 09:21:30 -050085
86 // BUPT Adjacency LSA
87 AdjacencyList buptAdjacencies;
88 buptAdjacencies.insert(thisRouter);
Ashlesh Gawanded02c3882015-12-29 16:02:51 -060089 AdjLsa buptAdjLsa(buptRouterName, 1,
Vince Lehmancae33b62015-06-05 09:21:30 -050090 ndn::time::system_clock::now() + ndn::time::seconds(5),
91 0 , buptAdjacencies);
92
Ashlesh Gawande57a87172020-05-09 19:47:06 -070093 lsdb.installLsa(std::make_shared<AdjLsa>(buptAdjLsa));
Vince Lehmancae33b62015-06-05 09:21:30 -050094
95 // BUPT Name LSA
96 ndn::Name buptAdvertisedName("/ndn/cn/edu/bupt");
97
Nick Gordon96861ca2017-10-17 18:25:21 -050098 NamePrefixList buptNames{buptAdvertisedName};
Vince Lehmancae33b62015-06-05 09:21:30 -050099
Ashlesh Gawande57a87172020-05-09 19:47:06 -0700100 NameLsa buptNameLsa(buptRouterName, 1, ndn::time::system_clock::now() + ndn::time::seconds(5),
Vince Lehmancae33b62015-06-05 09:21:30 -0500101 buptNames);
102
Ashlesh Gawande57a87172020-05-09 19:47:06 -0700103 lsdb.installLsa(std::make_shared<NameLsa>(buptNameLsa));
Vince Lehmancae33b62015-06-05 09:21:30 -0500104
105 // Advance clocks to expire LSAs
106 this->advanceClocks(ndn::time::seconds(15));
107
108 // LSA expirations should cause NPT entries to be completely removed
109 NamePrefixTable::const_iterator it = npt.begin();
110 BOOST_REQUIRE(it == npt.end());
111
112 // Install new name LSA
Ashlesh Gawanded02c3882015-12-29 16:02:51 -0600113 NameLsa buptNewNameLsa(buptRouterName, 12,
Vince Lehmancae33b62015-06-05 09:21:30 -0500114 ndn::time::system_clock::now() + ndn::time::seconds(3600),
115 buptNames);
116
Ashlesh Gawande57a87172020-05-09 19:47:06 -0700117 lsdb.installLsa(std::make_shared<NameLsa>(buptNewNameLsa));
Vince Lehmancae33b62015-06-05 09:21:30 -0500118
119 this->advanceClocks(ndn::time::seconds(1));
120
121 // Install new adjacency LSA
Ashlesh Gawanded02c3882015-12-29 16:02:51 -0600122 AdjLsa buptNewAdjLsa(buptRouterName, 12,
Vince Lehmancae33b62015-06-05 09:21:30 -0500123 ndn::time::system_clock::now() + ndn::time::seconds(3600),
124 0, buptAdjacencies);
Ashlesh Gawande57a87172020-05-09 19:47:06 -0700125 lsdb.installLsa(std::make_shared<AdjLsa>(buptNewAdjLsa));
Vince Lehmancae33b62015-06-05 09:21:30 -0500126
127 this->advanceClocks(ndn::time::seconds(1));
128
129 // Each NPT entry should have a destination router
130 it = npt.begin();
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500131 BOOST_REQUIRE_EQUAL((*it)->getNamePrefix(), buptRouterName);
132 BOOST_REQUIRE_EQUAL((*it)->getRteList().size(), 1);
133 BOOST_CHECK_EQUAL((*(*it)->getRteList().begin())->getDestination(), buptRouterName);
Vince Lehmancae33b62015-06-05 09:21:30 -0500134
135 ++it;
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500136 BOOST_REQUIRE_EQUAL((*it)->getNamePrefix(), buptAdvertisedName);
137 BOOST_REQUIRE_EQUAL((*it)->getRteList().size(), 1);
138 BOOST_CHECK_EQUAL((*(*it)->getRteList().begin())->getDestination(), buptRouterName);
Nick Gordonb50e51b2016-07-22 16:05:57 -0500139}
140
141BOOST_FIXTURE_TEST_CASE(AddEntryToPool, NamePrefixTableFixture)
142{
Nick Gordonb50e51b2016-07-22 16:05:57 -0500143 RoutingTablePoolEntry rtpe1("router1");
144
145 npt.addRtpeToPool(rtpe1);
146
147 BOOST_CHECK_EQUAL(npt.m_rtpool.size(), 1);
148 BOOST_CHECK_EQUAL(*(npt.m_rtpool.find("router1")->second), rtpe1);
149}
150
151BOOST_FIXTURE_TEST_CASE(RemoveEntryFromPool, NamePrefixTableFixture)
152{
Nick Gordonb50e51b2016-07-22 16:05:57 -0500153 RoutingTablePoolEntry rtpe1("router1", 0);
dmcoomes9f936662017-03-02 10:33:09 -0600154 std::shared_ptr<RoutingTablePoolEntry> rtpePtr = npt.addRtpeToPool(rtpe1);
Nick Gordonb50e51b2016-07-22 16:05:57 -0500155
156 npt.addRtpeToPool(rtpe1);
157
158 npt.deleteRtpeFromPool(rtpePtr);
159
160 BOOST_CHECK_EQUAL(npt.m_rtpool.size(), 0);
161 BOOST_CHECK_EQUAL(npt.m_rtpool.count("router1"), 0);
162}
163
164BOOST_FIXTURE_TEST_CASE(AddRoutingEntryToNptEntry, NamePrefixTableFixture)
165{
Nick Gordonb50e51b2016-07-22 16:05:57 -0500166 RoutingTablePoolEntry rtpe1("/ndn/memphis/rtr1", 0);
dmcoomes9f936662017-03-02 10:33:09 -0600167 std::shared_ptr<RoutingTablePoolEntry> rtpePtr = npt.addRtpeToPool(rtpe1);
Nick Gordonb50e51b2016-07-22 16:05:57 -0500168 NamePrefixTableEntry npte1("/ndn/memphis/rtr2");
169
170 npt.addEntry("/ndn/memphis/rtr2", "/ndn/memphis/rtr1");
171
172 NamePrefixTable::NptEntryList::iterator nItr =
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500173 std::find_if(npt.m_table.begin(),
174 npt.m_table.end(),
175 [&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
176 return entry->getNamePrefix() == npte1.getNamePrefix();
177 });
Nick Gordonb50e51b2016-07-22 16:05:57 -0500178
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500179 std::list<std::shared_ptr<RoutingTablePoolEntry>> rtpeList = (*nItr)->getRteList();
dmcoomes9f936662017-03-02 10:33:09 -0600180 std::list<std::shared_ptr<RoutingTablePoolEntry>>::iterator rItr =
Nick Gordonb50e51b2016-07-22 16:05:57 -0500181 std::find(rtpeList.begin(),
182 rtpeList.end(),
183 rtpePtr);
184 BOOST_CHECK_EQUAL(**rItr, *rtpePtr);
185}
186
187BOOST_FIXTURE_TEST_CASE(RemoveRoutingEntryFromNptEntry, NamePrefixTableFixture)
188{
Nick Gordonb50e51b2016-07-22 16:05:57 -0500189 RoutingTablePoolEntry rtpe1("/ndn/memphis/rtr1", 0);
190
191 NamePrefixTableEntry npte1("/ndn/memphis/rtr2");
Davide Pesaventod90338d2021-01-07 17:50:05 -0500192 npt.m_table.push_back(std::make_shared<NamePrefixTableEntry>(npte1));
Nick Gordonb50e51b2016-07-22 16:05:57 -0500193
194 npt.addEntry("/ndn/memphis/rtr2", "/ndn/memphis/rtr1");
195 npt.addEntry("/ndn/memphis/rtr2", "/ndn/memphis/altrtr");
196
197 npt.removeEntry("/ndn/memphis/rtr2", "/ndn/memphis/rtr1");
198
199 NamePrefixTable::NptEntryList::iterator nItr =
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500200 std::find_if(npt.m_table.begin(),
201 npt.m_table.end(),
202 [&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
203 return entry->getNamePrefix() == npte1.getNamePrefix();
204 });
Nick Gordonb50e51b2016-07-22 16:05:57 -0500205
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500206 std::list<std::shared_ptr<RoutingTablePoolEntry>> rtpeList = (*nItr)->getRteList();
Nick Gordonb50e51b2016-07-22 16:05:57 -0500207
208 BOOST_CHECK_EQUAL(rtpeList.size(), 1);
209 BOOST_CHECK_EQUAL(npt.m_rtpool.size(), 1);
Vince Lehmancae33b62015-06-05 09:21:30 -0500210}
211
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500212BOOST_FIXTURE_TEST_CASE(AddNptEntryPtrToRoutingEntry, NamePrefixTableFixture)
213{
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500214 NamePrefixTableEntry npte1("/ndn/memphis/rtr2");
Davide Pesaventod90338d2021-01-07 17:50:05 -0500215 npt.m_table.push_back(std::make_shared<NamePrefixTableEntry>(npte1));
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500216
217 npt.addEntry("/ndn/memphis/rtr2", "/ndn/memphis/rtr1");
218
219 NamePrefixTable::NptEntryList::iterator nItr =
220 std::find_if(npt.m_table.begin(),
221 npt.m_table.end(),
222 [&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
223 return entry->getNamePrefix() == npte1.getNamePrefix();
224 });
225
226 std::list<std::shared_ptr<RoutingTablePoolEntry>> rtpeList = (*nItr)->getRteList();
227
228 BOOST_CHECK_EQUAL(rtpeList.size(), 1);
229
230 auto& namePrefixPtrs = rtpeList.front()->namePrefixTableEntries;
231
232 auto nptIterator = namePrefixPtrs.find(npte1.getNamePrefix());
233 BOOST_REQUIRE(nptIterator != namePrefixPtrs.end());
234 auto nptSharedPtr = nptIterator->second.lock();
235 BOOST_CHECK_EQUAL(*nptSharedPtr, npte1);
236}
237
238BOOST_FIXTURE_TEST_CASE(RemoveNptEntryPtrFromRoutingEntry, NamePrefixTableFixture)
239{
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500240 NamePrefixTableEntry npte1("/ndn/memphis/rtr1");
241 NamePrefixTableEntry npte2("/ndn/memphis/rtr2");
242 RoutingTableEntry rte1("/ndn/memphis/destination1");
Davide Pesaventod90338d2021-01-07 17:50:05 -0500243 npt.m_table.push_back(std::make_shared<NamePrefixTableEntry>(npte1));
244 npt.m_table.push_back(std::make_shared<NamePrefixTableEntry>(npte2));
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500245
246 npt.addEntry(npte1.getNamePrefix(), rte1.getDestination());
247 // We have to add two entries, otherwise the routing pool entry will be deleted.
248 npt.addEntry(npte2.getNamePrefix(), rte1.getDestination());
249 npt.removeEntry(npte2.getNamePrefix(), rte1.getDestination());
250
251 NamePrefixTable::NptEntryList::iterator nItr =
252 std::find_if(npt.m_table.begin(),
253 npt.m_table.end(),
254 [&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
255 return entry->getNamePrefix() == npte1.getNamePrefix();
256 });
257
258 std::list<std::shared_ptr<RoutingTablePoolEntry>> rtpeList = (*nItr)->getRteList();
259
260 BOOST_CHECK_EQUAL(rtpeList.size(), 1);
261
262 auto& namePrefixPtrs = rtpeList.front()->namePrefixTableEntries;
263
264 // We should have removed the second one
265 BOOST_CHECK_EQUAL(namePrefixPtrs.size(), 1);
266
267 auto nptIterator = namePrefixPtrs.find(npte1.getNamePrefix());
268
269 BOOST_REQUIRE(nptIterator != namePrefixPtrs.end());
270 auto nptSharedPtr = nptIterator->second.lock();
271 BOOST_CHECK_EQUAL(*nptSharedPtr, npte1);
272}
273
274BOOST_FIXTURE_TEST_CASE(RoutingTableUpdate, NamePrefixTableFixture)
275{
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500276 const ndn::Name destination = ndn::Name{"/ndn/destination1"};
277 NextHop hop1{"upd4://10.0.0.1", 0};
278 NextHop hop2{"udp4://10.0.0.2", 1};
279 NextHop hop3{"udp4://10.0.0.3", 2};
280 const NamePrefixTableEntry entry1{"/ndn/router1"};
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600281 npt.addEntry(entry1.getNamePrefix(), destination);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500282
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -0700283 rt.addNextHop(destination, hop1);
284 rt.addNextHop(destination, hop2);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500285
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -0700286 npt.updateWithNewRoute(rt.m_rTable);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500287
288 // At this point the NamePrefixTableEntry should have two NextHops.
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600289 auto nameIterator = std::find_if(npt.begin(), npt.end(),
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500290 [&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
291 return entry1.getNamePrefix() == entry->getNamePrefix();
292 });
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600293 BOOST_REQUIRE(nameIterator != npt.end());
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500294
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600295 auto iterator = npt.m_rtpool.find(destination);
296 BOOST_REQUIRE(iterator != npt.m_rtpool.end());
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500297 auto nextHops = (iterator->second)->getNexthopList();
Nick Gordonff9a6272017-10-12 13:38:29 -0500298 BOOST_CHECK_EQUAL(nextHops.size(), 2);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500299
300 // Add the other NextHop
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -0700301 rt.addNextHop(destination, hop3);
302 npt.updateWithNewRoute(rt.m_rTable);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500303
304 // At this point the NamePrefixTableEntry should have three NextHops.
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600305 nameIterator = std::find_if(npt.begin(), npt.end(),
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500306 [&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
307 return entry1.getNamePrefix() == entry->getNamePrefix();
308 });
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600309 BOOST_REQUIRE(nameIterator != npt.end());
310 iterator = npt.m_rtpool.find(destination);
311 BOOST_REQUIRE(iterator != npt.m_rtpool.end());
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500312 nextHops = (iterator->second)->getNexthopList();
Nick Gordonff9a6272017-10-12 13:38:29 -0500313 BOOST_CHECK_EQUAL(nextHops.size(), 3);
Nick Gordonc0c6bcf2017-08-15 18:11:21 -0500314}
315
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -0700316BOOST_FIXTURE_TEST_CASE(UpdateFromLsdb, NamePrefixTableFixture)
317{
Davide Pesavento658fd852023-05-10 22:15:03 -0400318 auto testTimePoint = ndn::time::system_clock::now();
Ashlesh Gawande5d93aa52020-06-13 18:57:45 -0700319 NamePrefixList npl1;
320 ndn::Name n1("name1");
321 ndn::Name n2("name2");
322 ndn::Name router1("/router1/1");
323
324 npl1.insert(n1);
325 npl1.insert(n2);
326
327 NameLsa nlsa1(router1, 12, testTimePoint, npl1);
328 std::shared_ptr<Lsa> lsaPtr = std::make_shared<NameLsa>(nlsa1);
329
330 BOOST_CHECK(npt.begin() == npt.end());
331 npt.updateFromLsdb(lsaPtr, LsdbUpdate::INSTALLED, {}, {});
332 BOOST_CHECK_EQUAL(npt.m_table.size(), 3); // Router + 2 names
333
334 BOOST_CHECK(isNameInNpt(n1));
335 BOOST_CHECK(isNameInNpt(n2));
336
337 ndn::Name n3("name3");
338 auto nlsa = std::static_pointer_cast<NameLsa>(lsaPtr);
339 nlsa->removeName(n2);
340 nlsa->addName(n3);
341 npt.updateFromLsdb(lsaPtr, LsdbUpdate::UPDATED, {n3}, {n2});
342 BOOST_CHECK(isNameInNpt(n1));
343 BOOST_CHECK(!isNameInNpt(n2)); // Removed
344 BOOST_CHECK(isNameInNpt(n3));
345
346 BOOST_CHECK_EQUAL(npt.m_table.size(), 3); // Still router + 2 names
347
348 npt.updateFromLsdb(lsaPtr, LsdbUpdate::REMOVED, {}, {});
349 BOOST_CHECK_EQUAL(npt.m_table.size(), 0);
350
351 // Adj and Coordinate LSAs router
352 ndn::Name router2("/router2/2");
353 AdjLsa adjLsa(router2, 12, testTimePoint, 2, conf.getAdjacencyList());
354 lsaPtr = std::make_shared<AdjLsa>(adjLsa);
355 BOOST_CHECK(npt.begin() == npt.end());
356 npt.updateFromLsdb(lsaPtr, LsdbUpdate::INSTALLED, {}, {});
357 BOOST_CHECK_EQUAL(npt.m_table.size(), 1);
358 BOOST_CHECK(isNameInNpt(router2));
359
360 npt.updateFromLsdb(lsaPtr, LsdbUpdate::REMOVED, {}, {});
361 BOOST_CHECK_EQUAL(npt.m_table.size(), 0);
362
363 ndn::Name router3("/router3/3");
364 CoordinateLsa corLsa(router3, 12, testTimePoint, 2, {3});
365 lsaPtr = std::make_shared<CoordinateLsa>(corLsa);
366 BOOST_CHECK(npt.begin() == npt.end());
367 npt.updateFromLsdb(lsaPtr, LsdbUpdate::INSTALLED, {}, {});
368 BOOST_CHECK_EQUAL(npt.m_table.size(), 1);
369 BOOST_CHECK(isNameInNpt(router3));
370
371 npt.updateFromLsdb(lsaPtr, LsdbUpdate::REMOVED, {}, {});
372 BOOST_CHECK_EQUAL(npt.m_table.size(), 0);
373}
374
Vince Lehmancae33b62015-06-05 09:21:30 -0500375BOOST_AUTO_TEST_SUITE_END()
376
377} // namespace test
378} // namespace nlsr