tests: use BOOST_REQUIRE and Name::at() to prevent out-of-bound accesses

Various other cleanups

Change-Id: Ie099e618b12b7b6cf36c32be96d753221f14a8b6
This commit is contained in:
Davide Pesavento committed 2020-04-04 19:00:12 -04:00
1 parent 79c5baf1b9
commit 5b3cf7621c
13 files changed
+114 -142

No files matched your search

+2 -6
View File
@@ -119,9 +119,7 @@ public:
* Entries listed in positive are in ownIBLT but not in rcvdIBLT
* Entries listed in negative are in rcvdIBLT but not in ownIBLT
*
* @param positive
* @param negative
* @return true if decoding is complete successfully
* @return whether decoding completed successfully
*/
bool
listEntries(std::set<uint32_t>& positive, std::set<uint32_t>& negative) const;
@@ -136,15 +134,13 @@ public:
}
/**
* @brief Appends self to name
* @brief Appends self to @p name
*
* Encodes our hash table from uint32_t vector to uint8_t vector
* We create a uin8_t vector 12 times the size of uint32_t vector
* We put the first count in first 4 cells, keySum in next 4, and keyCheck in next 4.
* Repeat for all the other cells of the hash table.
* Then we append this uint8_t vector to the name.
*
* @param name
*/
void
appendToName(ndn::Name& name) const;
-3
View File
@@ -151,9 +151,6 @@ PSYNC_PUBLIC_WITH_TESTS_ELSE_PROTECTED:
/**
* @brief Logs a message if setting an interest filter fails
*
* @param prefix
* @param msg
*/
void
onRegisterFailed(const ndn::Name& prefix, const std::string& msg) const;
+7 -7
View File
@@ -19,7 +19,8 @@
#include "PSync/detail/bloom-filter.hpp"
#include <boost/test/unit_test.hpp>
#include "tests/boost-test.hpp"
#include <ndn-cxx/name.hpp>
namespace psync {
@@ -42,18 +43,17 @@ BOOST_AUTO_TEST_CASE(NameAppendAndExtract)
Name bfName("/test");
BloomFilter bf(100, 0.001);
bf.insert("/memphis");
bf.appendToName(bfName);
BloomFilter bfFromName(100, 0.001, bfName.get(-1));
BloomFilter bfFromName(100, 0.001, bfName.at(-1));
BOOST_CHECK_EQUAL(bfName.get(1).toNumber(), 100);
BOOST_CHECK_EQUAL(bfName.get(2).toNumber(), 1);
BOOST_CHECK_EQUAL(bfName.at(1).toNumber(), 100);
BOOST_CHECK_EQUAL(bfName.at(2).toNumber(), 1);
BOOST_CHECK_EQUAL(bf, bfFromName);
BOOST_CHECK_THROW(BloomFilter inCompatibleBf(200, 0.001, bfName.get(-1)), std::runtime_error);
BOOST_CHECK_THROW(BloomFilter(200, 0.001, bfName.at(-1)), std::runtime_error);
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace psync
} // namespace psync
+13 -15
View File
@@ -18,36 +18,34 @@
**/
#include "PSync/consumer.hpp"
#include "unit-test-time-fixture.hpp"
#include <boost/test/unit_test.hpp>
#include "tests/boost-test.hpp"
#include "tests/unit-test-time-fixture.hpp"
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace psync {
using namespace ndn;
using namespace std;
BOOST_AUTO_TEST_SUITE(TestConsumer)
BOOST_AUTO_TEST_CASE(Constructor)
{
util::DummyClientFace face({true, true});
BOOST_REQUIRE_NO_THROW(Consumer(Name("/psync"),
face,
[] (const vector<Name>&) {},
[] (const vector<MissingDataInfo>&) {},
40,
0.001));
BOOST_REQUIRE_NO_THROW(Consumer(Name("/psync"), face,
[] (const std::vector<Name>&) {},
[] (const std::vector<MissingDataInfo>&) {},
40, 0.001));
}
BOOST_AUTO_TEST_CASE(AddSubscription)
{
util::DummyClientFace face({true, true});
Consumer consumer(Name("/psync"), face,
[] (const vector<Name>&) {},
[] (const vector<MissingDataInfo>&) {},
[] (const auto&) {},
[] (const auto&) {},
40, 0.001);
Name subscription("test");
@@ -57,12 +55,12 @@ BOOST_AUTO_TEST_CASE(AddSubscription)
BOOST_CHECK(!consumer.addSubscription(subscription));
}
BOOST_FIXTURE_TEST_CASE(ConstantTimeoutForFirstSegment, ndn::tests::UnitTestTimeFixture)
BOOST_FIXTURE_TEST_CASE(ConstantTimeoutForFirstSegment, tests::UnitTestTimeFixture)
{
util::DummyClientFace face(io, {true, true});
Consumer consumer(Name("/psync"), face,
[] (const vector<Name>&) {},
[] (const vector<MissingDataInfo>&) {},
[] (const auto&) {},
[] (const auto&) {},
40, 0.001,
ndn::time::milliseconds(4000),
ndn::time::milliseconds(4000));
@@ -82,4 +80,4 @@ BOOST_FIXTURE_TEST_CASE(ConstantTimeoutForFirstSegment, ndn::tests::UnitTestTime
BOOST_AUTO_TEST_SUITE_END()
} // namespace psync
} // namespace psync
+6 -6
View File
@@ -18,17 +18,17 @@
**/
#include "PSync/full-producer.hpp"
#include "unit-test-time-fixture.hpp"
#include <boost/test/unit_test.hpp>
#include "tests/boost-test.hpp"
#include "tests/unit-test-time-fixture.hpp"
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace psync {
using namespace ndn;
using namespace std;
BOOST_AUTO_TEST_SUITE(TestFullProducer)
@@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(OnInterest)
BOOST_REQUIRE_NO_THROW(node.onSyncInterest(syncPrefix, Interest(syncInterestName)));
}
BOOST_FIXTURE_TEST_CASE(ConstantTimeoutForFirstSegment, ndn::tests::UnitTestTimeFixture)
BOOST_FIXTURE_TEST_CASE(ConstantTimeoutForFirstSegment, tests::UnitTestTimeFixture)
{
Name syncPrefix("/psync"), userNode("/testUser");
util::DummyClientFace face(io, {true, true});
@@ -87,4 +87,4 @@ BOOST_AUTO_TEST_CASE(OnSyncDataDecodeFailure)
BOOST_AUTO_TEST_SUITE_END()
} // namespace psync
} // namespace psync
+15 -25
View File
@@ -17,38 +17,35 @@
* PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "unit-test-time-fixture.hpp"
#include "PSync/full-producer.hpp"
#include "PSync/consumer.hpp"
#include "PSync/detail/state.hpp"
#include <boost/test/unit_test.hpp>
#include "tests/boost-test.hpp"
#include "tests/unit-test-time-fixture.hpp"
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace psync {
using namespace ndn;
using namespace std;
class FullSyncFixture : public tests::UnitTestTimeFixture
{
public:
FullSyncFixture()
: syncPrefix("psync")
{
}
protected:
void
addNode(int id)
{
BOOST_ASSERT(id >= 0 && id <= 3);
faces[id] = std::make_shared<util::DummyClientFace>(io, util::DummyClientFace::Options{true, true});
userPrefixes[id] = Name("userPrefix" + to_string(id));
nodes[id] = make_shared<FullProducer>(40, *faces[id], syncPrefix, userPrefixes[id],
[] (const std::vector<MissingDataInfo>& updates) {});
[] (const auto&) {});
}
Name syncPrefix;
protected:
const Name syncPrefix = "/psync";
shared_ptr<util::DummyClientFace> faces[4];
Name userPrefixes[4];
shared_ptr<FullProducer> nodes[4];
@@ -134,7 +131,6 @@ BOOST_AUTO_TEST_CASE(MultipleNodes)
for (int i = 0; i < 4; i++) {
addNode(i);
}
for (int i = 0; i < 3; i++) {
faces[i]->linkTo(*faces[i + 1]);
}
@@ -158,16 +154,14 @@ BOOST_AUTO_TEST_CASE(MultipleNodes)
}
}
BOOST_AUTO_TEST_CASE(MultipleNodesSimulataneousPublish)
BOOST_AUTO_TEST_CASE(MultipleNodesSimultaneousPublish)
{
for (int i = 0; i < 4; i++) {
addNode(i);
}
for (int i = 0; i < 3; i++) {
faces[i]->linkTo(*faces[i + 1]);
}
for (int i = 0; i < 4; i++) {
nodes[i]->publishName(userPrefixes[i]);
}
@@ -196,7 +190,6 @@ BOOST_AUTO_TEST_CASE(NetworkPartition)
for (int i = 0; i < 4; i++) {
addNode(i);
}
for (int i = 0; i < 3; i++) {
faces[i]->linkTo(*faces[i + 1]);
}
@@ -210,7 +203,6 @@ BOOST_AUTO_TEST_CASE(NetworkPartition)
for (int i = 0; i < 3; i++) {
faces[i]->unlink();
}
faces[0]->linkTo(*faces[1]);
faces[2]->linkTo(*faces[3]);
@@ -238,7 +230,6 @@ BOOST_AUTO_TEST_CASE(NetworkPartition)
for (int i = 0; i < 3; i++) {
faces[i]->unlink();
}
for (int i = 0; i < 3; i++) {
faces[i]->linkTo(*faces[i + 1]);
}
@@ -369,7 +360,6 @@ BOOST_AUTO_TEST_CASE(DiffIBFDecodeFailureMultipleNodes)
for (int i = 0; i < 4; i++) {
addNode(i);
}
for (int i = 0; i < 3; i++) {
faces[i]->linkTo(*faces[i + 1]);
}
@@ -400,19 +390,17 @@ BOOST_AUTO_TEST_CASE(DelayedSecondSegment)
int i = 0;
State state;
std::shared_ptr<ndn::Buffer> compressed;
std::shared_ptr<Buffer> compressed;
do {
Name prefixToPublish("userNode0-" + to_string(i++));
nodes[0]->addUserNode(prefixToPublish);
nodes[0]->publishName(prefixToPublish);
state.addContent(ndn::Name(prefixToPublish).appendNumber(nodes[0]->m_prefixes[prefixToPublish]));
state.addContent(Name(prefixToPublish).appendNumber(nodes[0]->m_prefixes[prefixToPublish]));
auto block = state.wireEncode();
compressed = compress(nodes[0]->m_contentCompression, block.wire(), block.size());
} while (compressed->size() < (ndn::MAX_NDN_PACKET_SIZE >> 1));
} while (compressed->size() < (MAX_NDN_PACKET_SIZE >> 1));
advanceClocks(ndn::time::milliseconds(10), 100);
@@ -430,6 +418,7 @@ BOOST_AUTO_TEST_CASE(DelayedSecondSegment)
BOOST_CHECK_EQUAL(nodes[0]->m_segmentPublisher.m_ims.size(), 0);
// Get data name from face and increase segment number to form next interest
BOOST_REQUIRE(!faces[0]->sentData.empty());
Name dataName = faces[0]->sentData.front().getName();
Name interestName = dataName.getSubName(0, dataName.size() - 2);
interestName.appendSegment(1);
@@ -441,7 +430,8 @@ BOOST_AUTO_TEST_CASE(DelayedSecondSegment)
// Should have repopulated SegmentPublisher
BOOST_CHECK_EQUAL(nodes[0]->m_segmentPublisher.m_ims.size(), 2);
// Should have received the second data segment this time
BOOST_CHECK_EQUAL(faces[0]->sentData.front().getName()[-1].toSegment(), 1);
BOOST_REQUIRE(!faces[0]->sentData.empty());
BOOST_CHECK_EQUAL(faces[0]->sentData.front().getName().at(-1).toSegment(), 1);
}
BOOST_AUTO_TEST_SUITE_END()
+21 -23
View File
@@ -20,8 +20,8 @@
#include "PSync/detail/iblt.hpp"
#include "PSync/detail/util.hpp"
#include <boost/test/unit_test.hpp>
#include <ndn-cxx/name.hpp>
#include "tests/boost-test.hpp"
#include <ndn-cxx/interest.hpp>
namespace psync {
@@ -71,40 +71,38 @@ static const uint8_t IBF[] = {
BOOST_AUTO_TEST_CASE(NameAppendAndExtract)
{
int size = 10;
const int size = 10;
IBLT iblt(size, CompressionScheme::DEFAULT);
std::string prefix = Name("/test/memphis").appendNumber(1).toUri();
uint32_t newHash = murmurHash3(11, prefix);
iblt.insert(newHash);
auto prefix = Name("/test/memphis").appendNumber(1).toUri();
auto hash = murmurHash3(11, prefix);
iblt.insert(hash);
Name ibltName("sync");
Name ibltName("/sync");
iblt.appendToName(ibltName);
IBLT rcvd(size, CompressionScheme::DEFAULT);
rcvd.initialize(ibltName.get(-1));
rcvd.initialize(ibltName.at(-1));
BOOST_CHECK_EQUAL(iblt, rcvd);
IBLT rcvdDiffSize(20, CompressionScheme::DEFAULT);
BOOST_CHECK_THROW(rcvdDiffSize.initialize(ibltName.get(-1)), IBLT::Error);
BOOST_CHECK_THROW(rcvdDiffSize.initialize(ibltName.at(-1)), IBLT::Error);
Name malformedName("test");
IBLT iblt2(size, CompressionScheme::NONE);
iblt2.insert(hash);
Name ibltName2("/sync");
iblt2.appendToName(ibltName2);
BOOST_CHECK_EQUAL_COLLECTIONS(IBF, IBF + sizeof(IBF),
ibltName2.at(-1).wireEncode().begin(),
ibltName2.at(-1).wireEncode().end());
Name malformedName("/test");
auto compressed = compress(CompressionScheme::DEFAULT,
malformedName.wireEncode().value(),
malformedName.wireEncode().value_size());
IBLT rcvdDiffSize1(size, CompressionScheme::DEFAULT);
malformedName.append(compressed->data(), compressed->size());
BOOST_CHECK_THROW(rcvdDiffSize1.initialize(malformedName.get(-1)), IBLT::Error);
IBLT iblt2(size, CompressionScheme::NONE);
iblt2.insert(newHash);
Name ibltName2("sync");
iblt2.appendToName(ibltName2);
BOOST_CHECK_EQUAL_COLLECTIONS(IBF, IBF + sizeof(IBF),
ibltName2.get(-1).wireEncode().begin(),
ibltName2.get(-1).wireEncode().end());
IBLT rcvd2(size, CompressionScheme::DEFAULT);
BOOST_CHECK_THROW(rcvd2.initialize(malformedName.at(-1)), IBLT::Error);
}
BOOST_AUTO_TEST_CASE(CopyInsertErase)
@@ -233,4 +231,4 @@ BOOST_AUTO_TEST_CASE(DifferenceBwOversizedIBFs)
BOOST_AUTO_TEST_SUITE_END()
} // namespace psync
} // namespace psync
+7 -10
View File
@@ -19,15 +19,15 @@
#include "PSync/partial-producer.hpp"
#include <boost/test/unit_test.hpp>
#include "tests/boost-test.hpp"
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace psync {
using namespace ndn;
using namespace std;
BOOST_AUTO_TEST_SUITE(TestPartialProducer)
@@ -46,12 +46,9 @@ BOOST_AUTO_TEST_CASE(RegisterPrefix)
face.processEvents(time::milliseconds(-1));
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
face.sentInterests.back();
Interest interest = *face.sentInterests.begin();
BOOST_CHECK_EQUAL(interest.getName().get(3), name::Component("register"));
name::Component test = interest.getName().get(4);
nfd::ControlParameters params(test.blockFromValue());
auto interest = face.sentInterests.front();
BOOST_CHECK_EQUAL(interest.getName().at(3), name::Component("register"));
nfd::ControlParameters params(interest.getName().at(4).blockFromValue());
BOOST_CHECK_EQUAL(params.getName(), syncPrefix);
}
@@ -144,4 +141,4 @@ BOOST_AUTO_TEST_CASE(OnSyncInterest)
BOOST_AUTO_TEST_SUITE_END()
} // namespace psync
} // namespace psync
+31 -28
View File
@@ -19,26 +19,26 @@
#include "PSync/partial-producer.hpp"
#include "PSync/consumer.hpp"
#include "unit-test-time-fixture.hpp"
#include <boost/test/unit_test.hpp>
#include "tests/boost-test.hpp"
#include "tests/unit-test-time-fixture.hpp"
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace psync {
using namespace ndn;
using namespace std;
class PartialSyncFixture : public tests::UnitTestTimeFixture
{
public:
PartialSyncFixture()
: face(io, {true, true})
, syncPrefix("psync")
, userPrefix("testUser-0")
, numHelloDataRcvd(0)
, numSyncDataRcvd(0)
: face(io, {true, true})
, syncPrefix("psync")
, userPrefix("testUser-0")
, numHelloDataRcvd(0)
, numSyncDataRcvd(0)
{
producer = make_shared<PartialProducer>(40, face, syncPrefix, userPrefix);
addUserNodes("testUser", 10);
@@ -54,16 +54,16 @@ public:
}
void
addConsumer(int id, const vector<string>& subscribeTo, bool linkToProducer = true)
addConsumer(int id, const std::vector<std::string>& subscribeTo, bool linkToProducer = true)
{
consumerFaces[id] = make_shared<util::DummyClientFace>(io, util::DummyClientFace::Options{true, true});
consumerFaces[id] = std::make_shared<util::DummyClientFace>(io, util::DummyClientFace::Options{true, true});
if (linkToProducer) {
face.linkTo(*consumerFaces[id]);
}
consumers[id] = make_shared<Consumer>(syncPrefix, *consumerFaces[id],
[&, id] (const vector<Name>& availableSubs)
consumers[id] = std::make_shared<Consumer>(syncPrefix, *consumerFaces[id],
[&, id] (const std::vector<Name>& availableSubs)
{
numHelloDataRcvd++;
BOOST_CHECK(checkSubList(availableSubs));
@@ -100,9 +100,9 @@ public:
}
bool
checkSubList(const vector<Name>& availableSubs)
checkSubList(const std::vector<Name>& availableSubs) const
{
for (const auto& prefix : producer->m_prefixes ) {
for (const auto& prefix : producer->m_prefixes) {
if (std::find(availableSubs.begin(), availableSubs.end(), prefix.first) == availableSubs.end()) {
return false;
}
@@ -151,7 +151,7 @@ BOOST_FIXTURE_TEST_SUITE(TestPartialSync, PartialSyncFixture)
BOOST_AUTO_TEST_CASE(Simple)
{
vector<string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
std::vector<std::string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
addConsumer(0, subscribeTo);
consumers[0]->sendHelloInterest();
@@ -168,7 +168,7 @@ BOOST_AUTO_TEST_CASE(Simple)
BOOST_AUTO_TEST_CASE(MissedUpdate)
{
vector<string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
std::vector<std::string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
addConsumer(0, subscribeTo);
consumers[0]->sendHelloInterest();
@@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(MissedUpdate)
BOOST_AUTO_TEST_CASE(LateSubscription)
{
vector<string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
std::vector<std::string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
addConsumer(0, subscribeTo);
consumers[0]->sendHelloInterest();
@@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(LateSubscription)
BOOST_AUTO_TEST_CASE(ConsumerSyncTimeout)
{
vector<string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
std::vector<std::string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
addConsumer(0, subscribeTo);
consumers[0]->sendHelloInterest();
@@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(ConsumerSyncTimeout)
BOOST_AUTO_TEST_CASE(MultipleConsumersWithSameSubList)
{
vector<string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
std::vector<std::string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
addConsumer(0, subscribeTo);
addConsumer(1, subscribeTo);
addConsumer(2, subscribeTo);
@@ -251,13 +251,13 @@ BOOST_AUTO_TEST_CASE(MultipleConsumersWithSameSubList)
BOOST_AUTO_TEST_CASE(MultipleConsumersWithDifferentSubList)
{
vector<string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
std::vector<std::string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
addConsumer(0, subscribeTo);
vector<string> subscribeTo1{"testUser-1", "testUser-3", "testUser-5"};
std::vector<std::string> subscribeTo1{"testUser-1", "testUser-3", "testUser-5"};
addConsumer(1, subscribeTo1);
vector<string> subscribeTo2{"testUser-2", "testUser-3"};
std::vector<std::string> subscribeTo2{"testUser-2", "testUser-3"};
addConsumer(2, subscribeTo2);
consumers[0]->sendHelloInterest();
@@ -277,7 +277,7 @@ BOOST_AUTO_TEST_CASE(MultipleConsumersWithDifferentSubList)
BOOST_AUTO_TEST_CASE(ReplicatedProducer)
{
vector<string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
std::vector<std::string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
addConsumer(0, subscribeTo);
consumers[0]->sendHelloInterest();
@@ -316,7 +316,7 @@ BOOST_AUTO_TEST_CASE(ApplicationNack)
// 50 is more than expected number of entries of 40 in the producer's IBF
addUserNodes("testUser", 50);
vector<string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
std::vector<std::string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
addConsumer(0, subscribeTo);
consumers[0]->sendHelloInterest();
@@ -354,7 +354,7 @@ BOOST_AUTO_TEST_CASE(ApplicationNack)
BOOST_AUTO_TEST_CASE(SegmentedHello)
{
vector<string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
std::vector<std::string> subscribeTo{"testUser-2", "testUser-4", "testUser-6"};
addConsumer(0, subscribeTo);
addUserNodes("testUser", 400);
@@ -364,6 +364,7 @@ BOOST_AUTO_TEST_CASE(SegmentedHello)
BOOST_CHECK_EQUAL(numHelloDataRcvd, 1);
// Simulate sending delayed interest for second segment
BOOST_REQUIRE(!face.sentData.empty());
Name dataName = face.sentData.back().getName();
face.sentData.clear();
BOOST_CHECK_EQUAL(producer->m_segmentPublisher.m_ims.size(), 2);
@@ -374,7 +375,8 @@ BOOST_AUTO_TEST_CASE(SegmentedHello)
producer->onHelloInterest(consumers[0]->m_helloInterestPrefix, Interest(dataName));
advanceClocks(ndn::time::milliseconds(10));
BOOST_CHECK_EQUAL(producer->m_segmentPublisher.m_ims.size(), 2);
BOOST_CHECK_EQUAL(face.sentData.front().getName()[-1].toSegment(), 1);
BOOST_REQUIRE(!face.sentData.empty());
BOOST_CHECK_EQUAL(face.sentData.front().getName().at(-1).toSegment(), 1);
}
BOOST_AUTO_TEST_CASE(SegmentedSync)
@@ -385,7 +387,7 @@ BOOST_AUTO_TEST_CASE(SegmentedSync)
}
addUserNodes(longNameToExceedDataSize.toUri(), 10);
vector<string> subscribeTo;
std::vector<std::string> subscribeTo;
for (int i = 1; i < 10; i++) {
subscribeTo.push_back(longNameToExceedDataSize.toUri() + "-" + to_string(i));
}
@@ -425,7 +427,8 @@ BOOST_AUTO_TEST_CASE(SegmentedSync)
producer->onSyncInterest(consumers[0]->m_syncInterestPrefix, Interest(syncInterestName));
advanceClocks(ndn::time::milliseconds(10));
BOOST_CHECK_EQUAL(producer->m_segmentPublisher.m_ims.size(), 2);
BOOST_CHECK_EQUAL(face.sentData.front().getName()[-1].toSegment(), 1);
BOOST_REQUIRE(!face.sentData.empty());
BOOST_CHECK_EQUAL(face.sentData.front().getName().at(-1).toSegment(), 1);
}
BOOST_AUTO_TEST_SUITE_END()
+4 -5
View File
@@ -20,8 +20,8 @@
#include "PSync/producer-base.hpp"
#include "PSync/detail/util.hpp"
#include <boost/test/unit_test.hpp>
#include <ndn-cxx/name.hpp>
#include "tests/boost-test.hpp"
#include <ndn-cxx/data.hpp>
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
@@ -75,10 +75,9 @@ BOOST_AUTO_TEST_CASE(ApplicationNack)
producerBase.m_syncReplyFreshness = time::milliseconds(1000);
producerBase.sendApplicationNack(Name("test"));
face.processEvents(time::milliseconds(10));
BOOST_CHECK_EQUAL(face.sentData.size(), 1);
Data data = *face.sentData.begin();
BOOST_CHECK_EQUAL(data.getContentType(), ndn::tlv::ContentType_Nack);
BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
BOOST_CHECK_EQUAL(face.sentData.front().getContentType(), ndn::tlv::ContentType_Nack);
}
BOOST_AUTO_TEST_SUITE_END()
+3 -3
View File
@@ -19,10 +19,10 @@
#include "PSync/segment-publisher.hpp"
#include "PSync/detail/state.hpp"
#include "unit-test-time-fixture.hpp"
#include <boost/test/unit_test.hpp>
#include <ndn-cxx/name.hpp>
#include "tests/boost-test.hpp"
#include "tests/unit-test-time-fixture.hpp"
#include <ndn-cxx/data.hpp>
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
+3 -3
View File
@@ -19,8 +19,8 @@
#include "PSync/detail/state.hpp"
#include <boost/test/unit_test.hpp>
#include <ndn-cxx/name.hpp>
#include "tests/boost-test.hpp"
#include <ndn-cxx/data.hpp>
namespace psync {
@@ -90,4 +90,4 @@ BOOST_AUTO_TEST_CASE(ReEncode)
BOOST_AUTO_TEST_SUITE_END()
} // namespace psync
} // namespace psync
+2 -8
View File
@@ -18,17 +18,11 @@
**/
#include "PSync/detail/util.hpp"
#include "PSync/detail/config.hpp"
#include "unit-test-time-fixture.hpp"
#include <boost/test/unit_test.hpp>
#include <iostream>
#include "tests/boost-test.hpp"
namespace psync {
using namespace ndn;
using namespace std;
BOOST_AUTO_TEST_SUITE(TestUtil)
BOOST_AUTO_TEST_CASE(Basic)
@@ -76,4 +70,4 @@ BOOST_AUTO_TEST_CASE(Basic)
BOOST_AUTO_TEST_SUITE_END()
} // namespace psync
} // namespace psync