tests: don't use makeDummyClientFace
refs #3383
Change-Id: I2408499aeedc7addd820c90022624273b751d6a8
diff --git a/tests/unit-tests/consumer.t.cpp b/tests/unit-tests/consumer.t.cpp
index 4db7e5f..f7f39ce 100644
--- a/tests/unit-tests/consumer.t.cpp
+++ b/tests/unit-tests/consumer.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California
+ * Copyright (c) 2014-2016, Regents of the University of California
*
* This file is part of ndn-group-encrypt (Group-based Encryption Protocol for NDN).
* See AUTHORS.md for complete list of ndn-group-encrypt authors and contributors.
@@ -57,8 +57,8 @@
public:
ConsumerFixture()
: tmpPath(boost::filesystem::path(TMP_TESTS_PATH))
- , face1(util::makeDummyClientFace(io, {true, true}))
- , face2(util::makeDummyClientFace(io, {true, true}))
+ , face1(io, keyChain, {true, true})
+ , face2(io, keyChain, {true, true})
, readInterestOffset1(0)
, readDataOffset1(0)
, readInterestOffset2(0)
@@ -131,10 +131,10 @@
{
bool hasPassed = false;
- checkFace(face1->sentInterests, readInterestOffset1, *face2, hasPassed);
- checkFace(face1->sentDatas, readDataOffset1, *face2, hasPassed);
- checkFace(face2->sentInterests, readInterestOffset2, *face1, hasPassed);
- checkFace(face2->sentDatas, readDataOffset2, *face1, hasPassed);
+ checkFace(face1.sentInterests, readInterestOffset1, face2, hasPassed);
+ checkFace(face1.sentData, readDataOffset1, face2, hasPassed);
+ checkFace(face2.sentInterests, readInterestOffset2, face1, hasPassed);
+ checkFace(face2.sentData, readDataOffset2, face1, hasPassed);
return hasPassed;
}
@@ -156,8 +156,8 @@
public:
boost::filesystem::path tmpPath;
- shared_ptr<util::DummyClientFace> face1;
- shared_ptr<util::DummyClientFace> face2;
+ util::DummyClientFace face1;
+ util::DummyClientFace face2;
size_t readInterestOffset1;
size_t readDataOffset1;
@@ -197,7 +197,7 @@
auto contentData = createEncryptedContent();
// create consumer
- Consumer consumer(*face1, Name("/Group"), Name("/U"), dbDir);
+ Consumer consumer(face1, Name("/Group"), Name("/U"), dbDir);
// decrypt
consumer.decrypt(cKeyData->getContent().blockFromValue(),
@@ -236,27 +236,27 @@
Name prefix("/Prefix");
// prepare face1
- face1->setInterestFilter(prefix,
- [&] (const InterestFilter&, const Interest& i) {
- if (i.matchesData(*contentData)) {
- contentCount = 1;
- face1->put(*contentData);
- return;
- }
- if (i.matchesData(*cKeyData)) {
- cKeyCount = 1;
- face1->put(*cKeyData);
- return;
- }
- if (i.matchesData(*dKeyData)) {
- dKeyCount = 1;
- face1->put(*dKeyData);
- return;
- }
- return;
- },
- RegisterPrefixSuccessCallback(),
- [] (const Name&, const std::string& e) { });
+ face1.setInterestFilter(prefix,
+ [&] (const InterestFilter&, const Interest& i) {
+ if (i.matchesData(*contentData)) {
+ contentCount = 1;
+ face1.put(*contentData);
+ return;
+ }
+ if (i.matchesData(*cKeyData)) {
+ cKeyCount = 1;
+ face1.put(*cKeyData);
+ return;
+ }
+ if (i.matchesData(*dKeyData)) {
+ dKeyCount = 1;
+ face1.put(*dKeyData);
+ return;
+ }
+ return;
+ },
+ RegisterPrefixSuccessCallback(),
+ [] (const Name&, const std::string& e) { });
do {
advanceClocks(time::milliseconds(10), 20);
@@ -265,7 +265,7 @@
// create consumer
std::string dbDir = tmpPath.c_str();
dbDir += "/test.db";
- Consumer consumer(*face2, groupName, uName, dbDir);
+ Consumer consumer(face2, groupName, uName, dbDir);
consumer.addDecryptionKey(uKeyName, fixtureUDKeyBuf);
int finalCount = 0;
diff --git a/tests/unit-tests/producer.t.cpp b/tests/unit-tests/producer.t.cpp
index a5453e5..6367608 100755
--- a/tests/unit-tests/producer.t.cpp
+++ b/tests/unit-tests/producer.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California
+ * Copyright (c) 2014-2016, Regents of the University of California
*
* This file is part of ndn-group-encrypt (Group-based Encryption Protocol for NDN).
* See AUTHORS.md for complete list of ndn-group-encrypt authors and contributors.
@@ -47,8 +47,8 @@
public:
ProducerFixture()
: tmpPath(boost::filesystem::path(TMP_TESTS_PATH))
- , face1(util::makeDummyClientFace(io, {true, true}))
- , face2(util::makeDummyClientFace(io, {true, true}))
+ , face1(io, keyChain, {true, true})
+ , face2(io, keyChain, {true, true})
, readInterestOffset1(0)
, readDataOffset1(0)
, readInterestOffset2(0)
@@ -84,10 +84,10 @@
{
bool hasPassed = false;
- checkFace(face1->sentInterests, readInterestOffset1, *face2, hasPassed);
- checkFace(face1->sentDatas, readDataOffset1, *face2, hasPassed);
- checkFace(face2->sentInterests, readInterestOffset2, *face1, hasPassed);
- checkFace(face2->sentDatas, readDataOffset2, *face1, hasPassed);
+ checkFace(face1.sentInterests, readInterestOffset1, face2, hasPassed);
+ checkFace(face1.sentData, readDataOffset1, face2, hasPassed);
+ checkFace(face2.sentInterests, readInterestOffset2, face1, hasPassed);
+ checkFace(face2.sentData, readDataOffset2, face1, hasPassed);
return hasPassed;
}
@@ -109,8 +109,8 @@
public:
boost::filesystem::path tmpPath;
- shared_ptr<util::DummyClientFace> face1;
- shared_ptr<util::DummyClientFace> face2;
+ util::DummyClientFace face1;
+ util::DummyClientFace face2;
size_t readInterestOffset1;
size_t readDataOffset1;
@@ -155,17 +155,17 @@
expectedInterest = expectedInterest.getPrefix(-2).append(NAME_COMPONENT_E_KEY);
}
- face2->setInterestFilter(prefix,
- [&] (const InterestFilter&, const Interest& i) {
- Name interestName = i.getName();
- interestName.append(timeMarker);
- BOOST_REQUIRE_EQUAL(encryptionKeys.find(interestName) !=
- encryptionKeys.end(), true);
- face2->put(*(encryptionKeys[interestName]));
- return;
- },
- RegisterPrefixSuccessCallback(),
- [] (const Name&, const std::string& e) { });
+ face2.setInterestFilter(prefix,
+ [&] (const InterestFilter&, const Interest& i) {
+ Name interestName = i.getName();
+ interestName.append(timeMarker);
+ BOOST_REQUIRE_EQUAL(encryptionKeys.find(interestName) !=
+ encryptionKeys.end(), true);
+ face2.put(*(encryptionKeys[interestName]));
+ return;
+ },
+ RegisterPrefixSuccessCallback(),
+ [] (const Name&, const std::string& e) { });
do {
advanceClocks(time::milliseconds(10), 20);
@@ -175,7 +175,7 @@
Verify that content key is correctly encrypted for each domain, and the
produce method encrypts provided data with the same content key.
*/
- Producer producer(prefix, suffix, *face1, dbDir);
+ Producer producer(prefix, suffix, face1, dbDir);
ProducerDB testDb(dbDir);
Buffer contentKey;
@@ -296,32 +296,32 @@
createEncryptionKey(expectedInterest, timeMarkerThirdHop);
size_t requestCount = 0;
- face2->setInterestFilter(prefix,
- [&] (const InterestFilter&, const Interest& i) {
- BOOST_REQUIRE_EQUAL(i.getName(), expectedInterest);
- Name interestName = i.getName();
- switch(requestCount) {
- case 0:
- interestName.append(timeMarkerFirstHop);
- break;
+ face2.setInterestFilter(prefix,
+ [&] (const InterestFilter&, const Interest& i) {
+ BOOST_REQUIRE_EQUAL(i.getName(), expectedInterest);
+ Name interestName = i.getName();
+ switch(requestCount) {
+ case 0:
+ interestName.append(timeMarkerFirstHop);
+ break;
- case 1:
- interestName.append(timeMarkerSecondHop);
- break;
+ case 1:
+ interestName.append(timeMarkerSecondHop);
+ break;
- case 2:
- interestName.append(timeMarkerThirdHop);
- break;
+ case 2:
+ interestName.append(timeMarkerThirdHop);
+ break;
- default:
- break;
- }
- face2->put(*(encryptionKeys[interestName]));
- requestCount++;
- return;
- },
- RegisterPrefixSuccessCallback(),
- [] (const Name&, const std::string& e) { });
+ default:
+ break;
+ }
+ face2.put(*(encryptionKeys[interestName]));
+ requestCount++;
+ return;
+ },
+ RegisterPrefixSuccessCallback(),
+ [] (const Name&, const std::string& e) { });
do {
advanceClocks(time::milliseconds(10), 20);
@@ -331,7 +331,7 @@
Verify that if a key is found, but not within the right timeslot, the search
is refined until a valid timeslot is found.
*/
- Producer producer(prefix, suffix, *face1, dbDir);
+ Producer producer(prefix, suffix, face1, dbDir);
producer.createContentKey(testTime,
[&](const std::vector<Data>& result){
BOOST_CHECK_EQUAL(requestCount, 3);
@@ -365,14 +365,14 @@
time::system_clock::TimePoint testTime = time::fromIsoString("20150101T100001");
size_t timeoutCount = 0;
- face2->setInterestFilter(prefix,
- [&] (const InterestFilter&, const Interest& i) {
- BOOST_CHECK_EQUAL(i.getName(), expectedInterest);
- timeoutCount++;
- return;
- },
- RegisterPrefixSuccessCallback(),
- [] (const Name&, const std::string& e) { });
+ face2.setInterestFilter(prefix,
+ [&] (const InterestFilter&, const Interest& i) {
+ BOOST_CHECK_EQUAL(i.getName(), expectedInterest);
+ timeoutCount++;
+ return;
+ },
+ RegisterPrefixSuccessCallback(),
+ [] (const Name&, const std::string& e) { });
do {
advanceClocks(time::milliseconds(10), 20);
@@ -382,7 +382,7 @@
Verify that if no response is received, the producer appropriately times out.
The result vector should not contain elements that have timed out.
*/
- Producer producer(prefix, suffix, *face1, dbDir);
+ Producer producer(prefix, suffix, face1, dbDir);
producer.createContentKey(testTime,
[&](const std::vector<Data>& result){
BOOST_CHECK_EQUAL(timeoutCount, 4);