tests: migrate from DummyForwarder to DummyClientFace::linkTo()
Change-Id: I8d88ffd632468965689b44026ebe34a36f32e7a2
diff --git a/tests/unit/encryptor.t.cpp b/tests/unit/encryptor.t.cpp
index dcbf579..9439fcc 100644
--- a/tests/unit/encryptor.t.cpp
+++ b/tests/unit/encryptor.t.cpp
@@ -20,11 +20,11 @@
#include "encryptor.hpp"
#include "tests/boost-test.hpp"
-#include "tests/dummy-forwarder.hpp"
#include "tests/io-key-chain-fixture.hpp"
#include "tests/unit/static-data.hpp"
#include <iostream>
+#include <ndn-cxx/util/dummy-client-face.hpp>
#include <ndn-cxx/util/string-helper.hpp>
namespace ndn {
@@ -35,8 +35,6 @@
{
public:
EncryptorStaticDataEnvironment(bool shouldPublishData)
- : fw(m_io, m_keyChain)
- , imsFace(static_cast<util::DummyClientFace&>(fw.addFace()))
{
if (shouldPublishData) {
publishData();
@@ -45,14 +43,14 @@
auto serveFromIms = [this] (const Name&, const Interest& interest) {
auto data = m_ims.find(interest);
if (data != nullptr) {
- imsFace.put(*data);
+ m_imsFace.put(*data);
}
};
- imsFace.setInterestFilter("/", serveFromIms, [] (auto...) {});
+ m_imsFace.setInterestFilter("/", serveFromIms, [] (auto...) {});
advanceClocks(1_ms, 10);
- imsFace.sentData.clear();
- imsFace.sentInterests.clear();
+ m_imsFace.sentData.clear();
+ m_imsFace.sentInterests.clear();
}
void
@@ -65,9 +63,10 @@
advanceClocks(1_ms, 10);
}
-public:
- DummyForwarder fw;
- util::DummyClientFace& imsFace;
+protected:
+ util::DummyClientFace m_imsFace{m_io, m_keyChain, {true, true}};
+
+private:
InMemoryStoragePersistent m_ims;
};
@@ -77,18 +76,19 @@
public:
EncryptorFixture()
: EncryptorStaticDataEnvironment(shouldPublishData)
- , face(static_cast<util::DummyClientFace&>(fw.addFace()))
+ , face(m_io, m_keyChain, {true, true})
, encryptor("/access/policy/identity/NAC/dataset", "/some/ck/prefix", signingWithSha256(),
[=] (const ErrorCode& code, const std::string& error) {
onFailure(code, error);
},
validator, m_keyChain, face)
{
+ face.linkTo(m_imsFace);
advanceClocks(1_ms, 10);
}
public:
- util::DummyClientFace& face;
+ util::DummyClientFace face;
ValidatorNull validator;
Encryptor encryptor;
util::Signal<EncryptorFixture, ErrorCode, std::string> onFailure;
@@ -121,7 +121,7 @@
BOOST_CHECK_EQUAL(face.sentInterests.at(0).getName().getPrefix(6),
Name("/access/policy/identity/NAC/dataset/KEK"));
- auto kek = imsFace.sentData.at(0);
+ auto kek = m_imsFace.sentData.at(0);
BOOST_CHECK_EQUAL(kek.getName().getPrefix(6), Name("/access/policy/identity/NAC/dataset/KEK"));
BOOST_CHECK_EQUAL(kek.getName().size(), 7);
@@ -155,15 +155,15 @@
BOOST_CHECK_EQUAL(face.sentInterests.at(0).getName().getPrefix(6), Name("/access/policy/identity/NAC/dataset/KEK"));
// and failed
- BOOST_CHECK_EQUAL(imsFace.sentData.size(), 0);
+ BOOST_CHECK_EQUAL(m_imsFace.sentData.size(), 0);
advanceClocks(1_s, 13); // 4_s default interest lifetime x 3
BOOST_CHECK_EQUAL(nErrors, 1);
- BOOST_CHECK_EQUAL(imsFace.sentData.size(), 0);
+ BOOST_CHECK_EQUAL(m_imsFace.sentData.size(), 0);
advanceClocks(1_s, 730); // 60 seconds between attempts + ~12 seconds for each attempt
BOOST_CHECK_EQUAL(nErrors, 11);
- BOOST_CHECK_EQUAL(imsFace.sentData.size(), 0);
+ BOOST_CHECK_EQUAL(m_imsFace.sentData.size(), 0);
// check recovery
@@ -171,7 +171,7 @@
advanceClocks(1_s, 73);
- auto kek = imsFace.sentData.at(0);
+ auto kek = m_imsFace.sentData.at(0);
BOOST_CHECK_EQUAL(kek.getName().getPrefix(6), Name("/access/policy/identity/NAC/dataset/KEK"));
BOOST_CHECK_EQUAL(kek.getName().size(), 7);
}