Add ability to configure maximum packet size for sync data
Change-Id: Iab7913d094a1b5d64ef5cc8e00b2624993b59ab5
Refs: #4140
diff --git a/tests/unit-tests/test-logic.cpp b/tests/unit-tests/test-logic.cpp
index dc7e2ef..fb0422a 100644
--- a/tests/unit-tests/test-logic.cpp
+++ b/tests/unit-tests/test-logic.cpp
@@ -348,6 +348,41 @@
BOOST_REQUIRE(syncReply.wireEncode().size() < ndn::MAX_NDN_PACKET_SIZE);
}
+class MaxPacketCustomizationFixture
+{
+public:
+ MaxPacketCustomizationFixture()
+ {
+ if (getenv("CHRONOSYNC_MAX_PACKET_SIZE") != nullptr) {
+ oldSize = std::string(getenv("CHRONOSYNC_MAX_PACKET_SIZE"));
+ unsetenv("CHRONOSYNC_MAX_PACKET_SIZE");
+ }
+ }
+
+ ~MaxPacketCustomizationFixture()
+ {
+ if (oldSize) {
+ setenv("CHRONOSYNC_MAX_PACKET_SIZE", oldSize->c_str(), 1);
+ }
+ }
+private:
+ ndn::optional<std::string> oldSize;
+};
+
+BOOST_FIXTURE_TEST_CASE(MaxPacketCustomization, MaxPacketCustomizationFixture)
+{
+ BOOST_CHECK_EQUAL(getMaxPacketLimit(), ndn::MAX_NDN_PACKET_SIZE);
+
+ setenv("CHRONOSYNC_MAX_PACKET_SIZE", "1500", 1);
+ BOOST_CHECK_EQUAL(getMaxPacketLimit(), 1500);
+
+ setenv("CHRONOSYNC_MAX_PACKET_SIZE", ndn::to_string(ndn::MAX_NDN_PACKET_SIZE * 100).c_str(), 1);
+ BOOST_CHECK_EQUAL(getMaxPacketLimit(), ndn::MAX_NDN_PACKET_SIZE);
+
+ setenv("CHRONOSYNC_MAX_PACKET_SIZE", "1", 1);
+ BOOST_CHECK_EQUAL(getMaxPacketLimit(), 500);
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace test