Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 3 | * Copyright (c) 2014-2020, Arizona Board of Regents. |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-tools (Named Data Networking Essential Tools). |
| 6 | * See AUTHORS.md for complete list of ndn-tools authors and contributors. |
| 7 | * |
| 8 | * ndn-tools is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #include "tools/peek/ndnpeek/ndnpeek.hpp" |
| 21 | |
| 22 | #include "tests/test-common.hpp" |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 23 | #include "tests/io-fixture.hpp" |
Davide Pesavento | bf28cd7 | 2017-08-13 17:22:47 -0400 | [diff] [blame] | 24 | |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 25 | #include <ndn-cxx/util/dummy-client-face.hpp> |
| 26 | |
| 27 | #include <boost/mpl/vector.hpp> |
Davide Pesavento | a8600b0 | 2019-12-22 18:52:36 -0500 | [diff] [blame] | 28 | #if BOOST_VERSION >= 105900 |
| 29 | #include <boost/test/tools/output_test_stream.hpp> |
| 30 | #else |
| 31 | #include <boost/test/output_test_stream.hpp> |
| 32 | #endif |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 33 | |
| 34 | namespace ndn { |
| 35 | namespace peek { |
| 36 | namespace tests { |
| 37 | |
| 38 | using namespace ndn::tests; |
| 39 | using boost::test_tools::output_test_stream; |
| 40 | |
| 41 | class CoutRedirector : noncopyable |
| 42 | { |
| 43 | public: |
| 44 | explicit |
| 45 | CoutRedirector(std::ostream& destination) |
| 46 | { |
| 47 | m_originalBuf = std::cout.rdbuf(destination.rdbuf()); |
| 48 | } |
| 49 | |
| 50 | ~CoutRedirector() |
| 51 | { |
| 52 | std::cout.rdbuf(m_originalBuf); |
| 53 | } |
| 54 | |
| 55 | private: |
| 56 | std::streambuf* m_originalBuf; |
| 57 | }; |
| 58 | |
Davide Pesavento | 9602823 | 2019-08-17 01:26:13 -0400 | [diff] [blame] | 59 | static PeekOptions |
| 60 | makeDefaultOptions() |
| 61 | { |
| 62 | PeekOptions opt; |
| 63 | opt.name = "/peek/test"; |
| 64 | return opt; |
| 65 | } |
| 66 | |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 67 | class NdnPeekFixture : public IoFixture |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 68 | { |
| 69 | protected: |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 70 | void |
Davide Pesavento | 9602823 | 2019-08-17 01:26:13 -0400 | [diff] [blame] | 71 | initialize(const PeekOptions& opts = makeDefaultOptions()) |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 72 | { |
| 73 | peek = make_unique<NdnPeek>(face, opts); |
| 74 | } |
| 75 | |
| 76 | protected: |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 77 | ndn::util::DummyClientFace face{m_io}; |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 78 | output_test_stream output; |
| 79 | unique_ptr<NdnPeek> peek; |
| 80 | }; |
| 81 | |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 82 | class OutputFull |
| 83 | { |
| 84 | public: |
| 85 | static PeekOptions |
| 86 | makeOptions() |
| 87 | { |
| 88 | return makeDefaultOptions(); |
| 89 | } |
| 90 | |
| 91 | static void |
| 92 | checkOutput(output_test_stream& output, const Data& data) |
| 93 | { |
| 94 | const Block& block = data.wireEncode(); |
| 95 | std::string expected(reinterpret_cast<const char*>(block.wire()), block.size()); |
| 96 | BOOST_CHECK(output.is_equal(expected)); |
| 97 | } |
| 98 | |
| 99 | static void |
| 100 | checkOutput(output_test_stream& output, const lp::Nack& nack) |
| 101 | { |
| 102 | const Block& block = nack.getHeader().wireEncode(); |
| 103 | std::string expected(reinterpret_cast<const char*>(block.wire()), block.size()); |
| 104 | BOOST_CHECK(output.is_equal(expected)); |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | class OutputPayloadOnly |
| 109 | { |
| 110 | public: |
| 111 | static PeekOptions |
| 112 | makeOptions() |
| 113 | { |
| 114 | PeekOptions opt = makeDefaultOptions(); |
| 115 | opt.wantPayloadOnly = true; |
| 116 | return opt; |
| 117 | } |
| 118 | |
| 119 | static void |
| 120 | checkOutput(output_test_stream& output, const Data& data) |
| 121 | { |
| 122 | const Block& block = data.getContent(); |
| 123 | std::string expected(reinterpret_cast<const char*>(block.value()), block.value_size()); |
| 124 | BOOST_CHECK(output.is_equal(expected)); |
| 125 | } |
| 126 | |
| 127 | static void |
| 128 | checkOutput(output_test_stream& output, const lp::Nack& nack) |
| 129 | { |
| 130 | std::string expected = boost::lexical_cast<std::string>(nack.getReason()) + '\n'; |
| 131 | BOOST_CHECK(output.is_equal(expected)); |
| 132 | } |
| 133 | }; |
| 134 | |
| 135 | BOOST_AUTO_TEST_SUITE(Peek) |
| 136 | BOOST_FIXTURE_TEST_SUITE(TestNdnPeek, NdnPeekFixture) |
| 137 | |
| 138 | using OutputChecks = boost::mpl::vector<OutputFull, OutputPayloadOnly>; |
| 139 | |
| 140 | BOOST_AUTO_TEST_CASE_TEMPLATE(Default, OutputCheck, OutputChecks) |
| 141 | { |
| 142 | auto options = OutputCheck::makeOptions(); |
| 143 | initialize(options); |
| 144 | |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 145 | auto data = makeData(options.name); |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 146 | const std::string payload = "NdnPeekTest"; |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 147 | data->setContent(reinterpret_cast<const uint8_t*>(payload.data()), payload.size()); |
| 148 | |
| 149 | { |
| 150 | CoutRedirector redir(output); |
| 151 | peek->start(); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 152 | this->advanceClocks(25_ms, 4); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 153 | face.receive(*data); |
| 154 | } |
| 155 | |
| 156 | OutputCheck::checkOutput(output, *data); |
| 157 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 158 | BOOST_CHECK_EQUAL(face.sentInterests.back().getCanBePrefix(), false); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 159 | BOOST_CHECK_EQUAL(face.sentInterests.back().getMustBeFresh(), false); |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 160 | BOOST_CHECK_EQUAL(face.sentInterests.back().getForwardingHint().empty(), true); |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 161 | BOOST_CHECK_EQUAL(face.sentInterests.back().getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); |
Davide Pesavento | c214e07 | 2019-08-17 01:33:28 -0400 | [diff] [blame] | 162 | BOOST_CHECK(face.sentInterests.back().getHopLimit() == nullopt); |
| 163 | BOOST_CHECK(!face.sentInterests.back().hasApplicationParameters()); |
Davide Pesavento | 87434be | 2019-07-25 19:04:23 -0400 | [diff] [blame] | 164 | BOOST_CHECK(peek->getResult() == NdnPeek::Result::DATA); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 167 | BOOST_AUTO_TEST_CASE_TEMPLATE(NonDefault, OutputCheck, OutputChecks) |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 168 | { |
| 169 | auto options = OutputCheck::makeOptions(); |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 170 | options.canBePrefix = true; |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 171 | options.mustBeFresh = true; |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 172 | options.interestLifetime = 200_ms; |
Davide Pesavento | c214e07 | 2019-08-17 01:33:28 -0400 | [diff] [blame] | 173 | options.hopLimit = 64; |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 174 | initialize(options); |
| 175 | |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 176 | auto data = makeData(Name(options.name).append("suffix")); |
Junxiao Shi | 9619295 | 2019-05-22 15:45:12 +0000 | [diff] [blame] | 177 | data->setFreshnessPeriod(1_s); |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 178 | const std::string payload = "NdnPeekTest"; |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 179 | data->setContent(reinterpret_cast<const uint8_t*>(payload.data()), payload.size()); |
| 180 | |
| 181 | { |
| 182 | CoutRedirector redir(output); |
| 183 | peek->start(); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 184 | this->advanceClocks(25_ms, 4); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 185 | face.receive(*data); |
| 186 | } |
| 187 | |
| 188 | OutputCheck::checkOutput(output, *data); |
| 189 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 190 | BOOST_CHECK_EQUAL(face.sentInterests.back().getCanBePrefix(), true); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 191 | BOOST_CHECK_EQUAL(face.sentInterests.back().getMustBeFresh(), true); |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 192 | BOOST_CHECK_EQUAL(face.sentInterests.back().getForwardingHint().empty(), true); |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 193 | BOOST_CHECK_EQUAL(face.sentInterests.back().getInterestLifetime(), 200_ms); |
Davide Pesavento | c214e07 | 2019-08-17 01:33:28 -0400 | [diff] [blame] | 194 | BOOST_CHECK(face.sentInterests.back().getHopLimit() == 64); |
| 195 | BOOST_CHECK(!face.sentInterests.back().hasApplicationParameters()); |
Davide Pesavento | 87434be | 2019-07-25 19:04:23 -0400 | [diff] [blame] | 196 | BOOST_CHECK(peek->getResult() == NdnPeek::Result::DATA); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | BOOST_AUTO_TEST_CASE_TEMPLATE(ReceiveNackWithReason, OutputCheck, OutputChecks) |
| 200 | { |
| 201 | auto options = OutputCheck::makeOptions(); |
| 202 | initialize(options); |
| 203 | lp::Nack nack; |
| 204 | |
| 205 | { |
| 206 | CoutRedirector redir(output); |
| 207 | peek->start(); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 208 | this->advanceClocks(25_ms, 4); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 209 | nack = makeNack(face.sentInterests.at(0), lp::NackReason::NO_ROUTE); |
| 210 | face.receive(nack); |
| 211 | } |
| 212 | |
| 213 | OutputCheck::checkOutput(output, nack); |
| 214 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 1); |
Davide Pesavento | 87434be | 2019-07-25 19:04:23 -0400 | [diff] [blame] | 215 | BOOST_CHECK(peek->getResult() == NdnPeek::Result::NACK); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | BOOST_AUTO_TEST_CASE_TEMPLATE(ReceiveNackWithoutReason, OutputCheck, OutputChecks) |
| 219 | { |
| 220 | auto options = OutputCheck::makeOptions(); |
| 221 | initialize(options); |
| 222 | lp::Nack nack; |
| 223 | |
| 224 | { |
| 225 | CoutRedirector redir(output); |
| 226 | peek->start(); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 227 | this->advanceClocks(25_ms, 4); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 228 | nack = makeNack(face.sentInterests.at(0), lp::NackReason::NONE); |
| 229 | face.receive(nack); |
| 230 | } |
| 231 | |
| 232 | OutputCheck::checkOutput(output, nack); |
| 233 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 1); |
Davide Pesavento | 87434be | 2019-07-25 19:04:23 -0400 | [diff] [blame] | 234 | BOOST_CHECK(peek->getResult() == NdnPeek::Result::NACK); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Davide Pesavento | 9602823 | 2019-08-17 01:26:13 -0400 | [diff] [blame] | 237 | BOOST_AUTO_TEST_CASE(ApplicationParameters) |
| 238 | { |
| 239 | auto options = makeDefaultOptions(); |
| 240 | options.applicationParameters = make_shared<Buffer>("hello", 5); |
| 241 | initialize(options); |
| 242 | |
| 243 | peek->start(); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 244 | this->advanceClocks(25_ms, 4); |
Davide Pesavento | 9602823 | 2019-08-17 01:26:13 -0400 | [diff] [blame] | 245 | |
| 246 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); |
| 247 | BOOST_CHECK_EQUAL(face.sentInterests.back().getCanBePrefix(), false); |
| 248 | BOOST_CHECK_EQUAL(face.sentInterests.back().getMustBeFresh(), false); |
| 249 | BOOST_CHECK_EQUAL(face.sentInterests.back().getForwardingHint().empty(), true); |
| 250 | BOOST_CHECK_EQUAL(face.sentInterests.back().getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); |
| 251 | BOOST_CHECK_EQUAL(face.sentInterests.back().hasApplicationParameters(), true); |
| 252 | BOOST_CHECK_EQUAL(face.sentInterests.back().getApplicationParameters(), "2405 68656C6C6F"_block); |
| 253 | } |
| 254 | |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 255 | BOOST_AUTO_TEST_CASE(NoTimeout) |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 256 | { |
| 257 | auto options = makeDefaultOptions(); |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 258 | options.interestLifetime = 1_s; |
| 259 | options.timeout = nullopt; |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 260 | initialize(options); |
| 261 | |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 262 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 0); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 263 | |
| 264 | peek->start(); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 265 | this->advanceClocks(100_ms, 9); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 266 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 1); |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 267 | BOOST_CHECK_EQUAL(face.getNPendingInterests(), 1); |
Davide Pesavento | 87434be | 2019-07-25 19:04:23 -0400 | [diff] [blame] | 268 | BOOST_CHECK(peek->getResult() == NdnPeek::Result::UNKNOWN); |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 269 | |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 270 | this->advanceClocks(100_ms, 2); |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 271 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 1); |
| 272 | BOOST_CHECK_EQUAL(face.getNPendingInterests(), 0); |
Davide Pesavento | 87434be | 2019-07-25 19:04:23 -0400 | [diff] [blame] | 273 | BOOST_CHECK(peek->getResult() == NdnPeek::Result::TIMEOUT); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | BOOST_AUTO_TEST_CASE(TimeoutLessThanLifetime) |
| 277 | { |
| 278 | auto options = makeDefaultOptions(); |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 279 | options.interestLifetime = 200_ms; |
| 280 | options.timeout = 100_ms; |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 281 | initialize(options); |
| 282 | |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 283 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 0); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 284 | |
| 285 | peek->start(); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 286 | this->advanceClocks(25_ms, 6); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 287 | |
| 288 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 1); |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 289 | BOOST_CHECK_EQUAL(face.getNPendingInterests(), 0); |
Davide Pesavento | 87434be | 2019-07-25 19:04:23 -0400 | [diff] [blame] | 290 | BOOST_CHECK(peek->getResult() == NdnPeek::Result::TIMEOUT); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | BOOST_AUTO_TEST_CASE(TimeoutGreaterThanLifetime) |
| 294 | { |
| 295 | auto options = makeDefaultOptions(); |
Junxiao Shi | b54aabd | 2018-04-16 19:36:24 +0000 | [diff] [blame] | 296 | options.interestLifetime = 50_ms; |
| 297 | options.timeout = 200_ms; |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 298 | initialize(options); |
| 299 | |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 300 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 0); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 301 | |
| 302 | peek->start(); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 303 | this->advanceClocks(25_ms, 4); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 304 | |
| 305 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 1); |
Davide Pesavento | 65d1155 | 2019-06-09 19:15:50 -0400 | [diff] [blame] | 306 | BOOST_CHECK_EQUAL(face.getNPendingInterests(), 0); |
Davide Pesavento | 87434be | 2019-07-25 19:04:23 -0400 | [diff] [blame] | 307 | BOOST_CHECK(peek->getResult() == NdnPeek::Result::TIMEOUT); |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Davide Pesavento | 9602823 | 2019-08-17 01:26:13 -0400 | [diff] [blame] | 310 | BOOST_AUTO_TEST_CASE(OversizedPacket) |
| 311 | { |
| 312 | auto options = makeDefaultOptions(); |
| 313 | options.applicationParameters = make_shared<Buffer>(MAX_NDN_PACKET_SIZE); |
| 314 | initialize(options); |
| 315 | |
| 316 | peek->start(); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 317 | BOOST_CHECK_THROW(this->advanceClocks(1_ms, 10), Face::OversizedPacketError); |
Davide Pesavento | 9602823 | 2019-08-17 01:26:13 -0400 | [diff] [blame] | 318 | |
| 319 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 0); |
| 320 | } |
| 321 | |
Zhuo Li | b355889 | 2016-08-12 15:51:12 -0700 | [diff] [blame] | 322 | BOOST_AUTO_TEST_SUITE_END() // TestNdnPeek |
| 323 | BOOST_AUTO_TEST_SUITE_END() // Peek |
| 324 | |
| 325 | } // namespace tests |
| 326 | } // namespace peek |
| 327 | } // namespace ndn |