Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | 84d62cb | 2017-07-12 16:15:18 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | 3206565 | 2017-01-15 01:52:21 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, Regents of the University of California, |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
| 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | */ |
| 25 | |
Davide Pesavento | eee53aa | 2016-04-11 17:20:21 +0200 | [diff] [blame] | 26 | #include "transport-test-common.hpp" |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 27 | |
| 28 | #include "websocket-transport-fixture.hpp" |
| 29 | |
| 30 | #include <boost/mpl/vector.hpp> |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 31 | |
| 32 | namespace nfd { |
| 33 | namespace face { |
| 34 | namespace tests { |
| 35 | |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 36 | BOOST_AUTO_TEST_SUITE(Face) |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 37 | BOOST_FIXTURE_TEST_SUITE(TestWebSocketTransport, IpTransportFixture<WebSocketTransportFixture>) |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 38 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 39 | using WebSocketTransportFixtures = boost::mpl::vector< |
| 40 | GENERATE_IP_TRANSPORT_FIXTURE_INSTANTIATIONS(WebSocketTransportFixture) |
| 41 | >; |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 42 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 43 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(StaticProperties, T, WebSocketTransportFixtures, T) |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 44 | { |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 45 | TRANSPORT_TEST_INIT(); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 46 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 47 | checkStaticPropertiesInitialized(*this->transport); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 48 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 49 | BOOST_CHECK_EQUAL(this->transport->getLocalUri(), FaceUri(ip::tcp::endpoint(this->address, 20070), "ws")); |
| 50 | BOOST_CHECK_EQUAL(this->transport->getRemoteUri(), FaceUri(this->remoteEp, "wsclient")); |
| 51 | BOOST_CHECK_EQUAL(this->transport->getScope(), |
| 52 | this->addressScope == AddressScope::Loopback ? ndn::nfd::FACE_SCOPE_LOCAL |
| 53 | : ndn::nfd::FACE_SCOPE_NON_LOCAL); |
| 54 | BOOST_CHECK_EQUAL(this->transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_ON_DEMAND); |
| 55 | BOOST_CHECK_EQUAL(this->transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 56 | BOOST_CHECK_EQUAL(this->transport->getMtu(), MTU_UNLIMITED); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 59 | using StaticPropertiesV4MappedFixtures = boost::mpl::vector< |
| 60 | IpTransportFixture<WebSocketTransportFixture, AddressFamily::V4, AddressScope::Loopback>, |
| 61 | IpTransportFixture<WebSocketTransportFixture, AddressFamily::V4, AddressScope::Global> |
| 62 | >; |
| 63 | |
| 64 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(StaticPropertiesV4Mapped, T, StaticPropertiesV4MappedFixtures, T) |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 65 | { |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 66 | TRANSPORT_TEST_CHECK_PRECONDITIONS(); |
| 67 | auto mappedAddr = ip::address_v6::v4_mapped(this->address.to_v4()); |
| 68 | BOOST_REQUIRE(mappedAddr.is_v4_mapped()); |
| 69 | WebSocketTransportFixture::initialize(mappedAddr); |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 70 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 71 | checkStaticPropertiesInitialized(*this->transport); |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 72 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 73 | BOOST_CHECK_EQUAL(this->transport->getLocalUri(), FaceUri(ip::tcp::endpoint(mappedAddr, 20070), "ws")); |
| 74 | BOOST_CHECK_EQUAL(this->transport->getRemoteUri(), FaceUri(this->remoteEp, "wsclient")); |
| 75 | BOOST_CHECK_EQUAL(this->transport->getScope(), |
| 76 | this->addressScope == AddressScope::Loopback ? ndn::nfd::FACE_SCOPE_LOCAL |
| 77 | : ndn::nfd::FACE_SCOPE_NON_LOCAL); |
| 78 | BOOST_CHECK_EQUAL(this->transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_ON_DEMAND); |
| 79 | BOOST_CHECK_EQUAL(this->transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 80 | BOOST_CHECK_EQUAL(this->transport->getMtu(), MTU_UNLIMITED); |
Eric Newberry | 4a4ccfe | 2016-07-21 22:51:04 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Davide Pesavento | 3206565 | 2017-01-15 01:52:21 -0500 | [diff] [blame] | 83 | BOOST_AUTO_TEST_CASE(PersistencyChange) |
| 84 | { |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 85 | TRANSPORT_TEST_INIT(); |
Davide Pesavento | 3206565 | 2017-01-15 01:52:21 -0500 | [diff] [blame] | 86 | |
| 87 | BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND), true); |
| 88 | BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_PERSISTENT), false); |
| 89 | BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_PERMANENT), false); |
| 90 | } |
| 91 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 92 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(PingPong, T, WebSocketTransportFixtures, T) |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 93 | { |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 94 | TRANSPORT_TEST_INIT(time::milliseconds(500), time::milliseconds(300)); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 95 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 96 | BOOST_CHECK_EQUAL(this->limitedIo.run(2, // clientHandlePing, serverHandlePong |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 97 | time::milliseconds(1500)), LimitedIo::EXCEED_OPS); |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 98 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 99 | BOOST_CHECK_EQUAL(this->transport->getState(), TransportState::UP); |
| 100 | BOOST_CHECK_EQUAL(this->transport->getCounters().nOutPings, 1); |
| 101 | BOOST_CHECK_EQUAL(this->transport->getCounters().nInPongs, 1); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 102 | |
| 103 | this->clientShouldPong = false; |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 104 | BOOST_CHECK_EQUAL(this->limitedIo.run(2, // clientHandlePing, serverHandlePongTimeout |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 105 | time::seconds(2)), LimitedIo::EXCEED_OPS); |
| 106 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 107 | BOOST_CHECK_MESSAGE(this->transport->getState() == TransportState::FAILED || |
| 108 | this->transport->getState() == TransportState::CLOSED, |
| 109 | "expected FAILED or CLOSED state, actual state=" << this->transport->getState()); |
| 110 | BOOST_CHECK_EQUAL(this->transport->getCounters().nOutPings, 2); |
| 111 | BOOST_CHECK_EQUAL(this->transport->getCounters().nInPongs, 1); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 114 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(Send, T, WebSocketTransportFixtures, T) |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 115 | { |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 116 | TRANSPORT_TEST_INIT(); |
| 117 | |
| 118 | auto block1 = ndn::encoding::makeStringBlock(300, "hello"); |
| 119 | this->transport->send(Transport::Packet{Block{block1}}); // make a copy of the block |
| 120 | BOOST_CHECK_EQUAL(this->limitedIo.run(1, // clientHandleMessage |
| 121 | time::seconds(1)), LimitedIo::EXCEED_OPS); |
| 122 | BOOST_CHECK_EQUAL(this->transport->getCounters().nOutPackets, 1); |
| 123 | BOOST_CHECK_EQUAL(this->transport->getCounters().nOutBytes, block1.size()); |
| 124 | |
| 125 | auto block2 = ndn::encoding::makeStringBlock(301, "world"); |
| 126 | this->transport->send(Transport::Packet{Block{block2}}); // make a copy of the block |
| 127 | BOOST_CHECK_EQUAL(this->limitedIo.run(1, // clientHandleMessage |
| 128 | time::seconds(1)), LimitedIo::EXCEED_OPS); |
| 129 | BOOST_CHECK_EQUAL(this->transport->getCounters().nOutPackets, 2); |
| 130 | BOOST_CHECK_EQUAL(this->transport->getCounters().nOutBytes, block1.size() + block2.size()); |
| 131 | |
| 132 | BOOST_REQUIRE_EQUAL(this->clientReceivedMessages.size(), 2); |
| 133 | BOOST_CHECK_EQUAL_COLLECTIONS( |
| 134 | reinterpret_cast<const uint8_t*>(this->clientReceivedMessages[0].data()), |
| 135 | reinterpret_cast<const uint8_t*>(this->clientReceivedMessages[0].data()) + this->clientReceivedMessages[0].size(), |
| 136 | block1.begin(), block1.end()); |
| 137 | BOOST_CHECK_EQUAL_COLLECTIONS( |
| 138 | reinterpret_cast<const uint8_t*>(this->clientReceivedMessages[1].data()), |
| 139 | reinterpret_cast<const uint8_t*>(this->clientReceivedMessages[1].data()) + this->clientReceivedMessages[1].size(), |
| 140 | block2.begin(), block2.end()); |
| 141 | BOOST_CHECK_EQUAL(this->transport->getState(), TransportState::UP); |
| 142 | } |
| 143 | |
| 144 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(ReceiveNormal, T, WebSocketTransportFixtures, T) |
| 145 | { |
| 146 | TRANSPORT_TEST_INIT(); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 147 | |
| 148 | Block pkt1 = ndn::encoding::makeStringBlock(300, "hello"); |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 149 | this->client.send(this->clientHdl, pkt1.wire(), pkt1.size(), websocketpp::frame::opcode::binary); |
| 150 | BOOST_CHECK_EQUAL(this->limitedIo.run(1, // serverHandleMessage |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 151 | time::seconds(1)), LimitedIo::EXCEED_OPS); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 152 | |
| 153 | Block pkt2 = ndn::encoding::makeStringBlock(301, "world!"); |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 154 | this->client.send(this->clientHdl, pkt2.wire(), pkt2.size(), websocketpp::frame::opcode::binary); |
| 155 | BOOST_CHECK_EQUAL(this->limitedIo.run(1, // serverHandleMessage |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 156 | time::seconds(1)), LimitedIo::EXCEED_OPS); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 157 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 158 | BOOST_CHECK_EQUAL(this->transport->getCounters().nInPackets, 2); |
| 159 | BOOST_CHECK_EQUAL(this->transport->getCounters().nInBytes, pkt1.size() + pkt2.size()); |
| 160 | BOOST_CHECK_EQUAL(this->transport->getState(), TransportState::UP); |
| 161 | |
| 162 | BOOST_REQUIRE_EQUAL(this->serverReceivedPackets->size(), 2); |
| 163 | BOOST_CHECK(this->serverReceivedPackets->at(0).packet == pkt1); |
| 164 | BOOST_CHECK(this->serverReceivedPackets->at(1).packet == pkt2); |
| 165 | BOOST_CHECK_EQUAL(this->serverReceivedPackets->at(0).remoteEndpoint, |
| 166 | this->serverReceivedPackets->at(1).remoteEndpoint); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 169 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(ReceiveMalformed, T, WebSocketTransportFixtures, T) |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 170 | { |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 171 | TRANSPORT_TEST_INIT(); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 172 | |
| 173 | Block pkt1 = ndn::encoding::makeStringBlock(300, "hello"); |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 174 | this->client.send(this->clientHdl, pkt1.wire(), pkt1.size() - 1, // truncated |
| 175 | websocketpp::frame::opcode::binary); |
| 176 | BOOST_CHECK_EQUAL(this->limitedIo.run(1, // serverHandleMessage |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 177 | time::seconds(1)), LimitedIo::EXCEED_OPS); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 178 | |
| 179 | // bad packet is dropped |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 180 | BOOST_CHECK_EQUAL(this->transport->getState(), TransportState::UP); |
| 181 | BOOST_CHECK_EQUAL(this->serverReceivedPackets->size(), 0); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 182 | |
| 183 | Block pkt2 = ndn::encoding::makeStringBlock(301, "world!"); |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 184 | this->client.send(this->clientHdl, pkt2.wire(), pkt2.size(), websocketpp::frame::opcode::binary); |
| 185 | BOOST_CHECK_EQUAL(this->limitedIo.run(1, // serverHandleMessage |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 186 | time::seconds(1)), LimitedIo::EXCEED_OPS); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 187 | |
| 188 | // next valid packet is still received normally |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 189 | BOOST_CHECK_EQUAL(this->transport->getState(), TransportState::UP); |
| 190 | BOOST_REQUIRE_EQUAL(this->serverReceivedPackets->size(), 1); |
| 191 | BOOST_CHECK(this->serverReceivedPackets->at(0).packet == pkt2); |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 194 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(Close, T, WebSocketTransportFixtures, T) |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 195 | { |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 196 | TRANSPORT_TEST_INIT(); |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 197 | |
| 198 | int nStateChanges = 0; |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 199 | this->transport->afterStateChange.connect( |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 200 | [&nStateChanges] (TransportState oldState, TransportState newState) { |
| 201 | switch (nStateChanges) { |
| 202 | case 0: |
| 203 | BOOST_CHECK_EQUAL(oldState, TransportState::UP); |
| 204 | BOOST_CHECK_EQUAL(newState, TransportState::CLOSING); |
| 205 | break; |
| 206 | case 1: |
| 207 | BOOST_CHECK_EQUAL(oldState, TransportState::CLOSING); |
| 208 | BOOST_CHECK_EQUAL(newState, TransportState::CLOSED); |
| 209 | break; |
| 210 | default: |
| 211 | BOOST_CHECK(false); |
| 212 | } |
| 213 | nStateChanges++; |
| 214 | }); |
| 215 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 216 | this->transport->close(); |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 217 | BOOST_CHECK_EQUAL(nStateChanges, 2); |
| 218 | } |
| 219 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 220 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(RemoteClose, T, WebSocketTransportFixtures, T) |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 221 | { |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 222 | TRANSPORT_TEST_INIT(); |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 223 | |
| 224 | int nStateChanges = 0; |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 225 | this->transport->afterStateChange.connect( |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 226 | [&nStateChanges] (TransportState oldState, TransportState newState) { |
| 227 | switch (nStateChanges) { |
| 228 | case 0: |
| 229 | BOOST_CHECK_EQUAL(oldState, TransportState::UP); |
| 230 | BOOST_CHECK_EQUAL(newState, TransportState::CLOSING); |
| 231 | break; |
| 232 | case 1: |
| 233 | BOOST_CHECK_EQUAL(oldState, TransportState::CLOSING); |
| 234 | BOOST_CHECK_EQUAL(newState, TransportState::CLOSED); |
| 235 | break; |
| 236 | default: |
| 237 | BOOST_CHECK(false); |
| 238 | } |
| 239 | nStateChanges++; |
| 240 | }); |
| 241 | |
Davide Pesavento | 22fba35 | 2017-10-17 15:53:51 -0400 | [diff] [blame] | 242 | this->client.close(this->clientHdl, websocketpp::close::status::going_away, ""); |
| 243 | BOOST_CHECK_EQUAL(this->limitedIo.run(1, // serverHandleClose |
Weiwei Liu | 9360623 | 2016-02-26 16:32:11 -0700 | [diff] [blame] | 244 | time::seconds(1)), LimitedIo::EXCEED_OPS); |
| 245 | |
| 246 | BOOST_CHECK_EQUAL(nStateChanges, 2); |
| 247 | } |
| 248 | |
Yukai Tu | 2d6d563 | 2015-10-26 11:06:02 -0700 | [diff] [blame] | 249 | BOOST_AUTO_TEST_SUITE_END() // TestWebSocketTransport |
| 250 | BOOST_AUTO_TEST_SUITE_END() // Face |
| 251 | |
| 252 | } // namespace tests |
| 253 | } // namespace face |
| 254 | } // namespace nfd |