Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 1 | /* -*- 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 Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 8 | #include "core/face-uri.hpp" |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 9 | #include <ndn-cpp-dev/security/key-chain.hpp> |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 10 | |
| 11 | #include "tests/test-common.hpp" |
| 12 | #include "tests/core/limited-io.hpp" |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 13 | |
| 14 | namespace nfd { |
| 15 | namespace tests { |
| 16 | |
| 17 | BOOST_FIXTURE_TEST_SUITE(FaceUdp, BaseFixture) |
| 18 | |
| 19 | class FactoryErrorCheck : protected BaseFixture |
| 20 | { |
| 21 | public: |
| 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 27 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 28 | 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 33 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 34 | 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 39 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 40 | 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 47 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 48 | BOOST_FIXTURE_TEST_CASE(ChannelMapUdp, FactoryErrorCheck) |
| 49 | { |
| 50 | using boost::asio::ip::udp; |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 51 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 52 | UdpFactory factory = UdpFactory(); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 53 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 54 | //to instantiate multicast face on a specific ip address, change interfaceIp |
| 55 | std::string interfaceIp = "0.0.0.0"; |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 56 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 57 | 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 Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 60 | BOOST_CHECK_EQUAL(channel1->getUri().toString(), "udp4://127.0.0.1:20070"); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 61 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 62 | 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 66 | |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 67 | 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 Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 71 | //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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 77 | |
| 78 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 79 | 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 86 | |
| 87 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 88 | //same endpoint of a multicast face |
| 89 | BOOST_CHECK_EXCEPTION(factory.createChannel(interfaceIp, "20072"), |
| 90 | UdpFactory::Error, |
| 91 | isTheSameMulticastEndpoint); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 92 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 93 | //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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 106 | |
| 107 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 108 | // //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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 126 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 127 | // shared_ptr<MulticastUdpFace> multicastFace4 = factory.createMulticastFace("fe80::aa54:b2ff:fe08:27b8%wlan0", |
| 128 | // "FF01:0:0:0:0:0:0:2", |
| 129 | // "20073"); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 130 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 131 | // 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 136 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 137 | // 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 144 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 145 | // //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 | |
| 166 | class EndToEndFixture : protected BaseFixture |
| 167 | { |
| 168 | public: |
| 169 | void |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 170 | channel1_onFaceCreated(const shared_ptr<Face>& newFace) |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 171 | { |
| 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 178 | m_face1->onFail += |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 179 | bind(&EndToEndFixture::face1_onFail, this); |
| 180 | BOOST_CHECK_MESSAGE(true, "channel 1 face created"); |
| 181 | |
| 182 | m_faces.push_back(m_face1); |
| 183 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 184 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | void |
| 188 | channel1_onConnectFailed(const std::string& reason) |
| 189 | { |
| 190 | BOOST_CHECK_MESSAGE(false, reason); |
| 191 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 192 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 193 | } |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 194 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 195 | void |
| 196 | face1_onReceiveInterest(const Interest& interest) |
| 197 | { |
| 198 | m_face1_receivedInterests.push_back(interest); |
| 199 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 200 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 201 | } |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 202 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 203 | void |
| 204 | face1_onReceiveData(const Data& data) |
| 205 | { |
| 206 | m_face1_receivedDatas.push_back(data); |
| 207 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 208 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | void |
| 212 | face1_onFail() |
| 213 | { |
| 214 | m_face1.reset(); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 215 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 216 | } |
| 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 227 | m_face2->onFail += |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 228 | bind(&EndToEndFixture::face2_onFail, this); |
| 229 | |
| 230 | m_faces.push_back(m_face2); |
| 231 | |
| 232 | BOOST_CHECK_MESSAGE(true, "channel 2 face created"); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 233 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 234 | } |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 235 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 236 | void |
| 237 | channel2_onConnectFailed(const std::string& reason) |
| 238 | { |
| 239 | BOOST_CHECK_MESSAGE(false, reason); |
| 240 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 241 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 242 | } |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 243 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 244 | void |
| 245 | face2_onReceiveInterest(const Interest& interest) |
| 246 | { |
| 247 | m_face2_receivedInterests.push_back(interest); |
| 248 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 249 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 250 | } |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 251 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 252 | void |
| 253 | face2_onReceiveData(const Data& data) |
| 254 | { |
| 255 | m_face2_receivedDatas.push_back(data); |
| 256 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 257 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | void |
| 261 | face2_onFail() |
| 262 | { |
| 263 | m_face2.reset(); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 264 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 265 | } |
| 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 273 | |
| 274 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 275 | } |
| 276 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 277 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 278 | void |
Junxiao Shi | 61e3cc5 | 2014-03-03 20:40:28 -0700 | [diff] [blame] | 279 | channel_onFaceCreated(const shared_ptr<Face>& newFace) |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 280 | { |
| 281 | m_faces.push_back(newFace); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 282 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | void |
| 286 | channel_onConnectFailed(const std::string& reason) |
| 287 | { |
| 288 | BOOST_CHECK_MESSAGE(false, reason); |
| 289 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 290 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | void |
| 294 | channel_onConnectFailedOk(const std::string& reason) |
| 295 | { |
| 296 | //it's ok, it was supposed to fail |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 297 | m_limitedIo.afterOp(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | void |
| 301 | checkFaceList(size_t shouldBe) |
| 302 | { |
| 303 | BOOST_CHECK_EQUAL(m_faces.size(), shouldBe); |
| 304 | } |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 305 | |
| 306 | public: |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 307 | LimitedIo m_limitedIo; |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 308 | |
| 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 Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 315 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 316 | shared_ptr<Face> m_face3; |
| 317 | |
| 318 | |
| 319 | std::list< shared_ptr<Face> > m_faces; |
| 320 | }; |
| 321 | |
| 322 | |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 323 | BOOST_FIXTURE_TEST_CASE(EndToEnd4, EndToEndFixture) |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 324 | { |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 325 | UdpFactory factory; |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 326 | |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 327 | factory.createChannel("127.0.0.1", "20071"); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 328 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 329 | factory.createFace(FaceUri("udp4://127.0.0.1:20070"), |
| 330 | bind(&EndToEndFixture::channel2_onFaceCreated, this, _1), |
| 331 | bind(&EndToEndFixture::channel2_onConnectFailed, this, _1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 332 | |
| 333 | |
| 334 | BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
| 335 | "UdpChannel error: cannot connect or cannot accept connection"); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 336 | |
| 337 | BOOST_REQUIRE(static_cast<bool>(m_face2)); |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 338 | BOOST_CHECK_EQUAL(m_face2->getUri().toString(), "udp4://127.0.0.1:20070"); |
| 339 | BOOST_CHECK_EQUAL(m_face2->isLocal(), false); |
| 340 | // m_face1 is not created yet |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 341 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 342 | shared_ptr<UdpChannel> channel1 = factory.createChannel("127.0.0.1", "20070"); |
| 343 | channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1), |
| 344 | bind(&EndToEndFixture::channel1_onConnectFailed, this, _1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 345 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 346 | Interest interest1("ndn:/TpnzGvW9R"); |
| 347 | Data data1 ("ndn:/KfczhUqVix"); |
| 348 | data1.setContent(0, 0); |
| 349 | Interest interest2("ndn:/QWiIMfj5sL"); |
| 350 | Data data2 ("ndn:/XNBV796f"); |
| 351 | data2.setContent(0, 0); |
| 352 | Interest interest3("ndn:/QWiIhjgkj5sL"); |
| 353 | Data data3 ("ndn:/XNBV794f"); |
| 354 | data3.setContent(0, 0); |
| 355 | |
| 356 | |
| 357 | ndn::SignatureSha256WithRsa fakeSignature; |
| 358 | fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, |
| 359 | reinterpret_cast<const uint8_t*>(0), |
| 360 | 0)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 361 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 362 | // set fake signature on data1 and data2 |
| 363 | data1.setSignature(fakeSignature); |
| 364 | data2.setSignature(fakeSignature); |
| 365 | data3.setSignature(fakeSignature); |
| 366 | |
| 367 | m_face2->sendInterest(interest2); |
| 368 | m_face2->sendData (data2 ); |
| 369 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 370 | BOOST_CHECK_MESSAGE(m_limitedIo.run(3,//2 send + 1 listen return |
| 371 | time::seconds(1)) == LimitedIo::EXCEED_OPS, |
| 372 | "UdpChannel error: cannot send or receive Interest/Data packets"); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 373 | |
| 374 | BOOST_REQUIRE(static_cast<bool>(m_face1)); |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 375 | BOOST_CHECK_EQUAL(m_face1->getUri().toString(), "udp4://127.0.0.1:20071"); |
| 376 | BOOST_CHECK_EQUAL(m_face1->isLocal(), false); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 377 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 378 | m_face1->sendInterest(interest1); |
| 379 | m_face1->sendData (data1 ); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 380 | |
| 381 | BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
| 382 | "UdpChannel error: cannot send or receive Interest/Data packets"); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 383 | |
| 384 | |
| 385 | BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1); |
| 386 | BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1); |
| 387 | BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1); |
| 388 | BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 389 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 390 | BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName()); |
| 391 | BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName()); |
| 392 | BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName()); |
| 393 | BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName()); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 394 | |
| 395 | |
| 396 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 397 | //checking if the connection accepting mechanism works properly. |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 398 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 399 | m_face2->sendData (data3 ); |
| 400 | m_face2->sendInterest(interest3); |
| 401 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 402 | BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
| 403 | "UdpChannel error: cannot send or receive Interest/Data packets"); |
| 404 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 405 | BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 2); |
| 406 | BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 2); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 407 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 408 | BOOST_CHECK_EQUAL(m_face1_receivedInterests[1].getName(), interest3.getName()); |
| 409 | BOOST_CHECK_EQUAL(m_face1_receivedDatas [1].getName(), data3.getName()); |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 410 | } |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 411 | |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 412 | BOOST_FIXTURE_TEST_CASE(EndToEnd6, EndToEndFixture) |
| 413 | { |
| 414 | UdpFactory factory; |
| 415 | |
| 416 | factory.createChannel("::1", "20071"); |
| 417 | |
| 418 | factory.createFace(FaceUri("udp://[::1]:20070"), |
| 419 | bind(&EndToEndFixture::channel2_onFaceCreated, this, _1), |
| 420 | bind(&EndToEndFixture::channel2_onConnectFailed, this, _1)); |
| 421 | |
| 422 | |
| 423 | BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
| 424 | "UdpChannel error: cannot connect or cannot accept connection"); |
| 425 | |
| 426 | BOOST_REQUIRE(static_cast<bool>(m_face2)); |
| 427 | BOOST_CHECK_EQUAL(m_face2->getUri().toString(), "udp6://[::1]:20070"); |
| 428 | BOOST_CHECK_EQUAL(m_face2->isLocal(), false); |
| 429 | // m_face1 is not created yet |
| 430 | |
| 431 | shared_ptr<UdpChannel> channel1 = factory.createChannel("::1", "20070"); |
| 432 | channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1), |
| 433 | bind(&EndToEndFixture::channel1_onConnectFailed, this, _1)); |
| 434 | |
| 435 | Interest interest1("ndn:/TpnzGvW9R"); |
| 436 | Data data1 ("ndn:/KfczhUqVix"); |
| 437 | data1.setContent(0, 0); |
| 438 | Interest interest2("ndn:/QWiIMfj5sL"); |
| 439 | Data data2 ("ndn:/XNBV796f"); |
| 440 | data2.setContent(0, 0); |
| 441 | Interest interest3("ndn:/QWiIhjgkj5sL"); |
| 442 | Data data3 ("ndn:/XNBV794f"); |
| 443 | data3.setContent(0, 0); |
| 444 | |
| 445 | |
| 446 | ndn::SignatureSha256WithRsa fakeSignature; |
| 447 | fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, |
| 448 | reinterpret_cast<const uint8_t*>(0), |
| 449 | 0)); |
| 450 | |
| 451 | // set fake signature on data1 and data2 |
| 452 | data1.setSignature(fakeSignature); |
| 453 | data2.setSignature(fakeSignature); |
| 454 | data3.setSignature(fakeSignature); |
| 455 | |
| 456 | m_face2->sendInterest(interest2); |
| 457 | m_face2->sendData (data2 ); |
| 458 | |
| 459 | BOOST_CHECK_MESSAGE(m_limitedIo.run(3,//2 send + 1 listen return |
| 460 | time::seconds(1)) == LimitedIo::EXCEED_OPS, |
| 461 | "UdpChannel error: cannot send or receive Interest/Data packets"); |
| 462 | |
| 463 | BOOST_REQUIRE(static_cast<bool>(m_face1)); |
| 464 | BOOST_CHECK_EQUAL(m_face1->getUri().toString(), "udp6://[::1]:20071"); |
| 465 | BOOST_CHECK_EQUAL(m_face1->isLocal(), false); |
| 466 | |
| 467 | m_face1->sendInterest(interest1); |
| 468 | m_face1->sendData (data1 ); |
| 469 | |
| 470 | BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
| 471 | "UdpChannel error: cannot send or receive Interest/Data packets"); |
| 472 | |
| 473 | |
| 474 | BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1); |
| 475 | BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1); |
| 476 | BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1); |
| 477 | BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1); |
| 478 | |
| 479 | BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName()); |
| 480 | BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName()); |
| 481 | BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName()); |
| 482 | BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName()); |
| 483 | |
| 484 | |
| 485 | |
| 486 | //checking if the connection accepting mechanism works properly. |
| 487 | |
| 488 | m_face2->sendData (data3 ); |
| 489 | m_face2->sendInterest(interest3); |
| 490 | |
| 491 | BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
| 492 | "UdpChannel error: cannot send or receive Interest/Data packets"); |
| 493 | |
| 494 | BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 2); |
| 495 | BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 2); |
| 496 | |
| 497 | BOOST_CHECK_EQUAL(m_face1_receivedInterests[1].getName(), interest3.getName()); |
| 498 | BOOST_CHECK_EQUAL(m_face1_receivedDatas [1].getName(), data3.getName()); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture) |
| 502 | { |
| 503 | Interest interest1("ndn:/TpnzGvW9R"); |
| 504 | Interest interest2("ndn:/QWiIMfj5sL"); |
| 505 | Interest interest3("ndn:/QWiIhjgkj5sL"); |
| 506 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 507 | UdpFactory factory; |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 508 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 509 | shared_ptr<UdpChannel> channel1 = factory.createChannel("127.0.0.1", "20070"); |
| 510 | shared_ptr<UdpChannel> channel2 = factory.createChannel("127.0.0.1", "20071"); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 511 | |
| 512 | |
| 513 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 514 | channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1), |
| 515 | bind(&EndToEndFixture::channel_onConnectFailed, this, _1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 516 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 517 | channel2->connect("127.0.0.1", "20070", |
| 518 | bind(&EndToEndFixture::channel2_onFaceCreated, this, _1), |
| 519 | bind(&EndToEndFixture::channel_onConnectFailed, this, _1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 520 | |
| 521 | |
| 522 | BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS, |
| 523 | "UdpChannel error: cannot connect or cannot accept connection"); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 524 | |
| 525 | BOOST_CHECK_EQUAL(m_faces.size(), 1); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 526 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 527 | shared_ptr<UdpChannel> channel3 = factory.createChannel("127.0.0.1", "20072"); |
| 528 | channel3->connect("127.0.0.1", "20070", |
| 529 | bind(&EndToEndFixture::channel3_onFaceCreated, this, _1), |
| 530 | bind(&EndToEndFixture::channel_onConnectFailed, this, _1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 531 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 532 | shared_ptr<UdpChannel> channel4 = factory.createChannel("127.0.0.1", "20073"); |
| 533 | |
| 534 | BOOST_CHECK_NE(channel3, channel4); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 535 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 536 | scheduler::schedule(time::seconds(0.5), |
| 537 | bind(&UdpChannel::connect, channel4, "127.0.0.1", "20070", |
| 538 | // does not work without static_cast |
| 539 | static_cast<UdpChannel::FaceCreatedCallback>( |
| 540 | bind(&EndToEndFixture::channel_onFaceCreated, this, _1)), |
| 541 | static_cast<UdpChannel::ConnectFailedCallback>( |
| 542 | bind(&EndToEndFixture::channel_onConnectFailed, this, _1)))); |
| 543 | |
| 544 | scheduler::schedule(time::seconds(0.4), bind(&EndToEndFixture::checkFaceList, this, 2)); |
| 545 | |
| 546 | BOOST_CHECK_MESSAGE(m_limitedIo.run(2,// 2 connects |
| 547 | time::seconds(4)) == LimitedIo::EXCEED_OPS, |
| 548 | "UdpChannel error: cannot connect or cannot accept multiple connections"); |
| 549 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 550 | BOOST_CHECK_EQUAL(m_faces.size(), 3); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 551 | |
| 552 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 553 | m_face2->sendInterest(interest1); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 554 | BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
| 555 | "UdpChannel error: cannot send or receive Interest/Data packets"); |
| 556 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 557 | BOOST_CHECK_EQUAL(m_faces.size(), 4); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 558 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 559 | m_face3->sendInterest(interest2); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 560 | BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS, |
| 561 | "UdpChannel error: cannot send or receive Interest/Data packets"); |
| 562 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 563 | //channel1 should have created 2 faces, one when m_face2 sent an interest, one when m_face3 sent an interest |
| 564 | BOOST_CHECK_EQUAL(m_faces.size(), 5); |
| 565 | BOOST_CHECK_THROW(channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated, |
| 566 | this, |
| 567 | _1), |
| 568 | bind(&EndToEndFixture::channel_onConnectFailedOk, |
| 569 | this, |
| 570 | _1)), |
| 571 | UdpChannel::Error); |
| 572 | } |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 573 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 574 | //Test commented because it required to be run in a machine that can resolve ipv6 query |
| 575 | //BOOST_FIXTURE_TEST_CASE(EndToEndIpv6, EndToEndFixture) |
| 576 | //{ |
| 577 | // UdpFactory factory = UdpFactory(); |
| 578 | // Scheduler scheduler(g_io); // to limit the amount of time the test may take |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 579 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 580 | // EventId abortEvent = |
| 581 | // scheduler.scheduleEvent(time::seconds(1), |
| 582 | // bind(&EndToEndFixture::abortTestCase, this, |
| 583 | // "UdpChannel error: cannot connect or cannot accept connection")); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 584 | // |
| 585 | // m_limitedIoRemaining = 1; |
| 586 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 587 | // shared_ptr<UdpChannel> channel1 = factory.createChannel("::1", "20070"); |
| 588 | // shared_ptr<UdpChannel> channel2 = factory.createChannel("::1", "20071"); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 589 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 590 | // channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1), |
| 591 | // bind(&EndToEndFixture::channel1_onConnectFailed, this, _1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 592 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 593 | // channel2->connect("::1", "20070", |
| 594 | // bind(&EndToEndFixture::channel2_onFaceCreated, this, _1), |
| 595 | // bind(&EndToEndFixture::channel2_onConnectFailed, this, _1)); |
| 596 | // g_io.run(); |
| 597 | // g_io.reset(); |
| 598 | // scheduler.cancelEvent(abortEvent); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 599 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 600 | // BOOST_REQUIRE(static_cast<bool>(m_face2)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 601 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 602 | // abortEvent = |
| 603 | // scheduler.scheduleEvent(time::seconds(1), |
| 604 | // bind(&EndToEndFixture::abortTestCase, this, |
| 605 | // "UdpChannel error: cannot send or receive Interest/Data packets")); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 606 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 607 | // Interest interest1("ndn:/TpnzGvW9R"); |
| 608 | // Data data1 ("ndn:/KfczhUqVix"); |
| 609 | // data1.setContent(0, 0); |
| 610 | // Interest interest2("ndn:/QWiIMfj5sL"); |
| 611 | // Data data2 ("ndn:/XNBV796f"); |
| 612 | // data2.setContent(0, 0); |
| 613 | // Interest interest3("ndn:/QWiIhjgkj5sL"); |
| 614 | // Data data3 ("ndn:/XNBV794f"); |
| 615 | // data3.setContent(0, 0); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 616 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 617 | // ndn::SignatureSha256WithRsa fakeSignature; |
| 618 | // fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 619 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 620 | // // set fake signature on data1 and data2 |
| 621 | // data1.setSignature(fakeSignature); |
| 622 | // data2.setSignature(fakeSignature); |
| 623 | // data3.setSignature(fakeSignature); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 624 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 625 | // m_face2->sendInterest(interest2); |
| 626 | // m_face2->sendData (data2 ); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 627 | // |
| 628 | // m_limitedIoRemaining = 3; //2 send + 1 listen return |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 629 | // g_io.run(); |
| 630 | // g_io.reset(); |
| 631 | // scheduler.cancelEvent(abortEvent); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 632 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 633 | // BOOST_REQUIRE(static_cast<bool>(m_face1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 634 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 635 | // m_face1->sendInterest(interest1); |
| 636 | // m_face1->sendData (data1 ); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 637 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 638 | // abortEvent = |
| 639 | // scheduler.scheduleEvent(time::seconds(1), |
| 640 | // bind(&EndToEndFixture::abortTestCase, this, |
| 641 | // "UdpChannel error: cannot send or receive Interest/Data packets")); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 642 | // m_limitedIoRemaining = 2; |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 643 | // g_io.run(); |
| 644 | // g_io.reset(); |
| 645 | // scheduler.cancelEvent(abortEvent); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 646 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 647 | // BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1); |
| 648 | // BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1); |
| 649 | // BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1); |
| 650 | // BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 651 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 652 | // BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName()); |
| 653 | // BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName()); |
| 654 | // BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName()); |
| 655 | // BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName()); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 656 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 657 | // //checking if the connection accepting mechanism works properly. |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 658 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 659 | // m_face2->sendData (data3 ); |
| 660 | // m_face2->sendInterest(interest3); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 661 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 662 | // abortEvent = |
| 663 | // scheduler.scheduleEvent(time::seconds(1), |
| 664 | // bind(&EndToEndFixture::abortTestCase, this, |
| 665 | // "UdpChannel error: cannot send or receive Interest/Data packets")); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 666 | // m_limitedIoRemaining = 2; |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 667 | // g_io.run(); |
| 668 | // g_io.reset(); |
| 669 | // scheduler.cancelEvent(abortEvent); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 670 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 671 | // BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 2); |
| 672 | // BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 2); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 673 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 674 | // BOOST_CHECK_EQUAL(m_face1_receivedInterests[1].getName(), interest3.getName()); |
| 675 | // BOOST_CHECK_EQUAL(m_face1_receivedDatas [1].getName(), data3.getName()); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 676 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 677 | //} |
| 678 | |
| 679 | |
| 680 | //Test commented because it required to be run in a machine that can resolve ipv6 query |
| 681 | //BOOST_FIXTURE_TEST_CASE(MultipleAcceptsIpv6, EndToEndFixture) |
| 682 | //{ |
| 683 | // Interest interest1("ndn:/TpnzGvW9R"); |
| 684 | // Interest interest2("ndn:/QWiIMfj5sL"); |
| 685 | // Interest interest3("ndn:/QWiIhjgkj5sL"); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 686 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 687 | // UdpFactory factory = UdpFactory(); |
| 688 | // Scheduler scheduler(g_io); // to limit the amount of time the test may take |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 689 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 690 | // EventId abortEvent = |
| 691 | // scheduler.scheduleEvent(time::seconds(4), |
| 692 | // bind(&EndToEndFixture::abortTestCase, this, |
| 693 | // "UdpChannel error: cannot connect or cannot accept connection")); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 694 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 695 | // shared_ptr<UdpChannel> channel1 = factory.createChannel("::1", "20070"); |
| 696 | // shared_ptr<UdpChannel> channel2 = factory.createChannel("::1", "20071"); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 697 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 698 | // channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1), |
| 699 | // bind(&EndToEndFixture::channel_onConnectFailed, this, _1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 700 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 701 | // channel2->connect("::1", "20070", |
| 702 | // bind(&EndToEndFixture::channel2_onFaceCreated, this, _1), |
| 703 | // bind(&EndToEndFixture::channel_onConnectFailed, this, _1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 704 | // |
| 705 | // m_limitedIoRemaining = 1; |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 706 | // g_io.run(); |
| 707 | // g_io.reset(); |
| 708 | // scheduler.cancelEvent(abortEvent); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 709 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 710 | // BOOST_CHECK_EQUAL(m_faces.size(), 1); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 711 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 712 | // shared_ptr<UdpChannel> channel3 = factory.createChannel("::1", "20072"); |
| 713 | // channel3->connect("::1", "20070", |
| 714 | // bind(&EndToEndFixture::channel3_onFaceCreated, this, _1), |
| 715 | // bind(&EndToEndFixture::channel_onConnectFailed, this, _1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 716 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 717 | // shared_ptr<UdpChannel> channel4 = factory.createChannel("::1", "20073"); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 718 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 719 | // BOOST_CHECK_NE(channel3, channel4); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 720 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 721 | // scheduler |
| 722 | // .scheduleEvent(time::seconds(0.5), |
| 723 | // bind(&UdpChannel::connect, channel4, |
| 724 | // "::1", "20070", |
| 725 | // static_cast<UdpChannel::FaceCreatedCallback>(bind(&EndToEndFixture:: |
| 726 | // channel_onFaceCreated, this, _1)), |
| 727 | // static_cast<UdpChannel::ConnectFailedCallback>(bind(&EndToEndFixture:: |
| 728 | // channel_onConnectFailed, this, _1)))); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 729 | // |
| 730 | // m_limitedIoRemaining = 2; // 2 connects |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 731 | // abortEvent = |
| 732 | // scheduler.scheduleEvent(time::seconds(4), |
| 733 | // bind(&EndToEndFixture::abortTestCase, this, |
| 734 | // "UdpChannel error: cannot connect or cannot accept multiple connections")); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 735 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 736 | // scheduler.scheduleEvent(time::seconds(0.4), |
| 737 | // bind(&EndToEndFixture::checkFaceList, this, 2)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 738 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 739 | // g_io.run(); |
| 740 | // g_io.reset(); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 741 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 742 | // BOOST_CHECK_EQUAL(m_faces.size(), 3); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 743 | // |
| 744 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 745 | // m_face2->sendInterest(interest1); |
| 746 | // abortEvent = |
| 747 | // scheduler.scheduleEvent(time::seconds(1), |
| 748 | // bind(&EndToEndFixture::abortTestCase, this, |
| 749 | // "UdpChannel error: cannot send or receive Interest/Data packets")); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 750 | // m_limitedIoRemaining = 1; |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 751 | // g_io.run(); |
| 752 | // g_io.reset(); |
| 753 | // scheduler.cancelEvent(abortEvent); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 754 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 755 | // BOOST_CHECK_EQUAL(m_faces.size(), 4); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 756 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 757 | // m_face3->sendInterest(interest2); |
| 758 | // abortEvent = |
| 759 | // scheduler.scheduleEvent(time::seconds(1), |
| 760 | // bind(&EndToEndFixture::abortTestCase, this, |
| 761 | // "UdpChannel error: cannot send or receive Interest/Data packets")); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 762 | // m_limitedIoRemaining = 1; |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 763 | // g_io.run(); |
| 764 | // g_io.reset(); |
| 765 | // scheduler.cancelEvent(abortEvent); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 766 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 767 | // //channel1 should have created 2 faces, one when m_face2 sent an interest, one when m_face3 sent an interest |
| 768 | // BOOST_CHECK_EQUAL(m_faces.size(), 5); |
| 769 | // BOOST_CHECK_THROW(channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated, |
| 770 | // this, |
| 771 | // _1), |
| 772 | // bind(&EndToEndFixture::channel_onConnectFailedOk, |
| 773 | // this, |
| 774 | // _1)), |
| 775 | // UdpChannel::Error); |
| 776 | //} |
| 777 | |
| 778 | |
| 779 | BOOST_FIXTURE_TEST_CASE(FaceClosing, EndToEndFixture) |
| 780 | { |
| 781 | UdpFactory factory = UdpFactory(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 782 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 783 | shared_ptr<UdpChannel> channel1 = factory.createChannel("127.0.0.1", "20070"); |
| 784 | shared_ptr<UdpChannel> channel2 = factory.createChannel("127.0.0.1", "20071"); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 785 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 786 | channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1), |
| 787 | bind(&EndToEndFixture::channel1_onConnectFailed, this, _1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 788 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 789 | channel2->connect("127.0.0.1", "20070", |
| 790 | bind(&EndToEndFixture::channel2_onFaceCreated, this, _1), |
| 791 | bind(&EndToEndFixture::channel2_onConnectFailed, this, _1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 792 | |
| 793 | BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS, |
| 794 | "UdpChannel error: cannot connect or cannot accept connection"); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 795 | |
| 796 | BOOST_CHECK_EQUAL(channel2->size(), 1); |
| 797 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 798 | BOOST_CHECK(static_cast<bool>(m_face2)); |
| 799 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 800 | // Face::close must be invoked during io run to be counted as an op |
| 801 | scheduler::schedule(time::seconds(0.1), bind(&Face::close, m_face2)); |
| 802 | |
| 803 | BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS, |
| 804 | "FaceClosing error: cannot properly close faces"); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 805 | |
| 806 | BOOST_CHECK(!static_cast<bool>(m_face2)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 807 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 808 | BOOST_CHECK_EQUAL(channel2->size(), 0); |
| 809 | } |
| 810 | |
| 811 | //BOOST_FIXTURE_TEST_CASE(MulticastFace, EndToEndFixture) |
| 812 | //{ |
| 813 | // //to instantiate multicast face on a specific ip address, change interfaceIp |
| 814 | // std::string interfaceIp = "0.0.0.0"; |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 815 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 816 | // UdpFactory factory = UdpFactory(); |
| 817 | // Scheduler scheduler(g_io); // to limit the amount of time the test may take |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 818 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 819 | // shared_ptr<MulticastUdpFace> multicastFace1 = |
| 820 | // factory.createMulticastFace(interfaceIp, "224.0.0.1", "20072"); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 821 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 822 | // BOOST_REQUIRE(static_cast<bool>(multicastFace1)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 823 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 824 | // channel1_onFaceCreated(multicastFace1); |
| 825 | // |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 826 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 827 | // EventId abortEvent = |
| 828 | // scheduler.scheduleEvent(time::seconds(10), |
| 829 | // bind(&EndToEndFixture::abortTestCase, this, |
| 830 | // "MulticastFace error: cannot send or receive Interest/Data packets")); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 831 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 832 | // Interest interest1("ndn:/TpnzGvW9R"); |
| 833 | // Data data1 ("ndn:/KfczhUqVix"); |
| 834 | // data1.setContent(0, 0); |
| 835 | // Interest interest2("ndn:/QWiIMfj5sL"); |
| 836 | // Data data2 ("ndn:/XNBV796f"); |
| 837 | // data2.setContent(0, 0); |
| 838 | // Interest interest3("ndn:/QWiIhjgkj5sL"); |
| 839 | // Data data3 ("ndn:/XNBV794f"); |
| 840 | // data3.setContent(0, 0); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 841 | // |
| 842 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 843 | // ndn::SignatureSha256WithRsa fakeSignature; |
| 844 | // fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0)); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 845 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 846 | // // set fake signature on data1 and data2 |
| 847 | // data1.setSignature(fakeSignature); |
| 848 | // data2.setSignature(fakeSignature); |
| 849 | // data3.setSignature(fakeSignature); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 850 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 851 | // multicastFace1->sendInterest(interest1); |
| 852 | // multicastFace1->sendData (data1 ); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 853 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 854 | // g_io.reset(); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 855 | // m_limitedIoRemaining = 2; |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 856 | // g_io.run(); |
| 857 | // g_io.reset(); |
| 858 | // scheduler.cancelEvent(abortEvent); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 859 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 860 | // BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1); |
| 861 | // BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1); |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 862 | // |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 863 | // BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest1.getName()); |
| 864 | // BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data1.getName()); |
| 865 | //} |
| 866 | |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 867 | |
| 868 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 869 | BOOST_AUTO_TEST_SUITE_END() |
Junxiao Shi | 7e2413b | 2014-03-02 11:15:09 -0700 | [diff] [blame] | 870 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 871 | } // namespace tests |
| 872 | } // namespace nfd |