blob: 3373916d153a3bc42f62f3d8783362f496648cac [file] [log] [blame]
Vince Lehman7c603292014-09-11 17:48:16 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Alexander Afanasyev67758b12018-03-06 18:36:44 -05002/*
Davide Pesavento288141a2024-02-13 17:30:35 -05003 * Copyright (c) 2014-2024, The University of Memphis,
Alexander Afanasyev67758b12018-03-06 18:36:44 -05004 * Regents of the University of California,
5 * Arizona Board of Regents.
Vince Lehman7c603292014-09-11 17:48:16 -05006 *
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/>.
Alexander Afanasyev67758b12018-03-06 18:36:44 -050020 */
Vince Lehman7c603292014-09-11 17:48:16 -050021
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040022#ifndef NLSR_TESTS_TEST_COMMON_HPP
23#define NLSR_TESTS_TEST_COMMON_HPP
Vince Lehman7c603292014-09-11 17:48:16 -050024
Ashlesh Gawande85998a12017-12-07 22:22:13 -060025#include "conf-parameter.hpp"
Vince Lehman0a7da612014-10-29 14:39:29 -050026
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040027#include "tests/boost-test.hpp"
Davide Pesaventocb065f12019-12-27 01:03:34 -050028
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040029#include <ndn-cxx/data.hpp>
Nick Gordond5c1a372016-10-31 13:56:23 -050030#include <ndn-cxx/util/dummy-client-face.hpp>
31
Davide Pesavento288141a2024-02-13 17:30:35 -050032namespace nlsr::tests {
Vince Lehman7c603292014-09-11 17:48:16 -050033
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040034/**
35 * \brief Create a Data with a null (i.e., empty) signature
36 *
37 * If a "real" signature is desired, use KeyChainFixture and sign again with `m_keyChain`.
38 */
39std::shared_ptr<ndn::Data>
40makeData(const ndn::Name& name);
41
42/**
43 * \brief Add a null signature to \p data
44 */
Nick Gordond5c1a372016-10-31 13:56:23 -050045ndn::Data&
46signData(ndn::Data& data);
47
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040048/**
49 * \brief Add a null signature to \p data
Nick Gordond5c1a372016-10-31 13:56:23 -050050 */
Davide Pesaventod90338d2021-01-07 17:50:05 -050051inline std::shared_ptr<ndn::Data>
52signData(std::shared_ptr<ndn::Data> data)
Nick Gordond5c1a372016-10-31 13:56:23 -050053{
54 signData(*data);
55 return data;
56}
57
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040058void
Junxiao Shi43f37a02023-08-09 00:09:00 +000059checkPrefixRegistered(const ndn::DummyClientFace& face, const ndn::Name& prefix);
Nick Gordond5c1a372016-10-31 13:56:23 -050060
Ashlesh Gawande85998a12017-12-07 22:22:13 -060061class DummyConfFileProcessor
62{
Ashlesh Gawande85998a12017-12-07 22:22:13 -060063public:
64 DummyConfFileProcessor(ConfParameter& conf,
Davide Pesavento1954a0c2022-09-30 15:56:04 -040065 SyncProtocol protocol = SyncProtocol::PSYNC,
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040066 HyperbolicState hyperbolicState = HYPERBOLIC_STATE_OFF,
67 const ndn::Name& networkName = "/ndn",
68 const ndn::Name& siteName = "/site",
69 const ndn::Name& routerName = "/%C1.Router/this-router")
Ashlesh Gawande85998a12017-12-07 22:22:13 -060070 {
Saurab Dulal427e0122019-11-28 11:58:02 -060071 conf.setNetwork(networkName);
72 conf.setSiteName(siteName);
73 conf.setRouterName(routerName);
Ashlesh Gawande6b388fc2019-09-30 10:14:41 -050074 conf.buildRouterAndSyncUserPrefix();
Ashlesh Gawande85998a12017-12-07 22:22:13 -060075 conf.setSyncProtocol(protocol);
Ashlesh Gawande6b388fc2019-09-30 10:14:41 -050076 conf.setHyperbolicState(hyperbolicState);
Ashlesh Gawande85998a12017-12-07 22:22:13 -060077 }
78};
79
Davide Pesavento288141a2024-02-13 17:30:35 -050080} // namespace nlsr::tests
Vince Lehman7c603292014-09-11 17:48:16 -050081
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040082#endif // NLSR_TESTS_TEST_COMMON_HPP