management: add CachingPolicy to LocalControlHeader
Breaks: NFD:commit:9cfeecaa2ffad1a1be79aed2321dcc7d042ecc5f
Breaks: ndnSIM:commit:ffe2586cfc466935c0632a5a64384f0fda709086
Change-Id: Idcce2b7ee9be31b55f9ec16c17e915d93974bff4
Refs: #2183
diff --git a/tests/unit-tests/test-interest.cpp b/tests/unit-tests/test-interest.cpp
index 71d6d29..7151c56 100644
--- a/tests/unit-tests/test-interest.cpp
+++ b/tests/unit-tests/test-interest.cpp
@@ -365,7 +365,10 @@
BOOST_CHECK(!interest.hasWire());
- Block headerBlock = interest.getLocalControlHeader().wireEncode(interest, true, true);
+ Block headerBlock =
+ interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID |
+ nfd::LocalControlHeader::ENCODE_NEXT_HOP);
BOOST_CHECK(interest.hasWire());
BOOST_CHECK(headerBlock.hasWire());
@@ -380,7 +383,10 @@
interest.setNonce(1000);
- Block updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, true, true);
+ Block updatedHeaderBlock =
+ interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID |
+ nfd::LocalControlHeader::ENCODE_NEXT_HOP);
BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 5);
// only length should have changed
@@ -389,30 +395,43 @@
// updating IncomingFaceId that keeps the length
interest.setIncomingFaceId(100);
- updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, true, true);
+ updatedHeaderBlock =
+ interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID |
+ nfd::LocalControlHeader::ENCODE_NEXT_HOP);
BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 5);
BOOST_CHECK_NE(*(updatedHeaderBlock.begin() + 4), *(headerBlock.begin() + 4));
// updating IncomingFaceId that increases the length by 2
interest.setIncomingFaceId(1000);
- updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, true, true);
+ updatedHeaderBlock =
+ interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID |
+ nfd::LocalControlHeader::ENCODE_NEXT_HOP);
BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 6);
// adding NextHopId
interest.setNextHopFaceId(1);
- updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, true, true);
+ updatedHeaderBlock =
+ interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID |
+ nfd::LocalControlHeader::ENCODE_NEXT_HOP);
BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 9);
// masking IncomingFaceId
- updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, false, true);
+ updatedHeaderBlock = interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_NEXT_HOP);
BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 5);
// masking NextHopId
- updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, true, false);
+ updatedHeaderBlock =
+ interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID);
BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 6);
// masking everything
- BOOST_CHECK_THROW(interest.getLocalControlHeader().wireEncode(interest, false, false),
+ BOOST_CHECK_THROW(interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_NONE),
nfd::LocalControlHeader::Error);
}
@@ -432,24 +451,42 @@
BOOST_REQUIRE_NO_THROW(interest.getLocalControlHeader().wireDecode(wireBlock));
- BOOST_CHECK_EQUAL(interest.getLocalControlHeader().wireEncode(interest, true, true).size(), 5);
+ BOOST_CHECK_EQUAL(
+ interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID |
+ nfd::LocalControlHeader::ENCODE_NEXT_HOP).size(),
+ 5);
BOOST_CHECK_EQUAL(interest.getIncomingFaceId(), 10);
BOOST_CHECK(!interest.getLocalControlHeader().hasNextHopFaceId());
- BOOST_CHECK_THROW(interest.getLocalControlHeader().wireEncode(interest, false, false),
+ BOOST_CHECK_THROW(interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_NONE),
nfd::LocalControlHeader::Error);
- BOOST_CHECK_THROW(interest.getLocalControlHeader().wireEncode(interest, false, true),
+ BOOST_CHECK_THROW(interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_NEXT_HOP),
nfd::LocalControlHeader::Error);
- BOOST_CHECK_NO_THROW(interest.getLocalControlHeader().wireEncode(interest, true, false));
- BOOST_CHECK_NO_THROW(interest.getLocalControlHeader().wireEncode(interest, true, true));
+ BOOST_CHECK_NO_THROW(
+ interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID));
+ BOOST_CHECK_NO_THROW(
+ interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID |
+ nfd::LocalControlHeader::ENCODE_NEXT_HOP));
- BOOST_CHECK_NE((void*)interest.getLocalControlHeader().wireEncode(interest, true, true).wire(),
- (void*)wireBlock.wire());
+ BOOST_CHECK_NE(
+ (void*)interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID |
+ nfd::LocalControlHeader::ENCODE_NEXT_HOP)
+ .wire(),
+ (void*)wireBlock.wire());
- BOOST_CHECK_EQUAL(interest.getLocalControlHeader().wireEncode(interest, true, true).size(), 5);
+ BOOST_CHECK_EQUAL(interest.getLocalControlHeader()
+ .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID |
+ nfd::LocalControlHeader::ENCODE_NEXT_HOP).size(),
+ 5);
}
BOOST_AUTO_TEST_CASE(DecodeWithoutLocalHeader)