face: allow the creation of permanent TCP faces
Change-Id: I516c176b000a78012f2ef7bd7f1f3e74c1758a94
Refs: #3167
diff --git a/tests/daemon/face/tcp-channel-fixture.hpp b/tests/daemon/face/tcp-channel-fixture.hpp
index 4f63035..798fedd 100644
--- a/tests/daemon/face/tcp-channel-fixture.hpp
+++ b/tests/daemon/face/tcp-channel-fixture.hpp
@@ -50,7 +50,7 @@
connect(TcpChannel& channel) final
{
g_io.post([&] {
- channel.connect(listenerEp, false,
+ channel.connect(listenerEp, ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false,
[this] (const shared_ptr<Face>& newFace) {
BOOST_REQUIRE(newFace != nullptr);
connectFaceClosedSignal(*newFace, [this] { limitedIo.afterOp(); });
diff --git a/tests/daemon/face/tcp-channel.t.cpp b/tests/daemon/face/tcp-channel.t.cpp
index 8068364..986d471 100644
--- a/tests/daemon/face/tcp-channel.t.cpp
+++ b/tests/daemon/face/tcp-channel.t.cpp
@@ -46,7 +46,8 @@
// do not listen
auto channel = this->makeChannel(A());
- channel->connect(tcp::Endpoint(address, 7040), false,
+ channel->connect(tcp::Endpoint(address, 7040),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false,
[this] (const shared_ptr<nfd::Face>&) {
BOOST_FAIL("Connect succeeded when it should have failed");
this->limitedIo.afterOp();
diff --git a/tests/daemon/face/tcp-factory.t.cpp b/tests/daemon/face/tcp-factory.t.cpp
index 31e8918..d3f5fc9 100644
--- a/tests/daemon/face/tcp-factory.t.cpp
+++ b/tests/daemon/face/tcp-factory.t.cpp
@@ -185,35 +185,40 @@
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
false,
{CreateFaceExpectedResult::SUCCESS, 0, ""});
+
+ createFace(factory,
+ FaceUri("tcp4://127.0.0.1:6363"),
+ {},
+ ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ false,
+ {CreateFaceExpectedResult::SUCCESS, 0, ""});
+
+ createFace(factory,
+ FaceUri("tcp4://127.0.0.1:20072"),
+ {},
+ ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ false,
+ {CreateFaceExpectedResult::SUCCESS, 0, ""});
}
BOOST_AUTO_TEST_CASE(UnsupportedFaceCreate)
{
TcpFactory factory;
- factory.createChannel("127.0.0.1", "20070");
factory.createChannel("127.0.0.1", "20071");
factory.createChannel("127.0.0.1", "20072");
createFace(factory,
- FaceUri("tcp4://127.0.0.1:20070"),
- {},
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- false,
- {CreateFaceExpectedResult::FAILURE, 406,
- "Outgoing TCP faces only support persistent persistency"});
-
- createFace(factory,
FaceUri("tcp4://127.0.0.1:20071"),
{},
ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
false,
{CreateFaceExpectedResult::FAILURE, 406,
- "Outgoing TCP faces only support persistent persistency"});
+ "Outgoing TCP faces do not support on-demand persistency"});
createFace(factory,
FaceUri("tcp4://127.0.0.1:20072"),
- FaceUri("udp4://127.0.0.1:20073"),
+ FaceUri("tcp4://127.0.0.1:20073"),
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
false,
{CreateFaceExpectedResult::FAILURE, 406,
@@ -227,8 +232,7 @@
onFaceCreated(const shared_ptr<Face>& newFace)
{
BOOST_CHECK_MESSAGE(false, "Timeout expected");
- BOOST_CHECK(!static_cast<bool>(face1));
- face1 = newFace;
+ face = newFace;
limitedIo.afterOp();
}
@@ -243,14 +247,13 @@
public:
LimitedIo limitedIo;
-
- shared_ptr<Face> face1;
+ shared_ptr<Face> face;
};
BOOST_FIXTURE_TEST_CASE(FaceCreateTimeout, FaceCreateTimeoutFixture)
{
TcpFactory factory;
- shared_ptr<TcpChannel> channel = factory.createChannel("0.0.0.0", "20070");
+ factory.createChannel("0.0.0.0", "20070");
factory.createFace(FaceUri("tcp4://192.0.2.1:20070"),
{},
@@ -259,10 +262,8 @@
bind(&FaceCreateTimeoutFixture::onFaceCreated, this, _1),
bind(&FaceCreateTimeoutFixture::onConnectFailed, this, _2));
- BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(10)) == LimitedIo::EXCEED_OPS,
- "TcpChannel error: cannot connect or cannot accept connection");
-
- BOOST_CHECK_EQUAL(static_cast<bool>(face1), false);
+ BOOST_REQUIRE_EQUAL(limitedIo.run(1, time::seconds(10)), LimitedIo::EXCEED_OPS);
+ BOOST_CHECK(face == nullptr);
}
class FakeNetworkInterfaceFixture : public BaseFixture
diff --git a/tests/daemon/face/udp-factory.t.cpp b/tests/daemon/face/udp-factory.t.cpp
index e658248..3270ad6 100644
--- a/tests/daemon/face/udp-factory.t.cpp
+++ b/tests/daemon/face/udp-factory.t.cpp
@@ -611,14 +611,14 @@
factory.createChannel("127.0.0.1", "20071");
createFace(factory,
- FaceUri("udp4://127.0.0.1:20070"),
+ FaceUri("udp4://127.0.0.1:6363"),
{},
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
false,
{CreateFaceExpectedResult::SUCCESS, 0, ""});
createFace(factory,
- FaceUri("udp4://127.0.0.1:20070"),
+ FaceUri("udp4://127.0.0.1:6363"),
{},
ndn::nfd::FACE_PERSISTENCY_PERMANENT,
false,
@@ -636,11 +636,11 @@
{
UdpFactory factory;
- factory.createChannel("127.0.0.1", "20070");
factory.createChannel("127.0.0.1", "20071");
+ factory.createChannel("127.0.0.1", "20072");
createFace(factory,
- FaceUri("udp4://127.0.0.1:20070"),
+ FaceUri("udp4://127.0.0.1:20071"),
{},
ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
false,
@@ -648,7 +648,7 @@
"Outgoing unicast UDP faces do not support on-demand persistency"});
createFace(factory,
- FaceUri("udp4://127.0.0.1:20071"),
+ FaceUri("udp4://127.0.0.1:20072"),
FaceUri("udp4://127.0.0.1:20073"),
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
false,