**breaking** consolidate src/tlv/*lsa* into src/lsa/*lsa*
Lsa de/serialize functions are replaced by wireEncode/Decode.
Update LSA wire formats. Change TLV assignments as required.
Update nlsrc to print using new encoding.
refs: #4787
Change-Id: Ie8d40b7836d51ea5bb444c8db208dc2b3a0d1cec
diff --git a/tests/test-lsa.cpp b/tests/test-lsa.cpp
index 20fc1c1..fb08473 100644
--- a/tests/test-lsa.cpp
+++ b/tests/test-lsa.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -19,43 +19,162 @@
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
-#include "lsa.hpp"
+#include "lsa/name-lsa.hpp"
+#include "lsa/adj-lsa.hpp"
+#include "lsa/coordinate-lsa.hpp"
#include "test-common.hpp"
#include "adjacent.hpp"
#include "name-prefix-list.hpp"
#include <ndn-cxx/util/time.hpp>
-#include <sstream>
namespace nlsr {
namespace test {
+/*static void
+printBytes(const uint8_t* buf, size_t size)
+{
+ std::string hex = ndn::toHex(buf, size);
+
+ for (size_t i = 0; i < hex.size(); i++) {
+ if (i > 0 && i % 30 == 0)
+ std::cout << "\n ";
+
+ std::cout << "0x" << hex[i];
+ std::cout << hex[++i];
+
+ if ((i + 1) != hex.size())
+ std::cout << ", ";
+ }
+ std::cout << "\n" << "};" << std::endl;
+}
+
+printBytes(wire.wire(), wire.size());*/
+
BOOST_AUTO_TEST_SUITE(TestLsa)
+const uint8_t NAME_LSA1[] = {
+ 0x89, 0x37, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
+ 0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32
+};
+
+const uint8_t NAME_LSA_EXTRA_NAME[] = {
+ 0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
+ 0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
+ 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
+};
+
+const uint8_t NAME_LSA_DIFF_SEQ[] = {
+ 0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
+ 0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
+ 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
+};
+
+const uint8_t NAME_LSA_DIFF_TS[] = {
+ 0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x34, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
+ 0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
+ 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
+};
+
BOOST_AUTO_TEST_CASE(NameLsaBasic)
{
ndn::Name s1{"name1"};
ndn::Name s2{"name2"};
NamePrefixList npl1{s1, s2};
- ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
+ ndn::time::system_clock::TimePoint testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
- //3rd arg is seqNo. which will be a random number I just put in 12.
+ // 3rd argument is seqNo
NameLsa nlsa1("router1", 12, testTimePoint, npl1);
NameLsa nlsa2("router2", 12, testTimePoint, npl1);
BOOST_CHECK_EQUAL(nlsa1.getType(), Lsa::Type::NAME);
-
BOOST_CHECK(nlsa1.getExpirationTimePoint() == nlsa2.getExpirationTimePoint());
-
BOOST_CHECK(nlsa1.getKey() != nlsa2.getKey());
+
+ auto wire = nlsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA1, NAME_LSA1 + sizeof(NAME_LSA1),
+ wire.begin(), wire.end());
+
+ nlsa1.addName("name3");
+ wire = nlsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA_EXTRA_NAME,
+ NAME_LSA_EXTRA_NAME + sizeof(NAME_LSA_EXTRA_NAME),
+ wire.begin(), wire.end());
+
+ nlsa1.setSeqNo(14);
+ wire = nlsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA_DIFF_SEQ, NAME_LSA_DIFF_SEQ + sizeof(NAME_LSA_DIFF_SEQ),
+ wire.begin(), wire.end());
+
+ testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
+ nlsa1.setExpirationTimePoint(testTimePoint);
+ wire = nlsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA_DIFF_TS, NAME_LSA_DIFF_TS + sizeof(NAME_LSA_DIFF_TS),
+ wire.begin(), wire.end());
+ // Not testing router name as not sure if that will ever change once set
}
-BOOST_AUTO_TEST_CASE(AdjacentLsaConstructorAndGetters)
+const uint8_t ADJ_LSA1[] = {
+ 0x83, 0x58, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
+ 0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0C, 0x8B, 0x13,
+ 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
+ 0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
+ 0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
+ 0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t ADJ_LSA_EXTRA_NEIGHBOR[] = {
+ 0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
+ 0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0C, 0x8B, 0x13,
+ 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
+ 0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
+ 0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
+ 0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
+ 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
+ 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t ADJ_LSA_DIFF_SEQ[] = {
+ 0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
+ 0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0E, 0x8B, 0x13,
+ 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
+ 0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
+ 0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
+ 0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
+ 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
+ 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+const uint8_t ADJ_LSA_DIFF_TS[] = {
+ 0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
+ 0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0E, 0x8B, 0x13,
+ 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
+ 0x33, 0x3A, 0x34, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
+ 0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
+ 0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
+ 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
+ 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+BOOST_AUTO_TEST_CASE(AdjLsaBasic)
{
ndn::Name routerName("/ndn/site/router");
ndn::Name adjacencyName("/ndn/site/adjacency");
- ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
+ ndn::time::system_clock::TimePoint testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
uint32_t seqNo = 12;
// An AdjLsa initialized with ACTIVE adjacencies should copy the adjacencies
@@ -68,7 +187,7 @@
activeAdjacencies.size(), activeAdjacencies);
BOOST_CHECK_EQUAL(alsa1.getAdl().size(), 1);
BOOST_CHECK_EQUAL(alsa1.getType(), Lsa::Type::ADJACENCY);
- BOOST_CHECK_EQUAL(alsa1.getLsSeqNo(), seqNo);
+ BOOST_CHECK_EQUAL(alsa1.getSeqNo(), seqNo);
BOOST_CHECK_EQUAL(alsa1.getExpirationTimePoint(), testTimePoint);
BOOST_CHECK_EQUAL(alsa1.getNoLink(), 1);
BOOST_CHECK(alsa1.getAdl().isNeighbor(activeAdjacency.getName()));
@@ -90,12 +209,73 @@
AdjLsa alsa3(routerName, seqNo, testTimePoint,
activeAdjacencies.size(), activeAdjacencies);
BOOST_CHECK(alsa1.isEqualContent(alsa3));
+
+ auto wire = alsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA1, ADJ_LSA1 + sizeof(ADJ_LSA1),
+ wire.begin(), wire.end());
+
+ Adjacent activeAdjacency2("/ndn/edu/adjacency");
+ activeAdjacency2.setStatus(Adjacent::STATUS_ACTIVE);
+ alsa1.addAdjacent(activeAdjacency2);
+ wire = alsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA_EXTRA_NEIGHBOR,
+ ADJ_LSA_EXTRA_NEIGHBOR + sizeof(ADJ_LSA_EXTRA_NEIGHBOR),
+ wire.begin(), wire.end());
+
+ alsa1.setSeqNo(14);
+ wire = alsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA_DIFF_SEQ, ADJ_LSA_DIFF_SEQ + sizeof(ADJ_LSA_DIFF_SEQ),
+ wire.begin(), wire.end());
+
+ testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
+ alsa1.setExpirationTimePoint(testTimePoint);
+ wire = alsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA_DIFF_TS, ADJ_LSA_DIFF_TS + sizeof(ADJ_LSA_DIFF_TS),
+ wire.begin(), wire.end());
}
-BOOST_AUTO_TEST_CASE(CoordinateLsaConstructorAndGetters)
+const uint8_t COORDINATE_LSA1[] = {
+ 0x85, 0x43, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x04, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x88, 0x08, 0x40, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88,
+ 0x08, 0x40, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t COORDINATE_LSA_DIFF_ANGLE[] = {
+ 0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x04, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t COORDINATE_LSA_DIFF_RADIUS[] = {
+ 0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t COORDINATE_LSA_DIFF_SEQ[] = {
+ 0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const uint8_t COORDINATE_LSA_DIFF_TS[] = {
+ 0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
+ 0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
+ 0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x34, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+BOOST_AUTO_TEST_CASE(CoordinateLsaBasic)
{
- ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
- std::vector<double> angles1, angles2;
+ ndn::time::system_clock::TimePoint testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
+ std::vector<double> angles1 {30.0}, angles2 {30.0};
angles1.push_back(30.0);
angles2.push_back(30.0);
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles1);
@@ -106,7 +286,38 @@
BOOST_CHECK(clsa1.isEqualContent(clsa2));
- BOOST_CHECK_EQUAL(clsa1.serialize(), clsa2.serialize());
+ BOOST_CHECK_EQUAL(clsa1.wireEncode(), clsa2.wireEncode());
+
+ auto wire = clsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA1, COORDINATE_LSA1 + sizeof(COORDINATE_LSA1),
+ wire.begin(), wire.end());
+
+ std::vector<double> angles3{40.0};
+ clsa1.setCorTheta(angles3);
+ wire = clsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_ANGLE,
+ COORDINATE_LSA_DIFF_ANGLE + sizeof(COORDINATE_LSA_DIFF_ANGLE),
+ wire.begin(), wire.end());
+
+ clsa1.setCorRadius(2.3);
+ wire = clsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_RADIUS,
+ COORDINATE_LSA_DIFF_RADIUS + sizeof(COORDINATE_LSA_DIFF_RADIUS),
+ wire.begin(), wire.end());
+
+ clsa1.setSeqNo(14);
+ wire = clsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_SEQ,
+ COORDINATE_LSA_DIFF_SEQ + sizeof(COORDINATE_LSA_DIFF_SEQ),
+ wire.begin(), wire.end());
+
+ testTimePoint =
+ ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
+ clsa1.setExpirationTimePoint(testTimePoint);
+ wire = clsa1.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_TS,
+ COORDINATE_LSA_DIFF_TS + sizeof(COORDINATE_LSA_DIFF_TS),
+ wire.begin(), wire.end());
}
BOOST_AUTO_TEST_CASE(IncrementAdjacentNumber)
@@ -121,7 +332,7 @@
adjList.insert(adj1);
adjList.insert(adj2);
- ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
+ ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now() + ndn::time::seconds(3600);
std::ostringstream ss;
ss << testTimePoint;
@@ -130,19 +341,13 @@
AdjLsa lsa("router1", 12, testTimePoint, adjList.size(), adjList);
std::string EXPECTED_OUTPUT =
- "LSA of type ADJACENCY:\n"
- "-Origin Router: /router1\n"
- "-Sequence Number: 12\n"
- "-Expiration Point: " + TEST_TIME_POINT_STRING + "\n"
- "-Adjacents:--Adjacent1:\n"
- "---Adjacent Name: /adjacent1\n"
- "---Connecting FaceUri: ://\n"
- "---Link Cost: 10\n"
- "--Adjacent2:\n"
- "---Adjacent Name: /adjacent2\n"
- "---Connecting FaceUri: ://\n"
- "---Link Cost: 10\n"
- "adj_lsa_end";
+ " ADJACENCY LSA:\n"
+ " Origin Router : /router1\n"
+ " Sequence Number : 12\n"
+ " Expires in : 3599999 milliseconds\n"
+ " Adjacents:\n"
+ " Adjacent 0: (name=/adjacent1, uri=://, cost=10)\n"
+ " Adjacent 1: (name=/adjacent2, uri=://, cost=10)\n";
std::ostringstream os;
os << lsa;
@@ -172,10 +377,7 @@
ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
AdjLsa adjlsa1("router1", 1, testTimePoint, adjList.size(), adjList);
- AdjLsa adjlsa2;
-
- BOOST_CHECK(adjlsa2.deserialize(adjlsa1.serialize()));
-
+ AdjLsa adjlsa2(adjlsa1.wireEncode());
BOOST_CHECK(adjlsa1.isEqualContent(adjlsa2));
//Name LSA
@@ -184,24 +386,16 @@
NamePrefixList npl1{s1, s2};
NameLsa nlsa1("router1", 1, testTimePoint, npl1);
- NameLsa nlsa2;
-
- BOOST_CHECK(nlsa2.deserialize(nlsa1.serialize()));
-
- BOOST_CHECK_EQUAL(nlsa1.serialize(), nlsa2.serialize());
+ NameLsa nlsa2(nlsa1.wireEncode());
+ BOOST_CHECK_EQUAL(nlsa1.wireEncode(), nlsa2.wireEncode());
//Coordinate LSA
std::vector<double> angles = {30, 40.0};
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles);
- CoordinateLsa clsa2;
-
- BOOST_CHECK(clsa2.deserialize(clsa1.serialize()));
-
- BOOST_CHECK_EQUAL(clsa1.serialize(), clsa2.serialize());
+ CoordinateLsa clsa2(clsa1.wireEncode());
+ BOOST_CHECK_EQUAL(clsa1.wireEncode(), clsa2.wireEncode());
}
-BOOST_AUTO_TEST_SUITE(TestNameLsa)
-
BOOST_AUTO_TEST_CASE(OperatorEquals)
{
NameLsa lsa1;
@@ -221,8 +415,6 @@
BOOST_CHECK(lsa1.isEqualContent(lsa2));
}
-BOOST_AUTO_TEST_SUITE_END() // TestNameLsa
-
BOOST_AUTO_TEST_SUITE_END()
} // namespace test