interest: prevent InterestLifetime overflow

Refs: #4997
Change-Id: Ic116e4d6d681ab89c655774a90d9d652db4a8916
diff --git a/tests/unit/interest.t.cpp b/tests/unit/interest.t.cpp
index 4c540b7..5e64fb1 100644
--- a/tests/unit/interest.t.cpp
+++ b/tests/unit/interest.t.cpp
@@ -611,6 +611,23 @@
                         [] (const auto& e) { return e.what() == "Nonce element is malformed"sv; });
 }
 
+BOOST_AUTO_TEST_CASE(LargeLifetime,
+  * ut::description("test for bug #4997"))
+{
+  i.wireDecode("050F 0703(080149) 0C087FFFFFFFFFFFFFFF"_block);
+  BOOST_CHECK_EQUAL(i.getInterestLifetime(), 0x7FFFFFFFFFFFFFFF_ms);
+
+  i.wireDecode("050F 0703(080149) 0C088000000000000000"_block);
+  BOOST_CHECK_EQUAL(i.getInterestLifetime(), time::milliseconds::max());
+
+  i.wireDecode("050F 0703(080149) 0C08FFFFFFFFFFFFFFFF"_block);
+  BOOST_CHECK_EQUAL(i.getInterestLifetime(), time::milliseconds::max());
+
+  // force re-encoding
+  i.setNonce(0x957c6554);
+  BOOST_CHECK_EQUAL(i.wireEncode(), "0515 0703(080149) 0A04957C6554 0C08FFFFFFFFFFFFFFFF"_block);
+}
+
 BOOST_AUTO_TEST_CASE(BadHopLimit)
 {
   BOOST_CHECK_EXCEPTION(i.wireDecode("0507 0703080149 2200"_block), tlv::Error,