blob: 36c8debe63466bda9b8c052a2b06d04dca2f6bb7 [file] [log] [blame]
Jiewen Tan99135962014-09-20 02:18:53 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shi85d90832016-08-04 03:19:46 +00003 * Copyright (c) 2013-2016 Regents of the University of California.
Jiewen Tan99135962014-09-20 02:18:53 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Spyridon Mastorakis429634f2015-02-19 17:35:33 -080020 */
Jiewen Tan99135962014-09-20 02:18:53 -070021
22#ifndef NDN_TESTS_UNIT_TESTS_MAKE_INTEREST_DATA_HPP
23#define NDN_TESTS_UNIT_TESTS_MAKE_INTEREST_DATA_HPP
24
Junxiao Shi85d90832016-08-04 03:19:46 +000025#include "interest.hpp"
26#include "data.hpp"
27#include "link.hpp"
Junxiao Shib1990df2015-11-05 00:14:44 +000028#include "lp/nack.hpp"
Jiewen Tan99135962014-09-20 02:18:53 -070029
30namespace ndn {
Junxiao Shi85d90832016-08-04 03:19:46 +000031namespace tests {
Jiewen Tan99135962014-09-20 02:18:53 -070032
Junxiao Shi85d90832016-08-04 03:19:46 +000033/** \brief create an Interest
34 * \param name Interest name
35 * \param nonce if non-zero, set Nonce to this value
36 * (useful for creating Nack with same Nonce)
37 */
38shared_ptr<Interest>
39makeInterest(const Name& name, uint32_t nonce = 0);
Jiewen Tan99135962014-09-20 02:18:53 -070040
Junxiao Shi85d90832016-08-04 03:19:46 +000041/** \brief create a Data with fake signature
42 * \note Data may be modified afterwards without losing the fake signature.
43 * If a real signature is desired, sign again with KeyChain.
44 */
45shared_ptr<Data>
46makeData(const Name& name);
47
48/** \brief add a fake signature to Data
49 */
50Data&
51signData(Data& data);
52
53/** \brief add a fake signature to Data
54 */
Jiewen Tan99135962014-09-20 02:18:53 -070055inline shared_ptr<Data>
Junxiao Shib1990df2015-11-05 00:14:44 +000056signData(shared_ptr<Data> data)
Jiewen Tan99135962014-09-20 02:18:53 -070057{
Junxiao Shi85d90832016-08-04 03:19:46 +000058 signData(*data);
Jiewen Tan99135962014-09-20 02:18:53 -070059 return data;
60}
61
Junxiao Shi85d90832016-08-04 03:19:46 +000062/** \brief create a Link object with fake signature
63 * \note Link may be modified afterwards without losing the fake signature.
64 * If a real signature is desired, sign again with KeyChain.
65 */
66shared_ptr<Link>
67makeLink(const Name& name, std::initializer_list<std::pair<uint32_t, Name>> delegations);
Jiewen Tan99135962014-09-20 02:18:53 -070068
Junxiao Shi85d90832016-08-04 03:19:46 +000069/** \brief create a Nack
70 * \param interest Interest
71 * \param reason Nack reason
72 */
73lp::Nack
74makeNack(const Interest& interest, lp::NackReason reason);
Junxiao Shib1990df2015-11-05 00:14:44 +000075
Junxiao Shi85d90832016-08-04 03:19:46 +000076/** \brief create a Nack
77 * \param name Interest name
78 * \param nonce Interest nonce
79 * \param reason Nack reason
80 */
81lp::Nack
82makeNack(const Name& name, uint32_t nonce, lp::NackReason reason);
Junxiao Shib1990df2015-11-05 00:14:44 +000083
Junxiao Shi85d90832016-08-04 03:19:46 +000084} // namespace tests
Jiewen Tan99135962014-09-20 02:18:53 -070085} // namespace ndn
86
87#endif // NDN_TESTS_UNIT_TESTS_MAKE_INTEREST_DATA_HPP