blob: 3a1ffebc7e327e316f1650fd497761f7aa4910ce [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/*
Davide Pesavento8de8a8b2022-05-12 01:26:43 -04003 * Copyright (c) 2014-2022, 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
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040021#include "tests/test-common.hpp"
22
23#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
Nick Gordond5c1a372016-10-31 13:56:23 -050024
25namespace nlsr {
26namespace test {
27
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040028std::shared_ptr<ndn::Data>
29makeData(const ndn::Name& name)
30{
31 auto data = std::make_shared<ndn::Data>(name);
32 return signData(data);
33}
34
Nick Gordond5c1a372016-10-31 13:56:23 -050035ndn::Data&
36signData(ndn::Data& data)
37{
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040038 data.setSignatureInfo(ndn::SignatureInfo(ndn::tlv::NullSignature));
39 data.setSignatureValue(std::make_shared<ndn::Buffer>());
Nick Gordond5c1a372016-10-31 13:56:23 -050040 data.wireEncode();
Nick Gordond5c1a372016-10-31 13:56:23 -050041 return data;
42}
43
Saurab Dulal427e0122019-11-28 11:58:02 -060044void
45checkPrefixRegistered(const ndn::util::DummyClientFace& face, const ndn::Name& prefix)
46{
47 bool registerCommandEmitted = false;
48 for (const auto& interest : face.sentInterests) {
49 if (interest.getName().size() > 4 &&
50 interest.getName().get(3) == ndn::name::Component("register")) {
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040051 auto test = interest.getName().get(4);
Saurab Dulal427e0122019-11-28 11:58:02 -060052 ndn::nfd::ControlParameters params(test.blockFromValue());
53 if (params.getName() == prefix) {
54 registerCommandEmitted = true;
55 break;
56 }
57 }
58 }
59 BOOST_CHECK(registerCommandEmitted);
60}
61
Nick Gordond5c1a372016-10-31 13:56:23 -050062} // namespace test
63} // namespace nlsr