blob: b2db763cd2043dcd2d609c1b6a31c1ac81dbaa3d [file] [log] [blame]
Nick Gordond5c1a372016-10-31 13:56:23 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Ashlesh Gawande7a231c02020-06-12 20:06:44 -07002/*
Saurab Dulal427e0122019-11-28 11:58:02 -06003 * Copyright (c) 2014-2020, The University of Memphis,
Nick Gordond5c1a372016-10-31 13:56:23 -05004 * 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/>.
Ashlesh Gawande7a231c02020-06-12 20:06:44 -070019 */
Nick Gordond5c1a372016-10-31 13:56:23 -050020
21#include "test-common.hpp"
22
23namespace nlsr {
24namespace test {
25
26ndn::Data&
27signData(ndn::Data& data)
28{
Ashlesh Gawande7a231c02020-06-12 20:06:44 -070029 data.setSignatureInfo(ndn::SignatureInfo(ndn::tlv::SignatureTypeValue::SignatureSha256WithRsa));
30 data.setSignatureValue(ndn::encoding::makeEmptyBlock(ndn::tlv::SignatureValue).getBuffer());
Nick Gordond5c1a372016-10-31 13:56:23 -050031 data.wireEncode();
32
33 return data;
34}
35
Saurab Dulal427e0122019-11-28 11:58:02 -060036void
37checkPrefixRegistered(const ndn::util::DummyClientFace& face, const ndn::Name& prefix)
38{
39 bool registerCommandEmitted = false;
40 for (const auto& interest : face.sentInterests) {
41 if (interest.getName().size() > 4 &&
42 interest.getName().get(3) == ndn::name::Component("register")) {
43 ndn::name::Component test = interest.getName().get(4);
44 ndn::nfd::ControlParameters params(test.blockFromValue());
45 if (params.getName() == prefix) {
46 registerCommandEmitted = true;
47 break;
48 }
49 }
50 }
51 BOOST_CHECK(registerCommandEmitted);
52}
53
Nick Gordond5c1a372016-10-31 13:56:23 -050054MockNfdMgmtFixture::MockNfdMgmtFixture()
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050055 : m_face(m_ioService, m_keyChain, {true, true})
Nick Gordond5c1a372016-10-31 13:56:23 -050056{
57}
58
59void
60MockNfdMgmtFixture::signDatasetReply(ndn::Data& data)
61{
62 signData(data);
63}
64
65void
66UnitTestTimeFixture::advanceClocks(const ndn::time::nanoseconds& tick, size_t nTicks)
67{
68 for (size_t i = 0; i < nTicks; ++i) {
69 steadyClock->advance(tick);
70 systemClock->advance(tick);
71
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050072 if (m_ioService.stopped()) {
73 m_ioService.reset();
Nick Gordond5c1a372016-10-31 13:56:23 -050074 }
75
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050076 m_ioService.poll();
Nick Gordond5c1a372016-10-31 13:56:23 -050077 }
78}
79
80} // namespace test
81} // namespace nlsr