tests: fix compatibility with signed Interests in v0.3 format
Change-Id: I52bd2bfb5d9551614e2cf012b19b966d84306368
diff --git a/tests/route/test-fib.cpp b/tests/route/test-fib.cpp
index 9da37de..a902eb7 100644
--- a/tests/route/test-fib.cpp
+++ b/tests/route/test-fib.cpp
@@ -59,17 +59,18 @@
void
enableRegistrationReplyWithFaceId()
{
- face.onSendInterest.connect([this] (const ndn::Interest& interest) {
- static const ndn::Name localhostRegistration("/localhost/nfd/rib");
- if (!localhostRegistration.isPrefixOf(interest.getName()))
+ face.onSendInterest.connect([this] (const auto& interest) {
+ if (!RIB_COMMAND_PREFIX.isPrefixOf(interest.getName()))
return;
- ndn::nfd::ControlParameters params(interest.getName().get(-5).blockFromValue());
+ ndn::name::Component verb;
+ ndn::nfd::ControlParameters params;
+ extractRibCommandParameters(interest, verb, params);
if (!params.hasFaceId()) {
params.setFaceId(1);
}
params.setOrigin(ndn::nfd::ROUTE_ORIGIN_APP);
- if (interest.getName().get(3) == ndn::name::Component("register")) {
+ if (verb == ndn::name::Component("register")) {
params.setCost(0);
}
@@ -79,7 +80,6 @@
ndn::Data data(interest.getName());
data.setContent(resp.wireEncode());
-
m_keyChain.sign(data, ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_SHA256));
face.getIoService().post([this, data] { face.receive(data); });
@@ -87,23 +87,22 @@
}
static void
- extractRibCommandParameters(const ndn::Interest& interest, ndn::Name::Component& verb,
- ndn::nfd::ControlParameters& extractedParameters)
+ extractRibCommandParameters(const ndn::Interest& interest,
+ ndn::Name::Component& verb,
+ ndn::nfd::ControlParameters& params)
{
- static const ndn::Name commandPrefix("/localhost/nfd/rib");
-
const auto& name = interest.getName();
- verb = name.at(commandPrefix.size());
- const auto& paramComponent = name.at(commandPrefix.size() + 1);
- extractedParameters.wireDecode(paramComponent.blockFromValue());
+ verb = name.at(RIB_COMMAND_PREFIX.size());
+ params.wireDecode(name.at(RIB_COMMAND_PREFIX.size() + 1).blockFromValue());
}
private:
+ static inline const ndn::Name RIB_COMMAND_PREFIX{"/localhost/nfd/rib"};
+
ndn::Scheduler m_scheduler{m_io};
public:
ndn::util::DummyClientFace face{m_io, m_keyChain};
-
ConfParameter conf{face, m_keyChain};
AdjacencyList& adjacencies;
Fib fib;