tests: use NullSignature
Change-Id: Icb8ff95905cfa2ba9d9a493d7a60b30a61a8d671
diff --git a/tests/daemon/face/lp-fragmenter.t.cpp b/tests/daemon/face/lp-fragmenter.t.cpp
index d440310..30eb8e9 100644
--- a/tests/daemon/face/lp-fragmenter.t.cpp
+++ b/tests/daemon/face/lp-fragmenter.t.cpp
@@ -24,10 +24,8 @@
*/
#include "face/lp-fragmenter.hpp"
-#include "face/transport.hpp"
#include "tests/test-common.hpp"
-#include "tests/daemon/global-io-fixture.hpp"
namespace nfd {
namespace face {
@@ -35,7 +33,7 @@
using namespace nfd::tests;
-class LpFragmenterFixture : public GlobalIoFixture
+class LpFragmenterFixture
{
protected:
LpFragmenter fragmenter{{}};
@@ -44,23 +42,22 @@
BOOST_AUTO_TEST_SUITE(Face)
BOOST_FIXTURE_TEST_SUITE(TestLpFragmenter, LpFragmenterFixture)
-BOOST_AUTO_TEST_CASE(FragmentSingleFragment)
+BOOST_AUTO_TEST_CASE(SingleFragment)
{
- size_t mtu = 256;
+ const size_t mtu = 256;
lp::Packet packet;
packet.add<lp::IncomingFaceIdField>(123);
auto data = makeData("/test/data123");
- BOOST_REQUIRE_EQUAL(data->wireEncode().size(), 30);
packet.add<lp::FragmentField>({data->wireEncode().begin(), data->wireEncode().end()});
bool isOk = false;
std::vector<lp::Packet> frags;
std::tie(isOk, frags) = fragmenter.fragmentPacket(packet, mtu);
-
BOOST_REQUIRE(isOk);
BOOST_REQUIRE_EQUAL(frags.size(), 1);
+
BOOST_CHECK(frags[0].has<lp::FragmentField>());
BOOST_CHECK_EQUAL(frags[0].get<lp::IncomingFaceIdField>(), 123);
BOOST_CHECK(!frags[0].has<lp::FragIndexField>());
@@ -73,25 +70,23 @@
fragBegin, fragEnd);
}
-BOOST_AUTO_TEST_CASE(FragmentMultipleFragments)
+BOOST_AUTO_TEST_CASE(MultipleFragments)
{
- size_t mtu = MIN_MTU;
+ const size_t mtu = MIN_MTU;
lp::Packet packet;
packet.add<lp::IncomingFaceIdField>(123);
auto data = makeData("/test/data123/123456789/987654321/123456789");
- BOOST_REQUIRE_EQUAL(data->wireEncode().size(), 63);
packet.add<lp::FragmentField>({data->wireEncode().begin(), data->wireEncode().end()});
bool isOk = false;
std::vector<lp::Packet> frags;
std::tie(isOk, frags) = fragmenter.fragmentPacket(packet, mtu);
-
BOOST_REQUIRE(isOk);
BOOST_REQUIRE_EQUAL(frags.size(), 5);
- ndn::Buffer reassembledPayload(63);
+ ndn::Buffer reassembledPayload(data->wireEncode().size());
BOOST_CHECK(frags[0].has<lp::FragmentField>());
BOOST_CHECK_EQUAL(frags[0].get<lp::IncomingFaceIdField>(), 123);
@@ -151,9 +146,9 @@
reassembledPayload.begin(), reassembledPayload.end());
}
-BOOST_AUTO_TEST_CASE(FragmentMtuTooSmall)
+BOOST_AUTO_TEST_CASE(MtuTooSmall)
{
- size_t mtu = 20;
+ const size_t mtu = 20;
BOOST_ASSERT(mtu < MIN_MTU);
lp::Packet packet;
@@ -167,13 +162,14 @@
BOOST_CHECK_EQUAL(isOk, false);
}
-BOOST_AUTO_TEST_CASE(FragmentOverFragCount)
+BOOST_AUTO_TEST_CASE(FragCountOverLimit)
{
LpFragmenter::Options options;
options.nMaxFragments = 2;
fragmenter.setOptions(options);
- size_t mtu = 70;
+ const size_t mtu = 70;
+ BOOST_ASSERT(mtu >= MIN_MTU);
lp::Packet packet;
packet.add<lp::IncomingFaceIdField>(123);
diff --git a/tests/other/cs-benchmark.cpp b/tests/other/cs-benchmark.cpp
index 252e6fd..eae79be 100644
--- a/tests/other/cs-benchmark.cpp
+++ b/tests/other/cs-benchmark.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -70,10 +70,9 @@
static shared_ptr<Data>
makeData(const Name& name)
{
- auto data = make_shared<Data>(name);
- ndn::SignatureSha256WithRsa fakeSignature;
- fakeSignature.setValue(ndn::encoding::makeEmptyBlock(tlv::SignatureValue));
- data->setSignature(fakeSignature);
+ auto data = std::make_shared<Data>(name);
+ data->setSignatureInfo(ndn::SignatureInfo(tlv::NullSignature));
+ data->setSignatureValue(std::make_shared<ndn::Buffer>());
data->wireEncode();
return data;
}
@@ -115,7 +114,7 @@
std::vector<shared_ptr<Interest>> workload(count);
for (size_t i = 0; i < count; ++i) {
Name name = genName(i);
- auto interest = make_shared<Interest>(name);
+ auto interest = std::make_shared<Interest>(name);
interest->setCanBePrefix(false);
workload[i] = interest;
}
diff --git a/tests/test-common.cpp b/tests/test-common.cpp
index 8fe7c59..b57e804 100644
--- a/tests/test-common.cpp
+++ b/tests/test-common.cpp
@@ -25,8 +25,6 @@
#include "tests/test-common.hpp"
-#include <ndn-cxx/security/signature-sha256-with-rsa.hpp>
-
namespace nfd {
namespace tests {
@@ -34,7 +32,7 @@
makeInterest(const Name& name, bool canBePrefix, optional<time::milliseconds> lifetime,
optional<Interest::Nonce> nonce)
{
- auto interest = make_shared<Interest>(name);
+ auto interest = std::make_shared<Interest>(name);
interest->setCanBePrefix(canBePrefix);
if (lifetime) {
interest->setInterestLifetime(*lifetime);
@@ -46,16 +44,15 @@
shared_ptr<Data>
makeData(const Name& name)
{
- auto data = make_shared<Data>(name);
+ auto data = std::make_shared<Data>(name);
return signData(data);
}
Data&
signData(Data& data)
{
- ndn::SignatureSha256WithRsa fakeSignature;
- fakeSignature.setValue(ndn::encoding::makeEmptyBlock(tlv::SignatureValue));
- data.setSignature(fakeSignature);
+ data.setSignatureInfo(ndn::SignatureInfo(tlv::NullSignature));
+ data.setSignatureValue(std::make_shared<ndn::Buffer>());
data.wireEncode();
return data;
}
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
index 3139ef9..8d37568 100644
--- a/tests/test-common.hpp
+++ b/tests/test-common.hpp
@@ -47,26 +47,30 @@
namespace nfd {
namespace tests {
-/** \brief create an Interest
+/**
+ * \brief Create an Interest
*/
shared_ptr<Interest>
makeInterest(const Name& name, bool canBePrefix = false,
optional<time::milliseconds> lifetime = nullopt,
optional<Interest::Nonce> nonce = nullopt);
-/** \brief create a Data with fake signature
- * \note Data may be modified afterwards without losing the fake signature.
- * If a real signature is desired, sign again with KeyChain.
+/**
+ * \brief Create a Data with a null (i.e., empty) signature
+ *
+ * If a real signature is desired, use KeyChainFixture and sign again with `m_keyChain`.
*/
shared_ptr<Data>
makeData(const Name& name);
-/** \brief add a fake signature to Data
+/**
+ * \brief Add a null signature to \p data
*/
Data&
signData(Data& data);
-/** \brief add a fake signature to Data
+/**
+ * \brief Add a null signature to \p data
*/
inline shared_ptr<Data>
signData(shared_ptr<Data> data)
@@ -75,15 +79,17 @@
return data;
}
-/** \brief create a Nack
+/**
+ * \brief Create a Nack
*/
lp::Nack
makeNack(Interest interest, lp::NackReason reason);
-/** \brief replace a name component in a packet
- * \param[inout] pkt the packet
- * \param index the index of the name component to replace
- * \param args arguments to name::Component constructor
+/**
+ * \brief Replace a name component in a packet
+ * \param[inout] pkt the packet
+ * \param index the index of the name component to replace
+ * \param args arguments to name::Component constructor
*/
template<typename Packet, typename ...Args>
void
@@ -94,22 +100,25 @@
pkt.setName(name);
}
-/** \brief create a prefix announcement without signing
+/**
+ * \brief Create a prefix announcement without signing
*/
ndn::PrefixAnnouncement
makePrefixAnn(const Name& announcedName, time::milliseconds expiration,
optional<ndn::security::ValidityPeriod> validity = nullopt);
-/** \brief create a prefix announcement without signing
- * \param announcedName announced name
- * \param expiration expiration period
- * \param validityFromNow validity period, relative from now
+/**
+ * \brief Create a prefix announcement without signing
+ * \param announcedName announced name
+ * \param expiration expiration period
+ * \param validityFromNow validity period, relative from now
*/
ndn::PrefixAnnouncement
makePrefixAnn(const Name& announcedName, time::milliseconds expiration,
std::pair<time::seconds, time::seconds> validityFromNow);
-/** \brief sign a prefix announcement
+/**
+ * \brief Sign a prefix announcement
*/
ndn::PrefixAnnouncement
signPrefixAnn(ndn::PrefixAnnouncement&& pa, ndn::KeyChain& keyChain,