blob: f877e2ffe5760c7dd5b965cd43e597473e9c9096 [file] [log] [blame]
Giulio Grassi624f6c62014-02-18 19:42:14 +01001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "face/udp-factory.hpp"
Giulio Grassi624f6c62014-02-18 19:42:14 +01008#include "core/face-uri.hpp"
Giulio Grassi624f6c62014-02-18 19:42:14 +01009#include <ndn-cpp-dev/security/key-chain.hpp>
Junxiao Shi7e2413b2014-03-02 11:15:09 -070010
11#include "tests/test-common.hpp"
12#include "tests/core/limited-io.hpp"
Giulio Grassi624f6c62014-02-18 19:42:14 +010013
14namespace nfd {
15namespace tests {
16
17BOOST_FIXTURE_TEST_SUITE(FaceUdp, BaseFixture)
18
19class FactoryErrorCheck : protected BaseFixture
20{
21public:
22 bool isTheSameMulticastEndpoint(const UdpFactory::Error& e) {
23 return strcmp(e.what(),
24 "Cannot create the requested UDP unicast channel, local "
25 "endpoint is already allocated for a UDP multicast face") == 0;
26 }
Junxiao Shi7e2413b2014-03-02 11:15:09 -070027
Giulio Grassi624f6c62014-02-18 19:42:14 +010028 bool isNotMulticastAddress(const UdpFactory::Error& e) {
29 return strcmp(e.what(),
30 "Cannot create the requested UDP multicast face, "
31 "the multicast group given as input is not a multicast address") == 0;
32 }
Junxiao Shi7e2413b2014-03-02 11:15:09 -070033
Giulio Grassi624f6c62014-02-18 19:42:14 +010034 bool isTheSameUnicastEndpoint(const UdpFactory::Error& e) {
35 return strcmp(e.what(),
36 "Cannot create the requested UDP multicast face, local "
37 "endpoint is already allocated for a UDP unicast channel") == 0;
38 }
Junxiao Shi7e2413b2014-03-02 11:15:09 -070039
Giulio Grassi624f6c62014-02-18 19:42:14 +010040 bool isLocalEndpointOnDifferentGroup(const UdpFactory::Error& e) {
41 return strcmp(e.what(),
42 "Cannot create the requested UDP multicast face, local "
43 "endpoint is already allocated for a UDP multicast face "
44 "on a different multicast group") == 0;
45 }
46};
Junxiao Shi7e2413b2014-03-02 11:15:09 -070047
Giulio Grassi624f6c62014-02-18 19:42:14 +010048BOOST_FIXTURE_TEST_CASE(ChannelMapUdp, FactoryErrorCheck)
49{
50 using boost::asio::ip::udp;
Junxiao Shi7e2413b2014-03-02 11:15:09 -070051
Giulio Grassi624f6c62014-02-18 19:42:14 +010052 UdpFactory factory = UdpFactory();
Junxiao Shi7e2413b2014-03-02 11:15:09 -070053
Giulio Grassi624f6c62014-02-18 19:42:14 +010054 //to instantiate multicast face on a specific ip address, change interfaceIp
55 std::string interfaceIp = "0.0.0.0";
Junxiao Shi7e2413b2014-03-02 11:15:09 -070056
Giulio Grassi624f6c62014-02-18 19:42:14 +010057 shared_ptr<UdpChannel> channel1 = factory.createChannel("127.0.0.1", "20070");
58 shared_ptr<UdpChannel> channel1a = factory.createChannel("127.0.0.1", "20070");
59 BOOST_CHECK_EQUAL(channel1, channel1a);
Junxiao Shi61e3cc52014-03-03 20:40:28 -070060 BOOST_CHECK_EQUAL(channel1->getUri().toString(), "udp4://127.0.0.1:20070");
Junxiao Shi7e2413b2014-03-02 11:15:09 -070061
Giulio Grassi624f6c62014-02-18 19:42:14 +010062 shared_ptr<UdpChannel> channel2 = factory.createChannel("127.0.0.1", "20071");
63 BOOST_CHECK_NE(channel1, channel2);
64
65 shared_ptr<UdpChannel> channel3 = factory.createChannel(interfaceIp, "20070");
Junxiao Shi7e2413b2014-03-02 11:15:09 -070066
Junxiao Shi61e3cc52014-03-03 20:40:28 -070067 shared_ptr<UdpChannel> channel4 = factory.createChannel("::1", "20071");
68 BOOST_CHECK_NE(channel2, channel4);
69 BOOST_CHECK_EQUAL(channel4->getUri().toString(), "udp6://[::1]:20071");
70
Giulio Grassi624f6c62014-02-18 19:42:14 +010071 //same endpoint of a unicast channel
72 BOOST_CHECK_EXCEPTION(factory.createMulticastFace(interfaceIp,
73 "224.0.0.1",
74 "20070"),
75 UdpFactory::Error,
76 isTheSameUnicastEndpoint);
Junxiao Shi7e2413b2014-03-02 11:15:09 -070077
78
Giulio Grassi624f6c62014-02-18 19:42:14 +010079 shared_ptr<MulticastUdpFace> multicastFace1 = factory.createMulticastFace(interfaceIp,
80 "224.0.0.1",
81 "20072");
82 shared_ptr<MulticastUdpFace> multicastFace1a = factory.createMulticastFace(interfaceIp,
83 "224.0.0.1",
84 "20072");
85 BOOST_CHECK_EQUAL(multicastFace1, multicastFace1a);
Junxiao Shi7e2413b2014-03-02 11:15:09 -070086
87
Giulio Grassi624f6c62014-02-18 19:42:14 +010088 //same endpoint of a multicast face
89 BOOST_CHECK_EXCEPTION(factory.createChannel(interfaceIp, "20072"),
90 UdpFactory::Error,
91 isTheSameMulticastEndpoint);
Junxiao Shi7e2413b2014-03-02 11:15:09 -070092
Giulio Grassi624f6c62014-02-18 19:42:14 +010093 //same multicast endpoint, different group
94 BOOST_CHECK_EXCEPTION(factory.createMulticastFace(interfaceIp,
95 "224.0.0.42",
96 "20072"),
97 UdpFactory::Error,
98 isLocalEndpointOnDifferentGroup);
99
100 BOOST_CHECK_EXCEPTION(factory.createMulticastFace(interfaceIp,
101 "192.168.10.15",
102 "20025"),
103 UdpFactory::Error,
104 isNotMulticastAddress);
105
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700106
107
Giulio Grassi624f6c62014-02-18 19:42:14 +0100108// //Test commented because it required to be run in a machine that can resolve ipv6 query
109// shared_ptr<UdpChannel> channel1v6 = factory.createChannel(//"::1",
110// "fe80::5e96:9dff:fe7d:9c8d%en1",
111// //"fe80::aa54:b2ff:fe08:27b8%wlan0",
112// "20070");
113//
114// //the creation of multicastFace2 works properly. It has been disable because it needs an IP address of
115// //an available network interface (different from the first one used)
116// shared_ptr<MulticastUdpFace> multicastFace2 = factory.createMulticastFace("192.168.1.17",
117// "224.0.0.1",
118// "20073");
119// BOOST_CHECK_NE(multicastFace1, multicastFace2);
120//
121//
122// //ipv6 - work in progress
123// shared_ptr<MulticastUdpFace> multicastFace3 = factory.createMulticastFace("fe80::5e96:9dff:fe7d:9c8d%en1",
124// "FF01:0:0:0:0:0:0:2",
125// "20073");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700126//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100127// shared_ptr<MulticastUdpFace> multicastFace4 = factory.createMulticastFace("fe80::aa54:b2ff:fe08:27b8%wlan0",
128// "FF01:0:0:0:0:0:0:2",
129// "20073");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700130//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100131// BOOST_CHECK_EQUAL(multicastFace3, multicastFace4);
132//
133// shared_ptr<MulticastUdpFace> multicastFace5 = factory.createMulticastFace("::1",
134// "FF01:0:0:0:0:0:0:2",
135// "20073");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700136//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100137// BOOST_CHECK_NE(multicastFace3, multicastFace5);
138//
139// //same local ipv6 endpoint for a different multicast group
140// BOOST_CHECK_THROW(factory.createMulticastFace("fe80::aa54:b2ff:fe08:27b8%wlan0",
141// "FE01:0:0:0:0:0:0:2",
142// "20073"),
143// UdpFactory::Error);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700144//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100145// //same local ipv6 (expect for th port number) endpoint for a different multicast group
146// BOOST_CHECK_THROW(factory.createMulticastFace("fe80::aa54:b2ff:fe08:27b8%wlan0",
147// "FE01:0:0:0:0:0:0:2",
148// "20075"),
149// UdpFactory::Error);
150//
151// BOOST_CHECK_THROW(factory.createMulticastFace("fa80::20a:9dff:fef6:12ff",
152// "FE12:0:0:0:0:0:0:2",
153// "20075"),
154// UdpFactory::Error);
155//
156// //not a multicast ipv6
157// BOOST_CHECK_THROW(factory.createMulticastFace("fa80::20a:9dff:fef6:12ff",
158// "A112:0:0:0:0:0:0:2",
159// "20075"),
160// UdpFactory::Error);
161
162
163
164}
165
166class EndToEndFixture : protected BaseFixture
167{
168public:
169 void
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700170 channel1_onFaceCreated(const shared_ptr<Face>& newFace)
Giulio Grassi624f6c62014-02-18 19:42:14 +0100171 {
172 BOOST_CHECK(!static_cast<bool>(m_face1));
173 m_face1 = newFace;
174 m_face1->onReceiveInterest +=
175 bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
176 m_face1->onReceiveData +=
177 bind(&EndToEndFixture::face1_onReceiveData, this, _1);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700178 m_face1->onFail +=
Giulio Grassi624f6c62014-02-18 19:42:14 +0100179 bind(&EndToEndFixture::face1_onFail, this);
180 BOOST_CHECK_MESSAGE(true, "channel 1 face created");
181
182 m_faces.push_back(m_face1);
183
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700184 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100185 }
186
187 void
188 channel1_onConnectFailed(const std::string& reason)
189 {
190 BOOST_CHECK_MESSAGE(false, reason);
191
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700192 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100193 }
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700194
Giulio Grassi624f6c62014-02-18 19:42:14 +0100195 void
196 face1_onReceiveInterest(const Interest& interest)
197 {
198 m_face1_receivedInterests.push_back(interest);
199
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700200 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100201 }
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700202
Giulio Grassi624f6c62014-02-18 19:42:14 +0100203 void
204 face1_onReceiveData(const Data& data)
205 {
206 m_face1_receivedDatas.push_back(data);
207
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700208 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100209 }
210
211 void
212 face1_onFail()
213 {
214 m_face1.reset();
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700215 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100216 }
217
218 void
219 channel2_onFaceCreated(const shared_ptr<Face>& newFace)
220 {
221 BOOST_CHECK(!static_cast<bool>(m_face2));
222 m_face2 = newFace;
223 m_face2->onReceiveInterest +=
224 bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
225 m_face2->onReceiveData +=
226 bind(&EndToEndFixture::face2_onReceiveData, this, _1);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700227 m_face2->onFail +=
Giulio Grassi624f6c62014-02-18 19:42:14 +0100228 bind(&EndToEndFixture::face2_onFail, this);
229
230 m_faces.push_back(m_face2);
231
232 BOOST_CHECK_MESSAGE(true, "channel 2 face created");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700233 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100234 }
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700235
Giulio Grassi624f6c62014-02-18 19:42:14 +0100236 void
237 channel2_onConnectFailed(const std::string& reason)
238 {
239 BOOST_CHECK_MESSAGE(false, reason);
240
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700241 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100242 }
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700243
Giulio Grassi624f6c62014-02-18 19:42:14 +0100244 void
245 face2_onReceiveInterest(const Interest& interest)
246 {
247 m_face2_receivedInterests.push_back(interest);
248
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700249 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100250 }
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700251
Giulio Grassi624f6c62014-02-18 19:42:14 +0100252 void
253 face2_onReceiveData(const Data& data)
254 {
255 m_face2_receivedDatas.push_back(data);
256
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700257 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100258 }
259
260 void
261 face2_onFail()
262 {
263 m_face2.reset();
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700264 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100265 }
266
267 void
268 channel3_onFaceCreated(const shared_ptr<Face>& newFace)
269 {
270 BOOST_CHECK(!static_cast<bool>(m_face1));
271 m_face3 = newFace;
272 m_faces.push_back(newFace);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700273
274 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100275 }
276
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700277
Giulio Grassi624f6c62014-02-18 19:42:14 +0100278 void
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700279 channel_onFaceCreated(const shared_ptr<Face>& newFace)
Giulio Grassi624f6c62014-02-18 19:42:14 +0100280 {
281 m_faces.push_back(newFace);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700282 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100283 }
284
285 void
286 channel_onConnectFailed(const std::string& reason)
287 {
288 BOOST_CHECK_MESSAGE(false, reason);
289
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700290 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100291 }
292
293 void
294 channel_onConnectFailedOk(const std::string& reason)
295 {
296 //it's ok, it was supposed to fail
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700297 m_limitedIo.afterOp();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100298 }
299
300 void
301 checkFaceList(size_t shouldBe)
302 {
303 BOOST_CHECK_EQUAL(m_faces.size(), shouldBe);
304 }
Giulio Grassi624f6c62014-02-18 19:42:14 +0100305
306public:
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700307 LimitedIo m_limitedIo;
Giulio Grassi624f6c62014-02-18 19:42:14 +0100308
309 shared_ptr<Face> m_face1;
310 std::vector<Interest> m_face1_receivedInterests;
311 std::vector<Data> m_face1_receivedDatas;
312 shared_ptr<Face> m_face2;
313 std::vector<Interest> m_face2_receivedInterests;
314 std::vector<Data> m_face2_receivedDatas;
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700315
Giulio Grassi624f6c62014-02-18 19:42:14 +0100316 shared_ptr<Face> m_face3;
317
318
319 std::list< shared_ptr<Face> > m_faces;
320};
321
322
323BOOST_FIXTURE_TEST_CASE(EndToEnd, EndToEndFixture)
324{
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700325 UdpFactory factory;
Giulio Grassi624f6c62014-02-18 19:42:14 +0100326
327 shared_ptr<UdpChannel> channel2 = factory.createChannel("127.0.0.1", "20071");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700328
329
Giulio Grassi624f6c62014-02-18 19:42:14 +0100330 //channel2->connect("127.0.0.1", "20070",
331 // bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
332 // bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700333
Giulio Grassi624f6c62014-02-18 19:42:14 +0100334 factory.createFace(FaceUri("udp4://127.0.0.1:20070"),
335 bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
336 bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700337
338
339 BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
340 "UdpChannel error: cannot connect or cannot accept connection");
Giulio Grassi624f6c62014-02-18 19:42:14 +0100341
342 BOOST_REQUIRE(static_cast<bool>(m_face2));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700343
Giulio Grassi624f6c62014-02-18 19:42:14 +0100344 shared_ptr<UdpChannel> channel1 = factory.createChannel("127.0.0.1", "20070");
345 channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
346 bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700347
Giulio Grassi624f6c62014-02-18 19:42:14 +0100348
349 Interest interest1("ndn:/TpnzGvW9R");
350 Data data1 ("ndn:/KfczhUqVix");
351 data1.setContent(0, 0);
352 Interest interest2("ndn:/QWiIMfj5sL");
353 Data data2 ("ndn:/XNBV796f");
354 data2.setContent(0, 0);
355 Interest interest3("ndn:/QWiIhjgkj5sL");
356 Data data3 ("ndn:/XNBV794f");
357 data3.setContent(0, 0);
358
359
360 ndn::SignatureSha256WithRsa fakeSignature;
361 fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue,
362 reinterpret_cast<const uint8_t*>(0),
363 0));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700364
Giulio Grassi624f6c62014-02-18 19:42:14 +0100365 // set fake signature on data1 and data2
366 data1.setSignature(fakeSignature);
367 data2.setSignature(fakeSignature);
368 data3.setSignature(fakeSignature);
369
370 m_face2->sendInterest(interest2);
371 m_face2->sendData (data2 );
372
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700373 BOOST_CHECK_MESSAGE(m_limitedIo.run(3,//2 send + 1 listen return
374 time::seconds(1)) == LimitedIo::EXCEED_OPS,
375 "UdpChannel error: cannot send or receive Interest/Data packets");
Giulio Grassi624f6c62014-02-18 19:42:14 +0100376
377 BOOST_REQUIRE(static_cast<bool>(m_face1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700378
Giulio Grassi624f6c62014-02-18 19:42:14 +0100379 m_face1->sendInterest(interest1);
380 m_face1->sendData (data1 );
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700381
382 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
383 "UdpChannel error: cannot send or receive Interest/Data packets");
Giulio Grassi624f6c62014-02-18 19:42:14 +0100384
385
386 BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
387 BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
388 BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
389 BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700390
Giulio Grassi624f6c62014-02-18 19:42:14 +0100391 BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
392 BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
393 BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
394 BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700395
396
397
Giulio Grassi624f6c62014-02-18 19:42:14 +0100398 //checking if the connection accepting mechanism works properly.
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700399
Giulio Grassi624f6c62014-02-18 19:42:14 +0100400 m_face2->sendData (data3 );
401 m_face2->sendInterest(interest3);
402
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700403 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
404 "UdpChannel error: cannot send or receive Interest/Data packets");
405
Giulio Grassi624f6c62014-02-18 19:42:14 +0100406 BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 2);
407 BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 2);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700408
Giulio Grassi624f6c62014-02-18 19:42:14 +0100409 BOOST_CHECK_EQUAL(m_face1_receivedInterests[1].getName(), interest3.getName());
410 BOOST_CHECK_EQUAL(m_face1_receivedDatas [1].getName(), data3.getName());
411
412}
413
414BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture)
415{
416 Interest interest1("ndn:/TpnzGvW9R");
417 Interest interest2("ndn:/QWiIMfj5sL");
418 Interest interest3("ndn:/QWiIhjgkj5sL");
419
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700420 UdpFactory factory;
Giulio Grassi624f6c62014-02-18 19:42:14 +0100421
Giulio Grassi624f6c62014-02-18 19:42:14 +0100422 shared_ptr<UdpChannel> channel1 = factory.createChannel("127.0.0.1", "20070");
423 shared_ptr<UdpChannel> channel2 = factory.createChannel("127.0.0.1", "20071");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700424
425
426
Giulio Grassi624f6c62014-02-18 19:42:14 +0100427 channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1),
428 bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700429
Giulio Grassi624f6c62014-02-18 19:42:14 +0100430 channel2->connect("127.0.0.1", "20070",
431 bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
432 bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700433
434
435 BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
436 "UdpChannel error: cannot connect or cannot accept connection");
Giulio Grassi624f6c62014-02-18 19:42:14 +0100437
438 BOOST_CHECK_EQUAL(m_faces.size(), 1);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700439
Giulio Grassi624f6c62014-02-18 19:42:14 +0100440 shared_ptr<UdpChannel> channel3 = factory.createChannel("127.0.0.1", "20072");
441 channel3->connect("127.0.0.1", "20070",
442 bind(&EndToEndFixture::channel3_onFaceCreated, this, _1),
443 bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700444
Giulio Grassi624f6c62014-02-18 19:42:14 +0100445 shared_ptr<UdpChannel> channel4 = factory.createChannel("127.0.0.1", "20073");
446
447 BOOST_CHECK_NE(channel3, channel4);
Giulio Grassi624f6c62014-02-18 19:42:14 +0100448
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700449 scheduler::schedule(time::seconds(0.5),
450 bind(&UdpChannel::connect, channel4, "127.0.0.1", "20070",
451 // does not work without static_cast
452 static_cast<UdpChannel::FaceCreatedCallback>(
453 bind(&EndToEndFixture::channel_onFaceCreated, this, _1)),
454 static_cast<UdpChannel::ConnectFailedCallback>(
455 bind(&EndToEndFixture::channel_onConnectFailed, this, _1))));
456
457 scheduler::schedule(time::seconds(0.4), bind(&EndToEndFixture::checkFaceList, this, 2));
458
459 BOOST_CHECK_MESSAGE(m_limitedIo.run(2,// 2 connects
460 time::seconds(4)) == LimitedIo::EXCEED_OPS,
461 "UdpChannel error: cannot connect or cannot accept multiple connections");
462
Giulio Grassi624f6c62014-02-18 19:42:14 +0100463 BOOST_CHECK_EQUAL(m_faces.size(), 3);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700464
465
Giulio Grassi624f6c62014-02-18 19:42:14 +0100466 m_face2->sendInterest(interest1);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700467 BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
468 "UdpChannel error: cannot send or receive Interest/Data packets");
469
Giulio Grassi624f6c62014-02-18 19:42:14 +0100470 BOOST_CHECK_EQUAL(m_faces.size(), 4);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700471
Giulio Grassi624f6c62014-02-18 19:42:14 +0100472 m_face3->sendInterest(interest2);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700473 BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
474 "UdpChannel error: cannot send or receive Interest/Data packets");
475
Giulio Grassi624f6c62014-02-18 19:42:14 +0100476 //channel1 should have created 2 faces, one when m_face2 sent an interest, one when m_face3 sent an interest
477 BOOST_CHECK_EQUAL(m_faces.size(), 5);
478 BOOST_CHECK_THROW(channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated,
479 this,
480 _1),
481 bind(&EndToEndFixture::channel_onConnectFailedOk,
482 this,
483 _1)),
484 UdpChannel::Error);
485}
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700486
Giulio Grassi624f6c62014-02-18 19:42:14 +0100487//Test commented because it required to be run in a machine that can resolve ipv6 query
488//BOOST_FIXTURE_TEST_CASE(EndToEndIpv6, EndToEndFixture)
489//{
490// UdpFactory factory = UdpFactory();
491// Scheduler scheduler(g_io); // to limit the amount of time the test may take
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700492//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100493// EventId abortEvent =
494// scheduler.scheduleEvent(time::seconds(1),
495// bind(&EndToEndFixture::abortTestCase, this,
496// "UdpChannel error: cannot connect or cannot accept connection"));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700497//
498// m_limitedIoRemaining = 1;
499//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100500// shared_ptr<UdpChannel> channel1 = factory.createChannel("::1", "20070");
501// shared_ptr<UdpChannel> channel2 = factory.createChannel("::1", "20071");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700502//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100503// channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
504// bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700505//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100506// channel2->connect("::1", "20070",
507// bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
508// bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
509// g_io.run();
510// g_io.reset();
511// scheduler.cancelEvent(abortEvent);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700512//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100513// BOOST_REQUIRE(static_cast<bool>(m_face2));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700514//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100515// abortEvent =
516// scheduler.scheduleEvent(time::seconds(1),
517// bind(&EndToEndFixture::abortTestCase, this,
518// "UdpChannel error: cannot send or receive Interest/Data packets"));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700519//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100520// Interest interest1("ndn:/TpnzGvW9R");
521// Data data1 ("ndn:/KfczhUqVix");
522// data1.setContent(0, 0);
523// Interest interest2("ndn:/QWiIMfj5sL");
524// Data data2 ("ndn:/XNBV796f");
525// data2.setContent(0, 0);
526// Interest interest3("ndn:/QWiIhjgkj5sL");
527// Data data3 ("ndn:/XNBV794f");
528// data3.setContent(0, 0);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700529//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100530// ndn::SignatureSha256WithRsa fakeSignature;
531// fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700532//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100533// // set fake signature on data1 and data2
534// data1.setSignature(fakeSignature);
535// data2.setSignature(fakeSignature);
536// data3.setSignature(fakeSignature);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700537//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100538// m_face2->sendInterest(interest2);
539// m_face2->sendData (data2 );
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700540//
541// m_limitedIoRemaining = 3; //2 send + 1 listen return
Giulio Grassi624f6c62014-02-18 19:42:14 +0100542// g_io.run();
543// g_io.reset();
544// scheduler.cancelEvent(abortEvent);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700545//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100546// BOOST_REQUIRE(static_cast<bool>(m_face1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700547//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100548// m_face1->sendInterest(interest1);
549// m_face1->sendData (data1 );
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700550//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100551// abortEvent =
552// scheduler.scheduleEvent(time::seconds(1),
553// bind(&EndToEndFixture::abortTestCase, this,
554// "UdpChannel error: cannot send or receive Interest/Data packets"));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700555// m_limitedIoRemaining = 2;
Giulio Grassi624f6c62014-02-18 19:42:14 +0100556// g_io.run();
557// g_io.reset();
558// scheduler.cancelEvent(abortEvent);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700559//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100560// BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
561// BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
562// BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
563// BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700564//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100565// BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
566// BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
567// BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
568// BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700569//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100570// //checking if the connection accepting mechanism works properly.
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700571//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100572// m_face2->sendData (data3 );
573// m_face2->sendInterest(interest3);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700574//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100575// abortEvent =
576// scheduler.scheduleEvent(time::seconds(1),
577// bind(&EndToEndFixture::abortTestCase, this,
578// "UdpChannel error: cannot send or receive Interest/Data packets"));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700579// m_limitedIoRemaining = 2;
Giulio Grassi624f6c62014-02-18 19:42:14 +0100580// g_io.run();
581// g_io.reset();
582// scheduler.cancelEvent(abortEvent);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700583//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100584// BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 2);
585// BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 2);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700586//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100587// BOOST_CHECK_EQUAL(m_face1_receivedInterests[1].getName(), interest3.getName());
588// BOOST_CHECK_EQUAL(m_face1_receivedDatas [1].getName(), data3.getName());
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700589//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100590//}
591
592
593//Test commented because it required to be run in a machine that can resolve ipv6 query
594//BOOST_FIXTURE_TEST_CASE(MultipleAcceptsIpv6, EndToEndFixture)
595//{
596// Interest interest1("ndn:/TpnzGvW9R");
597// Interest interest2("ndn:/QWiIMfj5sL");
598// Interest interest3("ndn:/QWiIhjgkj5sL");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700599//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100600// UdpFactory factory = UdpFactory();
601// Scheduler scheduler(g_io); // to limit the amount of time the test may take
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700602//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100603// EventId abortEvent =
604// scheduler.scheduleEvent(time::seconds(4),
605// bind(&EndToEndFixture::abortTestCase, this,
606// "UdpChannel error: cannot connect or cannot accept connection"));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700607//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100608// shared_ptr<UdpChannel> channel1 = factory.createChannel("::1", "20070");
609// shared_ptr<UdpChannel> channel2 = factory.createChannel("::1", "20071");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700610//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100611// channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1),
612// bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700613//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100614// channel2->connect("::1", "20070",
615// bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
616// bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700617//
618// m_limitedIoRemaining = 1;
Giulio Grassi624f6c62014-02-18 19:42:14 +0100619// g_io.run();
620// g_io.reset();
621// scheduler.cancelEvent(abortEvent);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700622//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100623// BOOST_CHECK_EQUAL(m_faces.size(), 1);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700624//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100625// shared_ptr<UdpChannel> channel3 = factory.createChannel("::1", "20072");
626// channel3->connect("::1", "20070",
627// bind(&EndToEndFixture::channel3_onFaceCreated, this, _1),
628// bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700629//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100630// shared_ptr<UdpChannel> channel4 = factory.createChannel("::1", "20073");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700631//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100632// BOOST_CHECK_NE(channel3, channel4);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700633//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100634// scheduler
635// .scheduleEvent(time::seconds(0.5),
636// bind(&UdpChannel::connect, channel4,
637// "::1", "20070",
638// static_cast<UdpChannel::FaceCreatedCallback>(bind(&EndToEndFixture::
639// channel_onFaceCreated, this, _1)),
640// static_cast<UdpChannel::ConnectFailedCallback>(bind(&EndToEndFixture::
641// channel_onConnectFailed, this, _1))));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700642//
643// m_limitedIoRemaining = 2; // 2 connects
Giulio Grassi624f6c62014-02-18 19:42:14 +0100644// abortEvent =
645// scheduler.scheduleEvent(time::seconds(4),
646// bind(&EndToEndFixture::abortTestCase, this,
647// "UdpChannel error: cannot connect or cannot accept multiple connections"));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700648//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100649// scheduler.scheduleEvent(time::seconds(0.4),
650// bind(&EndToEndFixture::checkFaceList, this, 2));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700651//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100652// g_io.run();
653// g_io.reset();
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700654//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100655// BOOST_CHECK_EQUAL(m_faces.size(), 3);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700656//
657//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100658// m_face2->sendInterest(interest1);
659// abortEvent =
660// scheduler.scheduleEvent(time::seconds(1),
661// bind(&EndToEndFixture::abortTestCase, this,
662// "UdpChannel error: cannot send or receive Interest/Data packets"));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700663// m_limitedIoRemaining = 1;
Giulio Grassi624f6c62014-02-18 19:42:14 +0100664// g_io.run();
665// g_io.reset();
666// scheduler.cancelEvent(abortEvent);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700667//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100668// BOOST_CHECK_EQUAL(m_faces.size(), 4);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700669//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100670// m_face3->sendInterest(interest2);
671// abortEvent =
672// scheduler.scheduleEvent(time::seconds(1),
673// bind(&EndToEndFixture::abortTestCase, this,
674// "UdpChannel error: cannot send or receive Interest/Data packets"));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700675// m_limitedIoRemaining = 1;
Giulio Grassi624f6c62014-02-18 19:42:14 +0100676// g_io.run();
677// g_io.reset();
678// scheduler.cancelEvent(abortEvent);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700679//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100680// //channel1 should have created 2 faces, one when m_face2 sent an interest, one when m_face3 sent an interest
681// BOOST_CHECK_EQUAL(m_faces.size(), 5);
682// BOOST_CHECK_THROW(channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated,
683// this,
684// _1),
685// bind(&EndToEndFixture::channel_onConnectFailedOk,
686// this,
687// _1)),
688// UdpChannel::Error);
689//}
690
691
692BOOST_FIXTURE_TEST_CASE(FaceClosing, EndToEndFixture)
693{
694 UdpFactory factory = UdpFactory();
Giulio Grassi624f6c62014-02-18 19:42:14 +0100695
Giulio Grassi624f6c62014-02-18 19:42:14 +0100696 shared_ptr<UdpChannel> channel1 = factory.createChannel("127.0.0.1", "20070");
697 shared_ptr<UdpChannel> channel2 = factory.createChannel("127.0.0.1", "20071");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700698
Giulio Grassi624f6c62014-02-18 19:42:14 +0100699 channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
700 bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700701
Giulio Grassi624f6c62014-02-18 19:42:14 +0100702 channel2->connect("127.0.0.1", "20070",
703 bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
704 bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700705
706 BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
707 "UdpChannel error: cannot connect or cannot accept connection");
Giulio Grassi624f6c62014-02-18 19:42:14 +0100708
709 BOOST_CHECK_EQUAL(channel2->size(), 1);
710
Giulio Grassi624f6c62014-02-18 19:42:14 +0100711 BOOST_CHECK(static_cast<bool>(m_face2));
712
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700713 // Face::close must be invoked during io run to be counted as an op
714 scheduler::schedule(time::seconds(0.1), bind(&Face::close, m_face2));
715
716 BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
717 "FaceClosing error: cannot properly close faces");
Giulio Grassi624f6c62014-02-18 19:42:14 +0100718
719 BOOST_CHECK(!static_cast<bool>(m_face2));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700720
Giulio Grassi624f6c62014-02-18 19:42:14 +0100721 BOOST_CHECK_EQUAL(channel2->size(), 0);
722}
723
724//BOOST_FIXTURE_TEST_CASE(MulticastFace, EndToEndFixture)
725//{
726// //to instantiate multicast face on a specific ip address, change interfaceIp
727// std::string interfaceIp = "0.0.0.0";
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700728//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100729// UdpFactory factory = UdpFactory();
730// Scheduler scheduler(g_io); // to limit the amount of time the test may take
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700731//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100732// shared_ptr<MulticastUdpFace> multicastFace1 =
733// factory.createMulticastFace(interfaceIp, "224.0.0.1", "20072");
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700734//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100735// BOOST_REQUIRE(static_cast<bool>(multicastFace1));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700736//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100737// channel1_onFaceCreated(multicastFace1);
738//
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700739//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100740// EventId abortEvent =
741// scheduler.scheduleEvent(time::seconds(10),
742// bind(&EndToEndFixture::abortTestCase, this,
743// "MulticastFace error: cannot send or receive Interest/Data packets"));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700744//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100745// Interest interest1("ndn:/TpnzGvW9R");
746// Data data1 ("ndn:/KfczhUqVix");
747// data1.setContent(0, 0);
748// Interest interest2("ndn:/QWiIMfj5sL");
749// Data data2 ("ndn:/XNBV796f");
750// data2.setContent(0, 0);
751// Interest interest3("ndn:/QWiIhjgkj5sL");
752// Data data3 ("ndn:/XNBV794f");
753// data3.setContent(0, 0);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700754//
755//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100756// ndn::SignatureSha256WithRsa fakeSignature;
757// fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700758//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100759// // set fake signature on data1 and data2
760// data1.setSignature(fakeSignature);
761// data2.setSignature(fakeSignature);
762// data3.setSignature(fakeSignature);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700763//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100764// multicastFace1->sendInterest(interest1);
765// multicastFace1->sendData (data1 );
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700766//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100767// g_io.reset();
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700768// m_limitedIoRemaining = 2;
Giulio Grassi624f6c62014-02-18 19:42:14 +0100769// g_io.run();
770// g_io.reset();
771// scheduler.cancelEvent(abortEvent);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700772//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100773// BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
774// BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700775//
Giulio Grassi624f6c62014-02-18 19:42:14 +0100776// BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest1.getName());
777// BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data1.getName());
778//}
779
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700780
781
Giulio Grassi624f6c62014-02-18 19:42:14 +0100782BOOST_AUTO_TEST_SUITE_END()
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700783
Giulio Grassi624f6c62014-02-18 19:42:14 +0100784} // namespace tests
785} // namespace nfd