Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Nick Gordon | feae557 | 2017-01-13 12:06:26 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, The University of Memphis, |
Vince Lehman | c2e51f6 | 2015-01-20 15:03:11 -0600 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 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/>. |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 20 | **/ |
| 21 | |
| 22 | #include "test-common.hpp" |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 23 | |
| 24 | #include "nlsr.hpp" |
| 25 | #include "communication/sync-logic-handler.hpp" |
| 26 | |
Muktadir R Chowdhury | c69da0a | 2015-12-18 13:24:38 -0600 | [diff] [blame] | 27 | #include <ndn-cxx/util/dummy-client-face.hpp> |
| 28 | |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 29 | namespace nlsr { |
| 30 | namespace test { |
| 31 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 32 | using std::shared_ptr; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 33 | |
| 34 | class SyncLogicFixture : public BaseFixture |
| 35 | { |
| 36 | public: |
| 37 | SyncLogicFixture() |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 38 | : face(std::make_shared<ndn::util::DummyClientFace>()) |
| 39 | , nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain) |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 40 | , sync(nlsr.getLsdb().getSyncLogicHandler()) |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 41 | , CONFIG_NETWORK("/ndn") |
| 42 | , CONFIG_SITE("/site") |
| 43 | , CONFIG_ROUTER_NAME("/%C1.Router/this-router") |
| 44 | { |
| 45 | nlsr.getConfParameter().setNetwork(CONFIG_NETWORK); |
| 46 | nlsr.getConfParameter().setSiteName(CONFIG_SITE); |
| 47 | nlsr.getConfParameter().setRouterName(CONFIG_ROUTER_NAME); |
| 48 | nlsr.getConfParameter().buildRouterPrefix(); |
| 49 | } |
| 50 | |
| 51 | void |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 52 | receiveUpdate(std::string prefix, uint64_t seqNo, SyncLogicHandler& p_sync) |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 53 | { |
Ashlesh Gawande | 415676b | 2016-12-22 00:26:23 -0600 | [diff] [blame] | 54 | chronosync::MissingDataInfo info = {ndn::Name(prefix).appendNumber(1), 0, seqNo}; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 55 | |
Ashlesh Gawande | 415676b | 2016-12-22 00:26:23 -0600 | [diff] [blame] | 56 | std::vector<chronosync::MissingDataInfo> updates; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 57 | updates.push_back(info); |
| 58 | |
| 59 | face->processEvents(ndn::time::milliseconds(1)); |
Muktadir R Chowdhury | c69da0a | 2015-12-18 13:24:38 -0600 | [diff] [blame] | 60 | face->sentInterests.clear(); |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 61 | |
Ashlesh Gawande | 7600c90 | 2017-06-21 13:28:35 -0500 | [diff] [blame] | 62 | p_sync.onChronoSyncUpdate(updates); |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 63 | |
| 64 | face->processEvents(ndn::time::milliseconds(1)); |
| 65 | } |
| 66 | |
| 67 | public: |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 68 | std::shared_ptr<ndn::util::DummyClientFace> face; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 69 | Nlsr nlsr; |
Vince Lehman | c11cc20 | 2015-01-20 11:41:33 -0600 | [diff] [blame] | 70 | SyncLogicHandler& sync; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 71 | |
| 72 | const std::string CONFIG_NETWORK; |
| 73 | const std::string CONFIG_SITE; |
| 74 | const std::string CONFIG_ROUTER_NAME; |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 75 | const std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, AdjLsa::TYPE_STRING, |
| 76 | CoordinateLsa::TYPE_STRING}; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | BOOST_FIXTURE_TEST_SUITE(TestSyncLogicHandler, SyncLogicFixture) |
| 80 | |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 81 | BOOST_AUTO_TEST_CASE(UpdateForOtherLS) |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 82 | { |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 83 | std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, AdjLsa::TYPE_STRING}; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 84 | |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 85 | uint64_t syncSeqNo = 1; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 86 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 87 | for (const std::string& lsaType : lsaTypes) { |
| 88 | std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() + |
| 89 | CONFIG_SITE + "/%C1.Router/other-router/" + lsaType; |
Nick Gordon | e8e03ac | 2016-07-07 14:24:38 -0500 | [diff] [blame] | 90 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 91 | receiveUpdate(updateName, syncSeqNo, sync); |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 92 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 93 | std::vector<ndn::Interest>& interests = face->sentInterests; |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 94 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 95 | std::vector<ndn::Interest>::iterator it = interests.begin(); |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 96 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 97 | BOOST_REQUIRE_EQUAL(interests.size(), 1); |
| 98 | |
| 99 | BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "/"); |
| 100 | } |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | BOOST_AUTO_TEST_CASE(UpdateForOtherHR) |
| 104 | { |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 105 | Nlsr nlsr_hr(g_ioService, g_scheduler, std::ref(*face), g_keyChain); |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 106 | SyncLogicHandler& sync_hr(nlsr_hr.getLsdb().getSyncLogicHandler()); |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 107 | |
| 108 | nlsr_hr.getConfParameter().setNetwork(CONFIG_NETWORK); |
| 109 | nlsr_hr.getConfParameter().setSiteName(CONFIG_SITE); |
| 110 | nlsr_hr.getConfParameter().setRouterName(CONFIG_ROUTER_NAME); |
| 111 | nlsr_hr.getConfParameter().buildRouterPrefix(); |
| 112 | |
| 113 | nlsr_hr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_ON); |
| 114 | |
| 115 | nlsr_hr.initialize(); |
| 116 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 117 | uint64_t syncSeqNo = 1; |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 118 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 119 | std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, CoordinateLsa::TYPE_STRING}; |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 120 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 121 | for (const std::string& lsaType : lsaTypes) { |
| 122 | std::string updateName = nlsr_hr.getConfParameter().getLsaPrefix().toUri() + |
| 123 | CONFIG_SITE + "/%C1.Router/other-router/" + lsaType; |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 124 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 125 | receiveUpdate(updateName, syncSeqNo, sync_hr); |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 126 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 127 | std::vector<ndn::Interest>& interests = face->sentInterests; |
| 128 | std::vector<ndn::Interest>::iterator it = interests.begin(); |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 129 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 130 | BOOST_REQUIRE_EQUAL(interests.size(), 1); |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 131 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 132 | BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "/"); |
| 133 | } |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry) |
| 137 | { |
| 138 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 139 | Nlsr nlsr_hrdry(g_ioService, g_scheduler, std::ref(*face),g_keyChain); |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 140 | SyncLogicHandler& sync_hrdry(nlsr_hrdry.getLsdb().getSyncLogicHandler()); |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 141 | |
| 142 | nlsr_hrdry.getConfParameter().setNetwork(CONFIG_NETWORK); |
| 143 | nlsr_hrdry.getConfParameter().setSiteName(CONFIG_SITE); |
| 144 | nlsr_hrdry.getConfParameter().setRouterName(CONFIG_ROUTER_NAME); |
| 145 | nlsr_hrdry.getConfParameter().buildRouterPrefix(); |
| 146 | |
| 147 | nlsr_hrdry.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN); |
| 148 | |
| 149 | nlsr_hrdry.initialize(); |
| 150 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 151 | for (const std::string& lsaType : lsaTypes) { |
| 152 | |
| 153 | std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() + |
| 154 | CONFIG_SITE + "/%C1.Router/other-router/" + lsaType; |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 155 | |
| 156 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 157 | uint64_t syncSeqNo = 1; |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 158 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 159 | receiveUpdate(updateName, syncSeqNo, sync_hrdry); |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 160 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 161 | // In HR dry-state all LSA's should be published |
Davide Pesavento | c58cc7f | 2017-08-08 16:51:28 -0500 | [diff] [blame] | 162 | const auto& it = std::find_if(face->sentInterests.begin(), face->sentInterests.end(), |
| 163 | [updateName] (const ndn::Interest& interest) { |
| 164 | return interest.getName().getPrefix(-1) == updateName + "/"; |
| 165 | }); |
| 166 | BOOST_REQUIRE(it != face->sentInterests.end()); |
Nick Gordon | e8e03ac | 2016-07-07 14:24:38 -0500 | [diff] [blame] | 167 | } |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 168 | } |
| 169 | |
Nick Gordon | 0f1bf1d | 2017-06-22 15:40:27 -0500 | [diff] [blame] | 170 | BOOST_AUTO_TEST_CASE(NoUpdateForSelf) |
| 171 | { |
| 172 | for (const std::string& lsaType : lsaTypes) { |
| 173 | std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() + |
| 174 | CONFIG_SITE + CONFIG_ROUTER_NAME + lsaType; |
| 175 | |
| 176 | receiveUpdate(updateName, 1, sync); |
| 177 | |
| 178 | std::vector<ndn::Interest>& interests = face->sentInterests; |
| 179 | BOOST_CHECK_EQUAL(interests.size(), 0); |
| 180 | } |
| 181 | } |
| 182 | |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 183 | BOOST_AUTO_TEST_CASE(MalformedUpdate) |
| 184 | { |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 185 | for (const std::string& lsaType : lsaTypes) { |
| 186 | std::string updateName = CONFIG_SITE + nlsr.getConfParameter().getLsaPrefix().toUri() + |
| 187 | CONFIG_ROUTER_NAME + lsaType; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 188 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 189 | std::vector<ndn::Interest>& interests = face->sentInterests; |
| 190 | BOOST_CHECK_EQUAL(interests.size(), 0); |
| 191 | } |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | BOOST_AUTO_TEST_CASE(SequenceNumber) |
| 195 | { |
| 196 | std::string originRouter = CONFIG_NETWORK + CONFIG_SITE + "/%C1.Router/other-router/"; |
| 197 | |
| 198 | Lsdb& lsdb = nlsr.getLsdb(); |
| 199 | |
| 200 | // Install Name LSA |
| 201 | NamePrefixList nameList; |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 202 | NameLsa lsa(originRouter, 999, ndn::time::system_clock::TimePoint::max(), nameList); |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 203 | lsdb.installNameLsa(lsa); |
| 204 | |
| 205 | // Install Adj LSA |
| 206 | AdjacencyList adjList; |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 207 | AdjLsa adjLsa(originRouter, 1000, ndn::time::system_clock::TimePoint::max(), |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 208 | 3 , adjList); |
| 209 | lsdb.installAdjLsa(adjLsa); |
| 210 | |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 211 | std::vector<double> angles = {0.0}; |
| 212 | |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 213 | // Install Cor LSA |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 214 | CoordinateLsa corLsa(originRouter, 1000, ndn::time::system_clock::TimePoint::max(), |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 215 | 0, angles); |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 216 | lsdb.installCoordinateLsa(corLsa); |
| 217 | |
| 218 | std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() + |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 219 | CONFIG_SITE + "/%C1.Router/other-router/" + NameLsa::TYPE_STRING; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 220 | |
| 221 | // Lower NameLSA sequence number |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 222 | uint64_t lowerSeqNo = 998; |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 223 | receiveUpdate(updateName, lowerSeqNo, sync); |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 224 | |
Muktadir R Chowdhury | c69da0a | 2015-12-18 13:24:38 -0600 | [diff] [blame] | 225 | std::vector<ndn::Interest>& interests = face->sentInterests; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 226 | BOOST_REQUIRE_EQUAL(interests.size(), 0); |
| 227 | |
| 228 | // Same NameLSA sequence number |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 229 | uint64_t sameSeqNo = 999; |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 230 | receiveUpdate(updateName, sameSeqNo, sync); |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 231 | |
Muktadir R Chowdhury | c69da0a | 2015-12-18 13:24:38 -0600 | [diff] [blame] | 232 | interests = face->sentInterests; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 233 | BOOST_REQUIRE_EQUAL(interests.size(), 0); |
| 234 | |
| 235 | // Higher NameLSA sequence number |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 236 | uint64_t higherSeqNo = 1000; |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 237 | receiveUpdate(updateName, higherSeqNo, sync); |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 238 | |
Muktadir R Chowdhury | c69da0a | 2015-12-18 13:24:38 -0600 | [diff] [blame] | 239 | interests = face->sentInterests; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 240 | BOOST_REQUIRE_EQUAL(interests.size(), 1); |
| 241 | |
| 242 | std::vector<ndn::Interest>::iterator it = interests.begin(); |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 243 | BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "/"); |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 244 | } |
| 245 | |
Vince Lehman | c11cc20 | 2015-01-20 11:41:33 -0600 | [diff] [blame] | 246 | BOOST_AUTO_TEST_CASE(UpdatePrefix) |
| 247 | { |
| 248 | ndn::Name expectedPrefix = nlsr.getConfParameter().getLsaPrefix(); |
| 249 | expectedPrefix.append(CONFIG_SITE); |
| 250 | expectedPrefix.append(CONFIG_ROUTER_NAME); |
| 251 | |
| 252 | nlsr.initialize(); |
| 253 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 254 | BOOST_CHECK_EQUAL(sync.m_nameLsaUserPrefix, ndn::Name(expectedPrefix).append(NameLsa::TYPE_STRING)); |
| 255 | BOOST_CHECK_EQUAL(sync.m_adjLsaUserPrefix, ndn::Name(expectedPrefix).append(AdjLsa::TYPE_STRING)); |
| 256 | BOOST_CHECK_EQUAL(sync.m_coorLsaUserPrefix, ndn::Name(expectedPrefix).append(CoordinateLsa::TYPE_STRING)); |
Vince Lehman | c11cc20 | 2015-01-20 11:41:33 -0600 | [diff] [blame] | 257 | } |
| 258 | |
Vince Lehman | 9d09780 | 2015-03-16 17:55:59 -0500 | [diff] [blame] | 259 | BOOST_AUTO_TEST_CASE(CreateSyncSocketOnInitialization) // Bug #2649 |
| 260 | { |
| 261 | nlsr.initialize(); |
| 262 | |
| 263 | // Make sure an adjacency LSA has not been built yet |
| 264 | ndn::Name key = ndn::Name(nlsr.getConfParameter().getRouterPrefix()).append(AdjLsa::TYPE_STRING); |
| 265 | AdjLsa* lsa = nlsr.getLsdb().findAdjLsa(key); |
| 266 | BOOST_REQUIRE(lsa == nullptr); |
| 267 | |
| 268 | // Publish a routing update before an Adjacency LSA is built |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 269 | BOOST_CHECK_NO_THROW(sync.publishRoutingUpdate(AdjLsa::TYPE_STRING, 0)); |
Vince Lehman | 9d09780 | 2015-03-16 17:55:59 -0500 | [diff] [blame] | 270 | } |
| 271 | |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 272 | BOOST_AUTO_TEST_SUITE_END() |
| 273 | |
| 274 | } // namespace test |
| 275 | } // namespace nlsr |