blob: 285b85f5fb78cda900e5d85d475d88ee8584b434 [file] [log] [blame]
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +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
Alexander Afanasyev0eb70652014-02-27 18:35:07 -08007#include "face/unix-stream-factory.hpp"
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +01008#include <ndn-cpp-dev/security/key-chain.hpp>
9
Junxiao Shid9ee45c2014-02-27 15:38:11 -070010#include "tests/test-common.hpp"
Junxiao Shi7e2413b2014-03-02 11:15:09 -070011#include "tests/core/limited-io.hpp"
Junxiao Shid9ee45c2014-02-27 15:38:11 -070012
13namespace nfd {
14namespace tests {
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010015
16using namespace boost::asio::local;
17
Junxiao Shi61e3cc52014-03-03 20:40:28 -070018#define CHANNEL_PATH1 "unix-stream-test.1.sock"
19#define CHANNEL_PATH2 "unix-stream-test.2.sock"
20
Junxiao Shid9ee45c2014-02-27 15:38:11 -070021BOOST_FIXTURE_TEST_SUITE(FaceUnixStream, BaseFixture)
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010022
23BOOST_AUTO_TEST_CASE(ChannelMap)
24{
Alexander Afanasyev0eb70652014-02-27 18:35:07 -080025 UnixStreamFactory factory;
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010026
Junxiao Shi61e3cc52014-03-03 20:40:28 -070027 shared_ptr<UnixStreamChannel> channel1 = factory.createChannel(CHANNEL_PATH1);
28 shared_ptr<UnixStreamChannel> channel1a = factory.createChannel(CHANNEL_PATH1);
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010029 BOOST_CHECK_EQUAL(channel1, channel1a);
Junxiao Shi61e3cc52014-03-03 20:40:28 -070030 std::string channel1uri = channel1->getUri().toString();
31 BOOST_CHECK_EQUAL(channel1uri.find("unix:///"), 0); // third '/' is the path separator
32 BOOST_CHECK_EQUAL(channel1uri.rfind(CHANNEL_PATH1),
33 channel1uri.size() - std::string(CHANNEL_PATH1).size());
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010034
Junxiao Shi61e3cc52014-03-03 20:40:28 -070035 shared_ptr<UnixStreamChannel> channel2 = factory.createChannel(CHANNEL_PATH2);
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010036 BOOST_CHECK_NE(channel1, channel2);
37}
38
Junxiao Shid9ee45c2014-02-27 15:38:11 -070039class EndToEndFixture : protected BaseFixture
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010040{
41public:
42 void
43 client_onConnect(const boost::system::error_code& error)
44 {
45 BOOST_CHECK_MESSAGE(!error, error.message());
46
Junxiao Shi7e2413b2014-03-02 11:15:09 -070047 m_limitedIo.afterOp();
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010048 }
49
50 void
Junxiao Shi61e3cc52014-03-03 20:40:28 -070051 channel1_onFaceCreated(const shared_ptr<Face>& newFace)
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010052 {
53 BOOST_CHECK(!static_cast<bool>(m_face1));
Junxiao Shi61e3cc52014-03-03 20:40:28 -070054 m_face1 = static_pointer_cast<UnixStreamFace>(newFace);
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010055 m_face1->onReceiveInterest +=
56 bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
57 m_face1->onReceiveData +=
58 bind(&EndToEndFixture::face1_onReceiveData, this, _1);
59
Junxiao Shi7e2413b2014-03-02 11:15:09 -070060 m_limitedIo.afterOp();
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010061 }
62
63 void
64 channel1_onConnectFailed(const std::string& reason)
65 {
66 BOOST_CHECK_MESSAGE(false, reason);
67
Junxiao Shi7e2413b2014-03-02 11:15:09 -070068 m_limitedIo.afterOp();
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010069 }
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080070
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010071 void
72 face1_onReceiveInterest(const Interest& interest)
73 {
74 m_face1_receivedInterests.push_back(interest);
75
Junxiao Shi7e2413b2014-03-02 11:15:09 -070076 m_limitedIo.afterOp();
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010077 }
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080078
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010079 void
80 face1_onReceiveData(const Data& data)
81 {
82 m_face1_receivedDatas.push_back(data);
83
Junxiao Shi7e2413b2014-03-02 11:15:09 -070084 m_limitedIo.afterOp();
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010085 }
86
87 void
88 face2_onReceiveInterest(const Interest& interest)
89 {
90 m_face2_receivedInterests.push_back(interest);
91
Junxiao Shi7e2413b2014-03-02 11:15:09 -070092 m_limitedIo.afterOp();
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010093 }
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080094
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +010095 void
96 face2_onReceiveData(const Data& data)
97 {
98 m_face2_receivedDatas.push_back(data);
99
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700100 m_limitedIo.afterOp();
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100101 }
102
103 void
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700104 channel_onFaceCreated(const shared_ptr<Face>& newFace)
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100105 {
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700106 m_faces.push_back(static_pointer_cast<UnixStreamFace>(newFace));
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100107
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700108 m_limitedIo.afterOp();
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100109 }
110
111 void
112 channel_onConnectFailed(const std::string& reason)
113 {
114 BOOST_CHECK_MESSAGE(false, reason);
115
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700116 m_limitedIo.afterOp();
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100117 }
118
119protected:
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700120 LimitedIo m_limitedIo;
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100121
122 shared_ptr<UnixStreamFace> m_face1;
123 std::vector<Interest> m_face1_receivedInterests;
124 std::vector<Data> m_face1_receivedDatas;
125 shared_ptr<UnixStreamFace> m_face2;
126 std::vector<Interest> m_face2_receivedInterests;
127 std::vector<Data> m_face2_receivedDatas;
128
129 std::list< shared_ptr<UnixStreamFace> > m_faces;
130};
131
132
133BOOST_FIXTURE_TEST_CASE(EndToEnd, EndToEndFixture)
134{
Alexander Afanasyev0eb70652014-02-27 18:35:07 -0800135 UnixStreamFactory factory;
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100136
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700137 shared_ptr<UnixStreamChannel> channel1 = factory.createChannel(CHANNEL_PATH1);
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100138 channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
139 bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
140
141 shared_ptr<stream_protocol::socket> client =
Alexander Afanasyev7329e022014-02-27 14:47:22 -0800142 make_shared<stream_protocol::socket>(boost::ref(g_io));
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700143 client->async_connect(stream_protocol::endpoint(CHANNEL_PATH1),
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100144 bind(&EndToEndFixture::client_onConnect, this, _1));
145
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700146 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
147 "UnixStreamChannel error: cannot connect or cannot accept connection");
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100148
149 BOOST_REQUIRE(static_cast<bool>(m_face1));
150
Alexander Afanasyeva39b90b2014-03-05 15:31:00 +0000151 std::string face1uri = m_face1->getUri().toString();
152 BOOST_CHECK_EQUAL(face1uri.find("unix:///"), 0); // third '/' is the path separator
153 BOOST_CHECK_EQUAL(face1uri.rfind(CHANNEL_PATH1),
154 face1uri.size() - std::string(CHANNEL_PATH1).size());
155
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100156 m_face2 = make_shared<UnixStreamFace>(client);
157 m_face2->onReceiveInterest +=
158 bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
159 m_face2->onReceiveData +=
160 bind(&EndToEndFixture::face2_onReceiveData, this, _1);
161
162 Interest interest1("ndn:/TpnzGvW9R");
163 Data data1 ("ndn:/KfczhUqVix");
164 data1.setContent(0, 0);
165 Interest interest2("ndn:/QWiIMfj5sL");
166 Data data2 ("ndn:/XNBV796f");
167 data2.setContent(0, 0);
168
169 ndn::SignatureSha256WithRsa fakeSignature;
170 fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
171
172 // set fake signature on data1 and data2
173 data1.setSignature(fakeSignature);
174 data2.setSignature(fakeSignature);
175
176 m_face1->sendInterest(interest1);
Alexander Afanasyev7e698e62014-03-07 16:48:35 +0000177 m_face1->sendInterest(interest1);
178 m_face1->sendInterest(interest1);
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100179 m_face1->sendData (data1 );
180 m_face2->sendInterest(interest2);
181 m_face2->sendData (data2 );
Alexander Afanasyev7e698e62014-03-07 16:48:35 +0000182 m_face2->sendData (data2 );
183 m_face2->sendData (data2 );
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100184
Alexander Afanasyev7e698e62014-03-07 16:48:35 +0000185 BOOST_CHECK_MESSAGE(m_limitedIo.run(8, time::seconds(1)) == LimitedIo::EXCEED_OPS,
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700186 "UnixStreamChannel error: cannot send or receive Interest/Data packets");
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100187
188 BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
Alexander Afanasyev7e698e62014-03-07 16:48:35 +0000189 BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 3);
190 BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 3);
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100191 BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
192
193 BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
194 BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
195 BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
196 BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
Alexander Afanasyev7e698e62014-03-07 16:48:35 +0000197
198 const FaceCounters& counters1 = m_face1->getCounters();
199 BOOST_CHECK_EQUAL(counters1.getInInterest() , 1);
200 BOOST_CHECK_EQUAL(counters1.getInData() , 3);
201 BOOST_CHECK_EQUAL(counters1.getOutInterest(), 3);
202 BOOST_CHECK_EQUAL(counters1.getOutData() , 1);
203
204 const FaceCounters& counters2 = m_face2->getCounters();
205 BOOST_CHECK_EQUAL(counters2.getInInterest() , 3);
206 BOOST_CHECK_EQUAL(counters2.getInData() , 1);
207 BOOST_CHECK_EQUAL(counters2.getOutInterest(), 1);
208 BOOST_CHECK_EQUAL(counters2.getOutData() , 3);
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100209}
210
211BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture)
212{
Alexander Afanasyev0eb70652014-02-27 18:35:07 -0800213 UnixStreamFactory factory;
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100214
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700215 shared_ptr<UnixStreamChannel> channel = factory.createChannel(CHANNEL_PATH1);
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100216 channel->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1),
217 bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
218
219 shared_ptr<stream_protocol::socket> client1 =
Alexander Afanasyev7329e022014-02-27 14:47:22 -0800220 make_shared<stream_protocol::socket>(boost::ref(g_io));
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700221 client1->async_connect(stream_protocol::endpoint(CHANNEL_PATH1),
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100222 bind(&EndToEndFixture::client_onConnect, this, _1));
223
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700224 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
225 "UnixStreamChannel error: cannot connect or cannot accept connection");
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100226
227 BOOST_CHECK_EQUAL(m_faces.size(), 1);
228
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100229 shared_ptr<stream_protocol::socket> client2 =
Alexander Afanasyev7329e022014-02-27 14:47:22 -0800230 make_shared<stream_protocol::socket>(boost::ref(g_io));
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700231 client2->async_connect(stream_protocol::endpoint(CHANNEL_PATH1),
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100232 bind(&EndToEndFixture::client_onConnect, this, _1));
233
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700234 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
235 "UnixStreamChannel error: cannot accept multiple connections");
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100236
237 BOOST_CHECK_EQUAL(m_faces.size(), 2);
238
239 // now close one of the faces
240 m_faces.front()->close();
241
242 // we should still be able to send/receive with the other one
243 m_face1 = m_faces.back();
244 m_face1->onReceiveInterest +=
245 bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
246 m_face1->onReceiveData +=
247 bind(&EndToEndFixture::face1_onReceiveData, this, _1);
248
249 m_face2 = make_shared<UnixStreamFace>(client2);
250 m_face2->onReceiveInterest +=
251 bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
252 m_face2->onReceiveData +=
253 bind(&EndToEndFixture::face2_onReceiveData, this, _1);
254
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100255 Interest interest1("ndn:/TpnzGvW9R");
256 Data data1 ("ndn:/KfczhUqVix");
257 data1.setContent(0, 0);
258 Interest interest2("ndn:/QWiIMfj5sL");
259 Data data2 ("ndn:/XNBV796f");
260 data2.setContent(0, 0);
261
262 ndn::SignatureSha256WithRsa fakeSignature;
263 fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
264
265 // set fake signature on data1 and data2
266 data1.setSignature(fakeSignature);
267 data2.setSignature(fakeSignature);
268
269 m_face1->sendInterest(interest1);
270 m_face1->sendData (data1 );
271 m_face2->sendInterest(interest2);
272 m_face2->sendData (data2 );
273
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700274 BOOST_CHECK_MESSAGE(m_limitedIo.run(4, time::seconds(1)) == LimitedIo::EXCEED_OPS,
275 "UnixStreamChannel error: cannot send or receive Interest/Data packets");
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100276
277 BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
278 BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
279 BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
280 BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
281
282 BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
283 BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
284 BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
285 BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
286}
287
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800288static inline void
289noOp()
290{
291}
292
293BOOST_FIXTURE_TEST_CASE(UnixStreamFaceLocalControlHeader, EndToEndFixture)
294{
Alexander Afanasyev0eb70652014-02-27 18:35:07 -0800295 UnixStreamFactory factory;
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800296
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700297 shared_ptr<UnixStreamChannel> channel1 = factory.createChannel(CHANNEL_PATH1);
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800298 channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
299 bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
300
301 shared_ptr<stream_protocol::socket> client =
Alexander Afanasyev7329e022014-02-27 14:47:22 -0800302 make_shared<stream_protocol::socket>(boost::ref(g_io));
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700303 client->async_connect(stream_protocol::endpoint(CHANNEL_PATH1),
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800304 bind(&EndToEndFixture::client_onConnect, this, _1));
305
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700306 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
307 "UnixStreamChannel error: cannot connect or cannot accept connection");
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800308
309 BOOST_REQUIRE(static_cast<bool>(m_face1));
310
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800311 m_face2 = make_shared<UnixStreamFace>(client);
312 m_face2->onReceiveInterest +=
313 bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
314 m_face2->onReceiveData +=
315 bind(&EndToEndFixture::face2_onReceiveData, this, _1);
316
317 Interest interest1("ndn:/TpnzGvW9R");
318 Data data1 ("ndn:/KfczhUqVix");
319 data1.setContent(0, 0);
320 Interest interest2("ndn:/QWiIMfj5sL");
321 Data data2 ("ndn:/XNBV796f");
322 data2.setContent(0, 0);
323
324 ndn::SignatureSha256WithRsa fakeSignature;
325 fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
326
327 // set fake signature on data1 and data2
328 data1.setSignature(fakeSignature);
329 data2.setSignature(fakeSignature);
330
331 m_face1->setLocalControlHeaderFeature(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID);
332 m_face1->setLocalControlHeaderFeature(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID);
333
334 BOOST_CHECK(m_face1->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
335 BOOST_CHECK(m_face1->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
336
337 m_face2->setLocalControlHeaderFeature(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID);
338 m_face2->setLocalControlHeaderFeature(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID);
339
340 BOOST_CHECK(m_face2->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
341 BOOST_CHECK(m_face2->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
342
343 ////////////////////////////////////////////////////////
344
345 interest1.setIncomingFaceId(11);
346 interest1.setNextHopFaceId(111);
347
348 m_face1->sendInterest(interest1);
349
350 data1.setIncomingFaceId(22);
351 data1.getLocalControlHeader().setNextHopFaceId(222);
352
353 m_face1->sendData (data1);
354
355 //
356
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700357 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
358 "UnixStreamChannel error: cannot send or receive Interest/Data packets");
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800359
360 BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
361 BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
362
363 // sending allows only IncomingFaceId, receiving allows only NextHopFaceId
364 BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getLocalControlHeader().hasIncomingFaceId(), false);
365 BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getLocalControlHeader().hasNextHopFaceId(), false);
366
367 BOOST_CHECK_EQUAL(m_face2_receivedDatas[0].getLocalControlHeader().hasIncomingFaceId(), false);
368 BOOST_CHECK_EQUAL(m_face2_receivedDatas[0].getLocalControlHeader().hasNextHopFaceId(), false);
369
370 ////////////////////////////////////////////////////////
371
372 using namespace boost::asio;
373
374 std::vector<const_buffer> interestWithHeader;
375 Block iHeader = interest1.getLocalControlHeader().wireEncode(interest1, true, true);
376 Block iPayload = interest1.wireEncode();
377 interestWithHeader.push_back(buffer(iHeader.wire(), iHeader.size()));
378 interestWithHeader.push_back(buffer(iPayload.wire(), iPayload.size()));
379
380 std::vector<const_buffer> dataWithHeader;
381 Block dHeader = data1.getLocalControlHeader().wireEncode(data1, true, true);
382 Block dPayload = data1.wireEncode();
383 dataWithHeader.push_back(buffer(dHeader.wire(), dHeader.size()));
384 dataWithHeader.push_back(buffer(dPayload.wire(), dPayload.size()));
385
386 //
387
388 client->async_send(interestWithHeader, bind(&noOp));
389 client->async_send(dataWithHeader, bind(&noOp));
390
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700391 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
392 "UnixStreamChannel error: cannot send or receive Interest/Data packets");
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800393
394 BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
395 BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
396
397 BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getLocalControlHeader().hasIncomingFaceId(), false);
398 BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getLocalControlHeader().hasNextHopFaceId(), true);
399 BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getNextHopFaceId(), 111);
400
401 BOOST_CHECK_EQUAL(m_face1_receivedDatas[0].getLocalControlHeader().hasIncomingFaceId(), false);
402 BOOST_CHECK_EQUAL(m_face1_receivedDatas[0].getLocalControlHeader().hasNextHopFaceId(), false);
403}
404
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100405BOOST_AUTO_TEST_SUITE_END()
406
Junxiao Shid9ee45c2014-02-27 15:38:11 -0700407} // namespace tests
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100408} // namespace nfd