face: move packet encoding to Impl class
Practical limit of packet size is now enforced on encoded
NDNLPv2 packets instead of network-layer packets.
If a packet exceeds size limit, the face throws a
Face::OversizedPacketError exception. Since packet encoding may
be asynchronous, this exception could be thrown by
Face::processEvents instead of Face::expressInterest and
Face::put.
refs #4228
Change-Id: Ib68cf80b3b8967fdd0ba040bd8ee595a0eff740e
diff --git a/tests/integrated/face.cpp b/tests/integrated/face.cpp
index 038b499..cf7c872 100644
--- a/tests/integrated/face.cpp
+++ b/tests/integrated/face.cpp
@@ -150,9 +150,7 @@
bind(&FacesFixture::onData, this),
bind(&FacesFixture::onNack, this),
bind(&FacesFixture::onTimeout, this));
-
- BOOST_REQUIRE_NO_THROW(face.processEvents());
-
+ face.processEvents();
BOOST_CHECK_EQUAL(nData, 1);
BOOST_CHECK_EQUAL(nNacks, 0);
BOOST_CHECK_EQUAL(nTimeouts, 0);
@@ -162,25 +160,29 @@
bind(&FacesFixture::onData, this),
bind(&FacesFixture::onNack, this),
bind(&FacesFixture::onTimeout, this));
+ face.processEvents();
+ BOOST_CHECK_EQUAL(nData, 1);
+ BOOST_CHECK_EQUAL(nNacks, 0);
+ BOOST_CHECK_EQUAL(nTimeouts, 1);
Name veryLongName;
for (size_t i = 0; i <= MAX_NDN_PACKET_SIZE / 10; i++) {
veryLongName.append("0123456789");
}
- BOOST_CHECK_THROW(face.expressInterest(Interest(veryLongName), nullptr, nullptr, nullptr),
- Face::Error);
+ BOOST_CHECK_THROW(do {
+ face.expressInterest(Interest(veryLongName), nullptr, nullptr, nullptr);
+ face.processEvents();
+ } while (false), Face::OversizedPacketError);
shared_ptr<Data> data = make_shared<Data>(veryLongName);
data->setContent(reinterpret_cast<const uint8_t*>("01234567890"), 10);
m_keyChain.sign(*data);
- BOOST_CHECK_THROW(face.put(*data), Face::Error);
+ BOOST_CHECK_THROW(do {
+ face.put(*data);
+ face.processEvents();
+ } while (false), Face::OversizedPacketError);
- BOOST_REQUIRE_NO_THROW(face.processEvents());
-
- BOOST_CHECK_EQUAL(nData, 1);
- BOOST_CHECK_EQUAL(nNacks, 0);
- BOOST_CHECK_EQUAL(nTimeouts, 1);
}
BOOST_AUTO_TEST_CASE(Tcp)