blob: 4d970d54031816465041c34dc36e8ec8a5be7f90 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi899277a2017-07-07 22:12:12 +00002/*
Davide Pesavento0f830802018-01-16 23:58:58 -05003 * Copyright (c) 2013-2018 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * 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.
Alexander Afanasyev5fa9e9a2013-12-24 19:45:07 -080020 */
21
Alexander Afanasyev09c613f2014-01-29 00:23:58 -080022#include "interest.hpp"
Junxiao Shiaf8eeea2014-03-31 20:10:56 -070023#include "data.hpp"
Yingdi Yubf6a2812014-06-17 15:32:11 -070024#include "security/digest-sha256.hpp"
Junxiao Shi899277a2017-07-07 22:12:12 +000025#include "security/signature-sha256-with-rsa.hpp"
Junxiao Shiaf8eeea2014-03-31 20:10:56 -070026
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070027#include "boost-test.hpp"
Alexander Afanasyeve4f8c3b2016-06-23 16:03:48 -070028#include "identity-management-fixture.hpp"
Alexander Afanasyev5fa9e9a2013-12-24 19:45:07 -080029
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080030namespace ndn {
Alexander Afanasyev90164962014-03-06 08:29:59 +000031namespace tests {
Alexander Afanasyev5fa9e9a2013-12-24 19:45:07 -080032
Junxiao Shi899277a2017-07-07 22:12:12 +000033BOOST_AUTO_TEST_SUITE(TestInterest)
Alexander Afanasyev5fa9e9a2013-12-24 19:45:07 -080034
Junxiao Shi899277a2017-07-07 22:12:12 +000035// ---- constructor, encode, decode ----
36
37BOOST_AUTO_TEST_CASE(DefaultConstructor)
38{
39 Interest i;
40 BOOST_CHECK_EQUAL(i.getName(), "/");
41 BOOST_CHECK(i.getSelectors().empty());
Junxiao Shi2dd711d2017-07-21 13:40:52 +000042 BOOST_CHECK_EQUAL(i.hasNonce(), false);
Junxiao Shi899277a2017-07-07 22:12:12 +000043 BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
Junxiao Shi899277a2017-07-07 22:12:12 +000044}
45
46BOOST_AUTO_TEST_CASE(EncodeDecodeBasic)
47{
48 const uint8_t WIRE[] = {
49 0x05, 0x1c, // Interest
50 0x07, 0x14, // Name
Junxiao Shi4ffbb9d2018-03-31 17:16:35 +000051 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, // GenericNameComponent
52 0x08, 0x03, 0x6e, 0x64, 0x6e, // GenericNameComponent
53 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, // GenericNameComponent
Junxiao Shi899277a2017-07-07 22:12:12 +000054 0x0a, 0x04, // Nonce
55 0x01, 0x00, 0x00, 0x00
56 };
57
58 Interest i1("/local/ndn/prefix");
59 i1.setNonce(1);
60 Block wire1 = i1.wireEncode();
61 BOOST_CHECK_EQUAL_COLLECTIONS(wire1.begin(), wire1.end(), WIRE, WIRE + sizeof(WIRE));
62
63 Interest i2(wire1);
64 BOOST_CHECK_EQUAL(i2.getName(), "/local/ndn/prefix");
65 BOOST_CHECK(i2.getSelectors().empty());
66 BOOST_CHECK_EQUAL(i2.getNonce(), 1);
67 BOOST_CHECK_EQUAL(i2.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
68
69 BOOST_CHECK_EQUAL(i1, i2);
70}
71
72BOOST_AUTO_TEST_CASE(EncodeDecodeFull)
73{
74 const uint8_t WIRE[] = {
Junxiao Shi9c154cb2017-07-07 22:14:54 +000075 0x05, 0x31, // Interest
Junxiao Shi899277a2017-07-07 22:12:12 +000076 0x07, 0x14, // Name
Junxiao Shi4ffbb9d2018-03-31 17:16:35 +000077 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, // GenericNameComponent
78 0x08, 0x03, 0x6e, 0x64, 0x6e, // GenericNameComponent
79 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, // GenericNameComponent
Junxiao Shi899277a2017-07-07 22:12:12 +000080 0x09, 0x03, // Selectors
81 0x0d, 0x01, 0x01, // MinSuffixComponents
82 0x0a, 0x04, // Nonce
83 0x01, 0x00, 0x00, 0x00,
84 0x0c, 0x02, // InterestLifetime
Junxiao Shi9c154cb2017-07-07 22:14:54 +000085 0x03, 0xe8,
86 0x1e, 0x0a, // ForwardingHint
87 0x1f, 0x08, // Delegation
88 0x1e, 0x01, 0x01, // Preference=1
89 0x07, 0x03, 0x08, 0x01, 0x41 // Name=/A
Junxiao Shi899277a2017-07-07 22:12:12 +000090 };
Junxiao Shi899277a2017-07-07 22:12:12 +000091
92 Interest i1;
93 i1.setName("/local/ndn/prefix");
94 i1.setMinSuffixComponents(1);
95 i1.setNonce(1);
Davide Pesavento0f830802018-01-16 23:58:58 -050096 i1.setInterestLifetime(1000_ms);
Junxiao Shi9c154cb2017-07-07 22:14:54 +000097 i1.setForwardingHint({{1, "/A"}});
Junxiao Shi899277a2017-07-07 22:12:12 +000098 Block wire1 = i1.wireEncode();
99 BOOST_CHECK_EQUAL_COLLECTIONS(wire1.begin(), wire1.end(), WIRE, WIRE + sizeof(WIRE));
100
101 Interest i2(wire1);
102 BOOST_CHECK_EQUAL(i2.getName(), "/local/ndn/prefix");
103 BOOST_CHECK_EQUAL(i2.getMinSuffixComponents(), 1);
104 BOOST_CHECK_EQUAL(i2.getNonce(), 1);
Davide Pesavento0f830802018-01-16 23:58:58 -0500105 BOOST_CHECK_EQUAL(i2.getInterestLifetime(), 1000_ms);
Junxiao Shi9c154cb2017-07-07 22:14:54 +0000106 BOOST_CHECK_EQUAL(i2.getForwardingHint(), DelegationList({{1, "/A"}}));
Junxiao Shi899277a2017-07-07 22:12:12 +0000107
108 BOOST_CHECK_EQUAL(i1, i2);
109}
110
Junxiao Shi899277a2017-07-07 22:12:12 +0000111BOOST_AUTO_TEST_CASE(WireDecodeReset) // checks wireDecode resets all fields
112{
113 Interest i1;
114 i1.setName("/test");
115 i1.setMinSuffixComponents(100);
116 i1.setNonce(10);
Davide Pesavento0f830802018-01-16 23:58:58 -0500117 i1.setInterestLifetime(10_s);
Junxiao Shi899277a2017-07-07 22:12:12 +0000118
119 Interest i2(i1.wireEncode());
120 BOOST_CHECK_EQUAL(i2.getName().toUri(), "/test");
Davide Pesavento0f830802018-01-16 23:58:58 -0500121 BOOST_CHECK_EQUAL(i2.getInterestLifetime(), 10_s);
Junxiao Shi899277a2017-07-07 22:12:12 +0000122 BOOST_CHECK_EQUAL(i2.getMinSuffixComponents(), 100);
123 BOOST_CHECK_EQUAL(i2.getNonce(), 10);
Junxiao Shi899277a2017-07-07 22:12:12 +0000124
125 i2.wireDecode(Interest().wireEncode());
126 BOOST_CHECK_EQUAL(i2.getName().toUri(), "/");
127 BOOST_CHECK_EQUAL(i2.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
128 BOOST_CHECK_EQUAL(i2.getMinSuffixComponents(), -1);
129 BOOST_WARN_NE(i2.getNonce(), 10);
Junxiao Shi899277a2017-07-07 22:12:12 +0000130}
131
Junxiao Shi2dd711d2017-07-21 13:40:52 +0000132BOOST_AUTO_TEST_CASE(DecodeNoName)
133{
134 Block b(tlv::Interest);
135 b.push_back(makeBinaryBlock(tlv::Nonce, "FISH", 4));
136 b.encode();
137
138 Interest i;
139 BOOST_CHECK_THROW(i.wireDecode(b), tlv::Error);
140}
141
142BOOST_AUTO_TEST_CASE(DecodeNoNonce)
143{
144 Block b(tlv::Interest);
145 b.push_back(Name("/YvzNKtPWh").wireEncode());
146 b.encode();
147
148 Interest i;
149 BOOST_CHECK_THROW(i.wireDecode(b), tlv::Error);
150}
151
152BOOST_AUTO_TEST_CASE(DecodeBadNonce)
153{
154 Block b(tlv::Interest);
155 b.push_back(Name("/BJzEHVxDJ").wireEncode());
156 b.push_back(makeBinaryBlock(tlv::Nonce, "SKY", 3));
157 b.encode();
158
159 Interest i;
160 BOOST_CHECK_THROW(i.wireDecode(b), tlv::Error);
161}
162
Junxiao Shi899277a2017-07-07 22:12:12 +0000163// ---- matching ----
164
165BOOST_AUTO_TEST_CASE(MatchesData)
166{
167 Interest interest;
168 interest.setName("ndn:/A")
169 .setMinSuffixComponents(2)
170 .setMaxSuffixComponents(2)
171 .setPublisherPublicKeyLocator(KeyLocator("ndn:/B"))
172 .setExclude(Exclude().excludeAfter(name::Component("J")));
173
174 Data data("ndn:/A/D");
175 SignatureSha256WithRsa signature(KeyLocator("ndn:/B"));
Junxiao Shidb7464d2017-07-13 03:11:17 +0000176 signature.setValue(encoding::makeEmptyBlock(tlv::SignatureValue));
Junxiao Shi899277a2017-07-07 22:12:12 +0000177 data.setSignature(signature);
178 data.wireEncode();
179 BOOST_CHECK_EQUAL(interest.matchesData(data), true);
180
181 Data data1 = data;
182 data1.setName("ndn:/A"); // violates MinSuffixComponents
183 data1.wireEncode();
184 BOOST_CHECK_EQUAL(interest.matchesData(data1), false);
185
186 Interest interest1 = interest;
187 interest1.setMinSuffixComponents(1);
188 BOOST_CHECK_EQUAL(interest1.matchesData(data1), true);
189
190 Data data2 = data;
191 data2.setName("ndn:/A/E/F"); // violates MaxSuffixComponents
192 data2.wireEncode();
193 BOOST_CHECK_EQUAL(interest.matchesData(data2), false);
194
195 Interest interest2 = interest;
196 interest2.setMaxSuffixComponents(3);
197 BOOST_CHECK_EQUAL(interest2.matchesData(data2), true);
198
199 Data data3 = data;
200 SignatureSha256WithRsa signature3(KeyLocator("ndn:/G")); // violates PublisherPublicKeyLocator
Junxiao Shidb7464d2017-07-13 03:11:17 +0000201 signature3.setValue(encoding::makeEmptyBlock(tlv::SignatureValue));
Junxiao Shi899277a2017-07-07 22:12:12 +0000202 data3.setSignature(signature3);
203 data3.wireEncode();
204 BOOST_CHECK_EQUAL(interest.matchesData(data3), false);
205
206 Interest interest3 = interest;
207 interest3.setPublisherPublicKeyLocator(KeyLocator("ndn:/G"));
208 BOOST_CHECK_EQUAL(interest3.matchesData(data3), true);
209
210 Data data4 = data;
211 DigestSha256 signature4; // violates PublisherPublicKeyLocator
Junxiao Shidb7464d2017-07-13 03:11:17 +0000212 signature4.setValue(encoding::makeEmptyBlock(tlv::SignatureValue));
Junxiao Shi899277a2017-07-07 22:12:12 +0000213 data4.setSignature(signature4);
214 data4.wireEncode();
215 BOOST_CHECK_EQUAL(interest.matchesData(data4), false);
216
217 Interest interest4 = interest;
218 interest4.setPublisherPublicKeyLocator(KeyLocator());
219 BOOST_CHECK_EQUAL(interest4.matchesData(data4), true);
220
221 Data data5 = data;
222 data5.setName("ndn:/A/J"); // violates Exclude
223 data5.wireEncode();
224 BOOST_CHECK_EQUAL(interest.matchesData(data5), false);
225
226 Interest interest5 = interest;
227 interest5.setExclude(Exclude().excludeAfter(name::Component("K")));
228 BOOST_CHECK_EQUAL(interest5.matchesData(data5), true);
229
230 Data data6 = data;
231 data6.setName("ndn:/H/I"); // violates Name
232 data6.wireEncode();
233 BOOST_CHECK_EQUAL(interest.matchesData(data6), false);
234
235 Data data7 = data;
236 data7.setName("ndn:/A/B");
237 data7.wireEncode();
238
Junxiao Shidb7464d2017-07-13 03:11:17 +0000239 Interest interest7("/A/B/sha256digest=54008e240a7eea2714a161dfddf0dd6ced223b3856e9da96792151e180f3b128");
Junxiao Shi899277a2017-07-07 22:12:12 +0000240 BOOST_CHECK_EQUAL(interest7.matchesData(data7), true);
241
242 Interest interest7b("/A/B/sha256digest=0000000000000000000000000000000000000000000000000000000000000000");
243 BOOST_CHECK_EQUAL(interest7b.matchesData(data7), false); // violates implicit digest
244}
245
246BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(MatchesInterest, 1)
247BOOST_AUTO_TEST_CASE(MatchesInterest)
248{
249 Interest interest;
250 interest
251 .setName("/A")
252 .setMinSuffixComponents(2)
253 .setMaxSuffixComponents(2)
254 .setPublisherPublicKeyLocator(KeyLocator("/B"))
255 .setExclude(Exclude().excludeAfter(name::Component("J")))
256 .setNonce(10)
Davide Pesavento0f830802018-01-16 23:58:58 -0500257 .setInterestLifetime(5_s)
Junxiao Shid701e5b2017-07-26 01:30:41 +0000258 .setForwardingHint({{1, "/H"}});
Junxiao Shi899277a2017-07-07 22:12:12 +0000259
260 Interest other;
261 BOOST_CHECK_EQUAL(interest.matchesInterest(other), false);
262
263 other.setName(interest.getName());
264 BOOST_CHECK_EQUAL(interest.matchesInterest(other), false);
265
266 other.setSelectors(interest.getSelectors());
267 BOOST_CHECK_EQUAL(interest.matchesInterest(other), false); // will match until #3162 implemented
268
Junxiao Shid701e5b2017-07-26 01:30:41 +0000269 other.setForwardingHint({{1, "/H"}});
Junxiao Shi899277a2017-07-07 22:12:12 +0000270 BOOST_CHECK_EQUAL(interest.matchesInterest(other), true);
271
272 other.setNonce(200);
273 BOOST_CHECK_EQUAL(interest.matchesInterest(other), true);
274
Davide Pesavento0f830802018-01-16 23:58:58 -0500275 other.setInterestLifetime(5_h);
Junxiao Shi899277a2017-07-07 22:12:12 +0000276 BOOST_CHECK_EQUAL(interest.matchesInterest(other), true);
Junxiao Shi899277a2017-07-07 22:12:12 +0000277}
278
279// ---- field accessors ----
280
Junxiao Shi8d3f8342018-04-04 12:46:37 +0000281BOOST_AUTO_TEST_CASE(CanBePrefix)
282{
283 Interest i;
284 BOOST_CHECK_EQUAL(i.getCanBePrefix(), true);
285 i.setCanBePrefix(false);
286 BOOST_CHECK_EQUAL(i.getCanBePrefix(), false);
287 BOOST_CHECK_EQUAL(i.getSelectors().getMaxSuffixComponents(), 1);
288 i.setCanBePrefix(true);
289 BOOST_CHECK_EQUAL(i.getCanBePrefix(), true);
290 BOOST_CHECK_EQUAL(i.getSelectors().getMaxSuffixComponents(), -1);
291}
292
293BOOST_AUTO_TEST_CASE(MustBeFresh)
294{
295 Interest i;
296 BOOST_CHECK_EQUAL(i.getMustBeFresh(), false);
297 i.setMustBeFresh(true);
298 BOOST_CHECK_EQUAL(i.getMustBeFresh(), true);
299 BOOST_CHECK_EQUAL(i.getSelectors().getMustBeFresh(), true);
300 i.setMustBeFresh(false);
301 BOOST_CHECK_EQUAL(i.getMustBeFresh(), false);
302 BOOST_CHECK_EQUAL(i.getSelectors().getMustBeFresh(), false);
303}
304
305BOOST_AUTO_TEST_CASE(ModifyForwardingHint)
306{
307 Interest i;
308 i.setForwardingHint({{1, "/A"}});
309 i.wireEncode();
310 BOOST_CHECK(i.hasWire());
311
312 i.modifyForwardingHint([] (DelegationList& fh) { fh.insert(2, "/B"); });
313 BOOST_CHECK(!i.hasWire());
314 BOOST_CHECK_EQUAL(i.getForwardingHint(), DelegationList({{1, "/A"}, {2, "/B"}}));
315}
316
Junxiao Shi899277a2017-07-07 22:12:12 +0000317BOOST_AUTO_TEST_CASE(GetNonce)
318{
Junxiao Shi2dd711d2017-07-21 13:40:52 +0000319 unique_ptr<Interest> i1, i2;
Junxiao Shi899277a2017-07-07 22:12:12 +0000320
Junxiao Shi2dd711d2017-07-21 13:40:52 +0000321 // getNonce automatically assigns a random Nonce.
322 // It's possible to assign the same Nonce to two Interest, but it's unlikely to get 100 pairs of
323 // same Nonces in a row.
Junxiao Shi899277a2017-07-07 22:12:12 +0000324 int nIterations = 0;
Junxiao Shi2dd711d2017-07-21 13:40:52 +0000325 uint32_t nonce1 = 0, nonce2 = 0;
Junxiao Shi899277a2017-07-07 22:12:12 +0000326 do {
Junxiao Shi2dd711d2017-07-21 13:40:52 +0000327 i1 = make_unique<Interest>();
328 nonce1 = i1->getNonce();
329 i2 = make_unique<Interest>();
330 nonce2 = i2->getNonce();
Junxiao Shi899277a2017-07-07 22:12:12 +0000331 }
Junxiao Shi2dd711d2017-07-21 13:40:52 +0000332 while (nonce1 == nonce2 && ++nIterations < 100);
333 BOOST_CHECK_NE(nonce1, nonce2);
334 BOOST_CHECK(i1->hasNonce());
335 BOOST_CHECK(i2->hasNonce());
Junxiao Shi899277a2017-07-07 22:12:12 +0000336
337 // Once a Nonce is assigned, it should not change.
Junxiao Shi2dd711d2017-07-21 13:40:52 +0000338 BOOST_CHECK_EQUAL(i1->getNonce(), nonce1);
339}
340
341BOOST_AUTO_TEST_CASE(SetNonce)
342{
343 Interest i1("/A");
344 i1.setNonce(1);
345 i1.wireEncode();
346 BOOST_CHECK_EQUAL(i1.getNonce(), 1);
347
348 Interest i2(i1);
349 BOOST_CHECK_EQUAL(i2.getNonce(), 1);
350
351 i2.setNonce(2);
352 BOOST_CHECK_EQUAL(i2.getNonce(), 2);
353 BOOST_CHECK_EQUAL(i1.getNonce(), 1); // should not affect i1 Nonce (Bug #4168)
Junxiao Shi899277a2017-07-07 22:12:12 +0000354}
355
356BOOST_AUTO_TEST_CASE(RefreshNonce)
357{
358 Interest i;
359 BOOST_CHECK(!i.hasNonce());
360 i.refreshNonce();
361 BOOST_CHECK(!i.hasNonce());
362
363 i.setNonce(1);
364 BOOST_CHECK(i.hasNonce());
365 i.refreshNonce();
366 BOOST_CHECK(i.hasNonce());
367 BOOST_CHECK_NE(i.getNonce(), 1);
368}
369
370BOOST_AUTO_TEST_CASE(SetInterestLifetime)
371{
372 BOOST_CHECK_THROW(Interest("/A", time::milliseconds(-1)), std::invalid_argument);
Davide Pesavento0f830802018-01-16 23:58:58 -0500373 BOOST_CHECK_NO_THROW(Interest("/A", 0_ms));
Junxiao Shi899277a2017-07-07 22:12:12 +0000374
375 Interest i("/local/ndn/prefix");
376 i.setNonce(1);
377 BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
378 BOOST_CHECK_THROW(i.setInterestLifetime(time::milliseconds(-1)), std::invalid_argument);
379 BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
Davide Pesavento0f830802018-01-16 23:58:58 -0500380 i.setInterestLifetime(0_ms);
381 BOOST_CHECK_EQUAL(i.getInterestLifetime(), 0_ms);
382 i.setInterestLifetime(1_ms);
383 BOOST_CHECK_EQUAL(i.getInterestLifetime(), 1_ms);
Junxiao Shi899277a2017-07-07 22:12:12 +0000384}
385
386// ---- operators ----
387
388BOOST_AUTO_TEST_CASE(Equality)
389{
390 Interest a;
391 Interest b;
392
393 // if nonce is not set, it would be set to a random value
394 a.setNonce(1);
395 b.setNonce(1);
396
397 BOOST_CHECK_EQUAL(a == b, true);
398 BOOST_CHECK_EQUAL(a != b, false);
399
400 // compare Name
401 a.setName("/A");
402 BOOST_CHECK_EQUAL(a == b, false);
403 BOOST_CHECK_EQUAL(a != b, true);
404
405 b.setName("/B");
406 BOOST_CHECK_EQUAL(a == b, false);
407 BOOST_CHECK_EQUAL(a != b, true);
408
409 b.setName("/A");
410 BOOST_CHECK_EQUAL(a == b, true);
411 BOOST_CHECK_EQUAL(a != b, false);
412
413 // compare Selectors
414 a.setChildSelector(1);
415 BOOST_CHECK_EQUAL(a == b, false);
416 BOOST_CHECK_EQUAL(a != b, true);
417
418 b.setChildSelector(1);
419 BOOST_CHECK_EQUAL(a == b, true);
420 BOOST_CHECK_EQUAL(a != b, false);
421
422 // compare Nonce
423 a.setNonce(100);
424 BOOST_CHECK_EQUAL(a == b, false);
425 BOOST_CHECK_EQUAL(a != b, true);
426
427 b.setNonce(100);
428 BOOST_CHECK_EQUAL(a == b, true);
429 BOOST_CHECK_EQUAL(a != b, false);
430
431 // compare InterestLifetime
Davide Pesavento0f830802018-01-16 23:58:58 -0500432 a.setInterestLifetime(10_s);
Junxiao Shi899277a2017-07-07 22:12:12 +0000433 BOOST_CHECK_EQUAL(a == b, false);
434 BOOST_CHECK_EQUAL(a != b, true);
435
Davide Pesavento0f830802018-01-16 23:58:58 -0500436 b.setInterestLifetime(10_s);
Junxiao Shi899277a2017-07-07 22:12:12 +0000437 BOOST_CHECK_EQUAL(a == b, true);
438 BOOST_CHECK_EQUAL(a != b, false);
439
Junxiao Shid701e5b2017-07-26 01:30:41 +0000440 // compare ForwardingHint
441 a.setForwardingHint({{1, "/H"}});
Junxiao Shi899277a2017-07-07 22:12:12 +0000442 BOOST_CHECK_EQUAL(a == b, false);
443 BOOST_CHECK_EQUAL(a != b, true);
444
Junxiao Shid701e5b2017-07-26 01:30:41 +0000445 b.setForwardingHint({{1, "/H"}});
Junxiao Shi899277a2017-07-07 22:12:12 +0000446 BOOST_CHECK_EQUAL(a == b, true);
447 BOOST_CHECK_EQUAL(a != b, false);
448}
449
Davide Pesaventoeee3e822016-11-26 19:19:34 +0100450BOOST_AUTO_TEST_SUITE_END() // TestInterest
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -0800451
Alexander Afanasyev90164962014-03-06 08:29:59 +0000452} // namespace tests
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -0800453} // namespace ndn