meta-info: prevent FreshnessPeriod overflow

refs #4997

Change-Id: I22ae27257fd79b539a8ac137f8b1871e1b988cf8
diff --git a/tests/unit/meta-info.t.cpp b/tests/unit/meta-info.t.cpp
index 2e37ea5..bd5aee4 100644
--- a/tests/unit/meta-info.t.cpp
+++ b/tests/unit/meta-info.t.cpp
@@ -78,6 +78,19 @@
   BOOST_CHECK_EQUAL(b.wireEncode(), wire3);
 }
 
+BOOST_AUTO_TEST_CASE(FreshnessPeriodOverflow)
+{
+  // Bug #4997
+  MetaInfo mi0("140A 19087FFFFFFFFFFFFFFF"_block);
+  BOOST_CHECK_EQUAL(mi0.getFreshnessPeriod(), 0x7FFFFFFFFFFFFFFF_ms);
+
+  MetaInfo mi1("140A 19088000000000000000"_block);
+  BOOST_CHECK_EQUAL(mi1.getFreshnessPeriod(), time::milliseconds::max());
+
+  MetaInfo mi2("140A 1908FFFFFFFFFFFFFFFF"_block);
+  BOOST_CHECK_EQUAL(mi2.getFreshnessPeriod(), time::milliseconds::max());
+}
+
 BOOST_AUTO_TEST_CASE(AppMetaInfo)
 {
   MetaInfo info1;