blob: 09ee905b41a0576ca4194021374dd95e28a4e1b9 [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);
177 m_face1->sendData (data1 );
178 m_face2->sendInterest(interest2);
179 m_face2->sendData (data2 );
180
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700181 BOOST_CHECK_MESSAGE(m_limitedIo.run(4, time::seconds(1)) == LimitedIo::EXCEED_OPS,
182 "UnixStreamChannel error: cannot send or receive Interest/Data packets");
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100183
184 BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
185 BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
186 BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
187 BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
188
189 BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
190 BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
191 BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
192 BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
193}
194
195BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture)
196{
Alexander Afanasyev0eb70652014-02-27 18:35:07 -0800197 UnixStreamFactory factory;
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100198
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700199 shared_ptr<UnixStreamChannel> channel = factory.createChannel(CHANNEL_PATH1);
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100200 channel->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1),
201 bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
202
203 shared_ptr<stream_protocol::socket> client1 =
Alexander Afanasyev7329e022014-02-27 14:47:22 -0800204 make_shared<stream_protocol::socket>(boost::ref(g_io));
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700205 client1->async_connect(stream_protocol::endpoint(CHANNEL_PATH1),
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100206 bind(&EndToEndFixture::client_onConnect, this, _1));
207
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700208 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
209 "UnixStreamChannel error: cannot connect or cannot accept connection");
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100210
211 BOOST_CHECK_EQUAL(m_faces.size(), 1);
212
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100213 shared_ptr<stream_protocol::socket> client2 =
Alexander Afanasyev7329e022014-02-27 14:47:22 -0800214 make_shared<stream_protocol::socket>(boost::ref(g_io));
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700215 client2->async_connect(stream_protocol::endpoint(CHANNEL_PATH1),
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100216 bind(&EndToEndFixture::client_onConnect, this, _1));
217
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700218 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
219 "UnixStreamChannel error: cannot accept multiple connections");
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100220
221 BOOST_CHECK_EQUAL(m_faces.size(), 2);
222
223 // now close one of the faces
224 m_faces.front()->close();
225
226 // we should still be able to send/receive with the other one
227 m_face1 = m_faces.back();
228 m_face1->onReceiveInterest +=
229 bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
230 m_face1->onReceiveData +=
231 bind(&EndToEndFixture::face1_onReceiveData, this, _1);
232
233 m_face2 = make_shared<UnixStreamFace>(client2);
234 m_face2->onReceiveInterest +=
235 bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
236 m_face2->onReceiveData +=
237 bind(&EndToEndFixture::face2_onReceiveData, this, _1);
238
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100239 Interest interest1("ndn:/TpnzGvW9R");
240 Data data1 ("ndn:/KfczhUqVix");
241 data1.setContent(0, 0);
242 Interest interest2("ndn:/QWiIMfj5sL");
243 Data data2 ("ndn:/XNBV796f");
244 data2.setContent(0, 0);
245
246 ndn::SignatureSha256WithRsa fakeSignature;
247 fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
248
249 // set fake signature on data1 and data2
250 data1.setSignature(fakeSignature);
251 data2.setSignature(fakeSignature);
252
253 m_face1->sendInterest(interest1);
254 m_face1->sendData (data1 );
255 m_face2->sendInterest(interest2);
256 m_face2->sendData (data2 );
257
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700258 BOOST_CHECK_MESSAGE(m_limitedIo.run(4, time::seconds(1)) == LimitedIo::EXCEED_OPS,
259 "UnixStreamChannel error: cannot send or receive Interest/Data packets");
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100260
261 BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
262 BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
263 BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
264 BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
265
266 BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
267 BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
268 BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
269 BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
270}
271
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800272static inline void
273noOp()
274{
275}
276
277BOOST_FIXTURE_TEST_CASE(UnixStreamFaceLocalControlHeader, EndToEndFixture)
278{
Alexander Afanasyev0eb70652014-02-27 18:35:07 -0800279 UnixStreamFactory factory;
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800280
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700281 shared_ptr<UnixStreamChannel> channel1 = factory.createChannel(CHANNEL_PATH1);
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800282 channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
283 bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
284
285 shared_ptr<stream_protocol::socket> client =
Alexander Afanasyev7329e022014-02-27 14:47:22 -0800286 make_shared<stream_protocol::socket>(boost::ref(g_io));
Junxiao Shi61e3cc52014-03-03 20:40:28 -0700287 client->async_connect(stream_protocol::endpoint(CHANNEL_PATH1),
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800288 bind(&EndToEndFixture::client_onConnect, this, _1));
289
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700290 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
291 "UnixStreamChannel error: cannot connect or cannot accept connection");
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800292
293 BOOST_REQUIRE(static_cast<bool>(m_face1));
294
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800295 m_face2 = make_shared<UnixStreamFace>(client);
296 m_face2->onReceiveInterest +=
297 bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
298 m_face2->onReceiveData +=
299 bind(&EndToEndFixture::face2_onReceiveData, this, _1);
300
301 Interest interest1("ndn:/TpnzGvW9R");
302 Data data1 ("ndn:/KfczhUqVix");
303 data1.setContent(0, 0);
304 Interest interest2("ndn:/QWiIMfj5sL");
305 Data data2 ("ndn:/XNBV796f");
306 data2.setContent(0, 0);
307
308 ndn::SignatureSha256WithRsa fakeSignature;
309 fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
310
311 // set fake signature on data1 and data2
312 data1.setSignature(fakeSignature);
313 data2.setSignature(fakeSignature);
314
315 m_face1->setLocalControlHeaderFeature(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID);
316 m_face1->setLocalControlHeaderFeature(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID);
317
318 BOOST_CHECK(m_face1->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
319 BOOST_CHECK(m_face1->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
320
321 m_face2->setLocalControlHeaderFeature(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID);
322 m_face2->setLocalControlHeaderFeature(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID);
323
324 BOOST_CHECK(m_face2->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
325 BOOST_CHECK(m_face2->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
326
327 ////////////////////////////////////////////////////////
328
329 interest1.setIncomingFaceId(11);
330 interest1.setNextHopFaceId(111);
331
332 m_face1->sendInterest(interest1);
333
334 data1.setIncomingFaceId(22);
335 data1.getLocalControlHeader().setNextHopFaceId(222);
336
337 m_face1->sendData (data1);
338
339 //
340
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700341 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
342 "UnixStreamChannel error: cannot send or receive Interest/Data packets");
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800343
344 BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
345 BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
346
347 // sending allows only IncomingFaceId, receiving allows only NextHopFaceId
348 BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getLocalControlHeader().hasIncomingFaceId(), false);
349 BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getLocalControlHeader().hasNextHopFaceId(), false);
350
351 BOOST_CHECK_EQUAL(m_face2_receivedDatas[0].getLocalControlHeader().hasIncomingFaceId(), false);
352 BOOST_CHECK_EQUAL(m_face2_receivedDatas[0].getLocalControlHeader().hasNextHopFaceId(), false);
353
354 ////////////////////////////////////////////////////////
355
356 using namespace boost::asio;
357
358 std::vector<const_buffer> interestWithHeader;
359 Block iHeader = interest1.getLocalControlHeader().wireEncode(interest1, true, true);
360 Block iPayload = interest1.wireEncode();
361 interestWithHeader.push_back(buffer(iHeader.wire(), iHeader.size()));
362 interestWithHeader.push_back(buffer(iPayload.wire(), iPayload.size()));
363
364 std::vector<const_buffer> dataWithHeader;
365 Block dHeader = data1.getLocalControlHeader().wireEncode(data1, true, true);
366 Block dPayload = data1.wireEncode();
367 dataWithHeader.push_back(buffer(dHeader.wire(), dHeader.size()));
368 dataWithHeader.push_back(buffer(dPayload.wire(), dPayload.size()));
369
370 //
371
372 client->async_send(interestWithHeader, bind(&noOp));
373 client->async_send(dataWithHeader, bind(&noOp));
374
Junxiao Shi7e2413b2014-03-02 11:15:09 -0700375 BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
376 "UnixStreamChannel error: cannot send or receive Interest/Data packets");
Alexander Afanasyevbd220a02014-02-20 00:29:56 -0800377
378 BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
379 BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
380
381 BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getLocalControlHeader().hasIncomingFaceId(), false);
382 BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getLocalControlHeader().hasNextHopFaceId(), true);
383 BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getNextHopFaceId(), 111);
384
385 BOOST_CHECK_EQUAL(m_face1_receivedDatas[0].getLocalControlHeader().hasIncomingFaceId(), false);
386 BOOST_CHECK_EQUAL(m_face1_receivedDatas[0].getLocalControlHeader().hasNextHopFaceId(), false);
387}
388
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100389BOOST_AUTO_TEST_SUITE_END()
390
Junxiao Shid9ee45c2014-02-27 15:38:11 -0700391} // namespace tests
Davide Pesaventobc4dd8c2014-02-14 20:01:01 +0100392} // namespace nfd