Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Saurab Dulal | 427e012 | 2019-11-28 11:58:02 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2020, The University of Memphis, |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 4 | * Regents of the University of California |
| 5 | * |
| 6 | * This file is part of NLSR (Named-data Link State Routing). |
| 7 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 8 | * |
| 9 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 10 | * of the GNU General Public License as published by the Free Software Foundation, |
| 11 | * either version 3 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 14 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 19 | **/ |
| 20 | |
| 21 | #include "test-common.hpp" |
| 22 | |
| 23 | namespace nlsr { |
| 24 | namespace test { |
| 25 | |
| 26 | ndn::Data& |
| 27 | signData(ndn::Data& data) |
| 28 | { |
| 29 | ndn::SignatureSha256WithRsa fakeSignature; |
| 30 | fakeSignature.setValue(ndn::encoding::makeEmptyBlock(ndn::tlv::SignatureValue)); |
| 31 | data.setSignature(fakeSignature); |
| 32 | data.wireEncode(); |
| 33 | |
| 34 | return data; |
| 35 | } |
| 36 | |
Saurab Dulal | 427e012 | 2019-11-28 11:58:02 -0600 | [diff] [blame] | 37 | void |
| 38 | checkPrefixRegistered(const ndn::util::DummyClientFace& face, const ndn::Name& prefix) |
| 39 | { |
| 40 | bool registerCommandEmitted = false; |
| 41 | for (const auto& interest : face.sentInterests) { |
| 42 | if (interest.getName().size() > 4 && |
| 43 | interest.getName().get(3) == ndn::name::Component("register")) { |
| 44 | ndn::name::Component test = interest.getName().get(4); |
| 45 | ndn::nfd::ControlParameters params(test.blockFromValue()); |
| 46 | if (params.getName() == prefix) { |
| 47 | registerCommandEmitted = true; |
| 48 | break; |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | BOOST_CHECK(registerCommandEmitted); |
| 53 | } |
| 54 | |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 55 | MockNfdMgmtFixture::MockNfdMgmtFixture() |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 56 | : m_face(m_ioService, m_keyChain, {true, true}) |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 57 | { |
| 58 | } |
| 59 | |
| 60 | void |
| 61 | MockNfdMgmtFixture::signDatasetReply(ndn::Data& data) |
| 62 | { |
| 63 | signData(data); |
| 64 | } |
| 65 | |
| 66 | void |
| 67 | UnitTestTimeFixture::advanceClocks(const ndn::time::nanoseconds& tick, size_t nTicks) |
| 68 | { |
| 69 | for (size_t i = 0; i < nTicks; ++i) { |
| 70 | steadyClock->advance(tick); |
| 71 | systemClock->advance(tick); |
| 72 | |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 73 | if (m_ioService.stopped()) { |
| 74 | m_ioService.reset(); |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 75 | } |
| 76 | |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 77 | m_ioService.poll(); |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | |
| 81 | } // namespace test |
| 82 | } // namespace nlsr |