blob: e2a48b5936437564efdc0662f40082e31a220a43 [file] [log] [blame]
Alexander Afanasyev5d57f972015-02-11 21:04:29 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventocf7db2f2019-03-24 23:17:28 -04002/*
Davide Pesaventoae430302023-05-11 01:42:46 -04003 * Copyright (c) 2014-2023, Regents of the University of California,
Alexander Afanasyev5d57f972015-02-11 21:04:29 -08004 * 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
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080026#include "face/null-face.hpp"
Davide Pesavento16916ae2019-03-29 23:53:26 -040027#include "face/null-transport.hpp"
Junxiao Shicde37ad2015-12-24 01:02:05 -070028
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040029#include "tests/daemon/global-io-fixture.hpp"
Davide Pesavento279af1c2022-08-29 20:18:32 -040030#include "tests/daemon/face/transport-test-common.hpp"
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080031
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040032namespace nfd::tests {
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080033
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040034using namespace nfd::face;
Junxiao Shia044be72015-10-26 11:00:56 -070035
36BOOST_AUTO_TEST_SUITE(Face)
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040037BOOST_FIXTURE_TEST_SUITE(TestNullFace, GlobalIoFixture)
Junxiao Shia044be72015-10-26 11:00:56 -070038
Junxiao Shia044be72015-10-26 11:00:56 -070039BOOST_AUTO_TEST_CASE(StaticProperties)
40{
Davide Pesavento16916ae2019-03-29 23:53:26 -040041 FaceUri uri("testnull://hhppt12sy");
42 auto face = makeNullFace(uri);
43 auto transport = face->getTransport();
Junxiao Shia044be72015-10-26 11:00:56 -070044
Davide Pesavento16916ae2019-03-29 23:53:26 -040045 checkStaticPropertiesInitialized(*transport);
46
47 BOOST_CHECK_EQUAL(transport->getLocalUri(), uri);
48 BOOST_CHECK_EQUAL(transport->getRemoteUri(), uri);
49 BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_LOCAL);
50 BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERMANENT);
51 BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT);
52 BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED);
53}
54
55BOOST_AUTO_TEST_CASE(ExpirationTime)
56{
57 auto transport = make_unique<NullTransport>();
58
Davide Pesaventoae430302023-05-11 01:42:46 -040059 BOOST_CHECK_EQUAL(transport->getExpirationTime(), time::steady_clock::time_point::max());
Davide Pesavento16916ae2019-03-29 23:53:26 -040060}
61
62BOOST_AUTO_TEST_CASE(SendQueue)
63{
64 auto transport = make_unique<NullTransport>();
65
66 BOOST_CHECK_EQUAL(transport->getSendQueueCapacity(), QUEUE_UNSUPPORTED);
67 BOOST_CHECK_EQUAL(transport->getSendQueueLength(), QUEUE_UNSUPPORTED);
Junxiao Shia044be72015-10-26 11:00:56 -070068}
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080069
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080070BOOST_AUTO_TEST_CASE(Send)
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080071{
Davide Pesavento16916ae2019-03-29 23:53:26 -040072 auto face = makeNullFace();
73 BOOST_CHECK_EQUAL(face->getState(), FaceState::UP);
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080074
Teng Liangf3bc3ae2020-06-08 10:19:25 -070075 face->sendInterest(*makeInterest("/A"));
Davide Pesavento16916ae2019-03-29 23:53:26 -040076 BOOST_CHECK_EQUAL(face->getState(), FaceState::UP);
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080077
Teng Liangf3bc3ae2020-06-08 10:19:25 -070078 face->sendData(*makeData("/B"));
Davide Pesavento16916ae2019-03-29 23:53:26 -040079 BOOST_CHECK_EQUAL(face->getState(), FaceState::UP);
80}
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080081
Davide Pesavento16916ae2019-03-29 23:53:26 -040082BOOST_AUTO_TEST_CASE(PersistencyChange)
83{
84 auto transport = make_unique<NullTransport>();
85
86 BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND), false);
87 BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_PERSISTENT), false);
88 BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_PERMANENT), true);
89}
90
91BOOST_AUTO_TEST_CASE(Close)
92{
93 auto transport = make_unique<NullTransport>();
94 BOOST_CHECK_EQUAL(transport->getState(), TransportState::UP);
95
96 transport->close();
97 BOOST_CHECK_EQUAL(transport->getState(), TransportState::CLOSED);
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080098}
99
Junxiao Shia044be72015-10-26 11:00:56 -0700100BOOST_AUTO_TEST_SUITE_END() // TestNullFace
101BOOST_AUTO_TEST_SUITE_END() // Face
Alexander Afanasyev5d57f972015-02-11 21:04:29 -0800102
Davide Pesaventoe422f9e2022-06-03 01:30:23 -0400103} // namespace nfd::tests