tests: adapt to lp::PrefixAnnouncementHeader
Change-Id: Ic1bfeb76010955426b421f9239d9bbc987e2f316
refs: #4280
diff --git a/tests/daemon/face/generic-link-service.t.cpp b/tests/daemon/face/generic-link-service.t.cpp
index 2192622..13d9476 100644
--- a/tests/daemon/face/generic-link-service.t.cpp
+++ b/tests/daemon/face/generic-link-service.t.cpp
@@ -27,11 +27,13 @@
#include "face/face.hpp"
#include "dummy-transport.hpp"
+#include "tests/identity-management-fixture.hpp"
#include "tests/test-common.hpp"
#include <ndn-cxx/lp/empty-value.hpp>
-#include <ndn-cxx/lp/prefix-announcement.hpp>
+#include <ndn-cxx/lp/prefix-announcement-header.hpp>
#include <ndn-cxx/lp/tags.hpp>
+#include <ndn-cxx/security/signing-helpers.hpp>
namespace nfd {
namespace face {
@@ -39,18 +41,11 @@
using namespace nfd::tests;
-static lp::PrefixAnnouncement
-makePrefixAnnouncement(Name announcedName)
-{
- Name paName = Name("self-learning").append(announcedName).appendVersion();
- return lp::PrefixAnnouncement(makeData(paName));
-}
-
BOOST_AUTO_TEST_SUITE(Face)
using nfd::Face;
-class GenericLinkServiceFixture : public UnitTestTimeFixture
+class GenericLinkServiceFixture : public IdentityManagementTimeFixture
{
protected:
GenericLinkServiceFixture()
@@ -86,6 +81,13 @@
[this] (const lp::Nack& nack) { receivedNacks.push_back(nack); });
}
+ lp::PrefixAnnouncementHeader
+ makePrefixAnnHeader(const Name& announcedName)
+ {
+ return lp::PrefixAnnouncementHeader{signPrefixAnn(
+ makePrefixAnn(announcedName, 1_h), m_keyChain, ndn::signingWithSha256())};
+ }
+
protected:
unique_ptr<Face> face;
GenericLinkService* service;
@@ -1244,8 +1246,8 @@
initialize(options);
shared_ptr<Data> data = makeData("/12345678");
- lp::PrefixAnnouncement pa = makePrefixAnnouncement("/local/ndn/prefix");
- data->setTag(make_shared<lp::PrefixAnnouncementTag>(pa));
+ auto pah = makePrefixAnnHeader("/local/ndn/prefix");
+ data->setTag(make_shared<lp::PrefixAnnouncementTag>(pah));
face->sendData(*data);
@@ -1261,8 +1263,8 @@
initialize(options);
shared_ptr<Data> data = makeData("/12345678");
- lp::PrefixAnnouncement pa = makePrefixAnnouncement("/local/ndn/prefix");
- data->setTag(make_shared<lp::PrefixAnnouncementTag>(pa));
+ auto pah = makePrefixAnnHeader("/local/ndn/prefix");
+ data->setTag(make_shared<lp::PrefixAnnouncementTag>(pah));
face->sendData(*data);
@@ -1278,15 +1280,15 @@
initialize(options);
shared_ptr<Data> data = makeData("/12345678");
- lp::PrefixAnnouncement pa = makePrefixAnnouncement("/local/ndn/prefix");
lp::Packet packet(data->wireEncode());
- packet.set<lp::PrefixAnnouncementField>(pa);
+ auto pah = makePrefixAnnHeader("/local/ndn/prefix");
+ packet.set<lp::PrefixAnnouncementField>(pah);
transport->receivePacket(packet.wireEncode());
BOOST_REQUIRE_EQUAL(receivedData.size(), 1);
shared_ptr<lp::PrefixAnnouncementTag> tag = receivedData.back().getTag<lp::PrefixAnnouncementTag>();
- BOOST_REQUIRE_EQUAL(tag->get().getAnnouncedName(), "/local/ndn/prefix");
+ BOOST_CHECK_EQUAL(tag->get().getPrefixAnn()->getAnnouncedName(), "/local/ndn/prefix");
}
BOOST_AUTO_TEST_CASE(ReceivePrefixAnnouncementDisabled)
@@ -1296,16 +1298,16 @@
initialize(options);
shared_ptr<Data> data = makeData("/12345678");
- lp::PrefixAnnouncement pa = makePrefixAnnouncement("/local/ndn/prefix");
lp::Packet packet(data->wireEncode());
- packet.set<lp::PrefixAnnouncementField>(pa);
+ auto pah = makePrefixAnnHeader("/local/ndn/prefix");
+ packet.set<lp::PrefixAnnouncementField>(pah);
transport->receivePacket(packet.wireEncode());
BOOST_CHECK_EQUAL(service->getCounters().nInNetInvalid, 0); // not an error
BOOST_CHECK_EQUAL(receivedData.size(), 1);
- shared_ptr<lp::NonDiscoveryTag> tag = receivedData.back().getTag<lp::NonDiscoveryTag>();
+ shared_ptr<lp::PrefixAnnouncementTag> tag = receivedData.back().getTag<lp::PrefixAnnouncementTag>();
BOOST_CHECK(tag == nullptr);
}
@@ -1316,9 +1318,9 @@
initialize(options);
shared_ptr<Interest> interest = makeInterest("/12345678");
- lp::PrefixAnnouncement pa = makePrefixAnnouncement("/local/ndn/prefix");
lp::Packet packet(interest->wireEncode());
- packet.set<lp::PrefixAnnouncementField>(pa);
+ auto pah = makePrefixAnnHeader("/local/ndn/prefix");
+ packet.set<lp::PrefixAnnouncementField>(pah);
transport->receivePacket(packet.wireEncode());
@@ -1333,12 +1335,12 @@
initialize(options);
lp::Nack nack = makeNack("/localhost/test", 123, lp::NackReason::NO_ROUTE);
- lp::PrefixAnnouncement pa = makePrefixAnnouncement("/local/ndn/prefix");
lp::Packet packet;
packet.set<lp::FragmentField>(std::make_pair(
nack.getInterest().wireEncode().begin(), nack.getInterest().wireEncode().end()));
packet.set<lp::NackField>(nack.getHeader());
- packet.set<lp::PrefixAnnouncementField>(pa);
+ auto pah = makePrefixAnnHeader("/local/ndn/prefix");
+ packet.set<lp::PrefixAnnouncementField>(pah);
transport->receivePacket(packet.wireEncode());