blob: 5c95a0cd707cf8a563c0192eb6910e5e5811ba67 [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 Pesaventoe28d8752022-03-19 03:55:25 -04003 * Copyright (c) 2014-2022, 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
Vince Lehman7c603292014-09-11 17:48:16 -050032namespace nlsr {
33namespace test {
34
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040035/**
36 * \brief Create a Data with a null (i.e., empty) signature
37 *
38 * If a "real" signature is desired, use KeyChainFixture and sign again with `m_keyChain`.
39 */
40std::shared_ptr<ndn::Data>
41makeData(const ndn::Name& name);
42
43/**
44 * \brief Add a null signature to \p data
45 */
Nick Gordond5c1a372016-10-31 13:56:23 -050046ndn::Data&
47signData(ndn::Data& data);
48
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040049/**
50 * \brief Add a null signature to \p data
Nick Gordond5c1a372016-10-31 13:56:23 -050051 */
Davide Pesaventod90338d2021-01-07 17:50:05 -050052inline std::shared_ptr<ndn::Data>
53signData(std::shared_ptr<ndn::Data> data)
Nick Gordond5c1a372016-10-31 13:56:23 -050054{
55 signData(*data);
56 return data;
57}
58
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040059void
60checkPrefixRegistered(const ndn::util::DummyClientFace& face, const ndn::Name& prefix);
Nick Gordond5c1a372016-10-31 13:56:23 -050061
Ashlesh Gawande85998a12017-12-07 22:22:13 -060062class DummyConfFileProcessor
63{
Ashlesh Gawande85998a12017-12-07 22:22:13 -060064public:
65 DummyConfFileProcessor(ConfParameter& conf,
Ashlesh Gawande30d96e42021-03-21 19:15:33 -070066 SyncProtocol protocol = SYNC_PROTOCOL_PSYNC,
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040067 HyperbolicState hyperbolicState = HYPERBOLIC_STATE_OFF,
68 const ndn::Name& networkName = "/ndn",
69 const ndn::Name& siteName = "/site",
70 const ndn::Name& routerName = "/%C1.Router/this-router")
Ashlesh Gawande85998a12017-12-07 22:22:13 -060071 {
Saurab Dulal427e0122019-11-28 11:58:02 -060072 conf.setNetwork(networkName);
73 conf.setSiteName(siteName);
74 conf.setRouterName(routerName);
Ashlesh Gawande6b388fc2019-09-30 10:14:41 -050075 conf.buildRouterAndSyncUserPrefix();
Ashlesh Gawande85998a12017-12-07 22:22:13 -060076 conf.setSyncProtocol(protocol);
Ashlesh Gawande6b388fc2019-09-30 10:14:41 -050077 conf.setHyperbolicState(hyperbolicState);
Ashlesh Gawande85998a12017-12-07 22:22:13 -060078 }
79};
80
Vince Lehman7c603292014-09-11 17:48:16 -050081} // namespace test
82} // namespace nlsr
83
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040084#endif // NLSR_TESTS_TEST_COMMON_HPP