tests: update test-publish to use new registerPrefix which takes the keyChain.
diff --git a/tests/test-publish-async.cpp b/tests/test-publish-async.cpp
index e895e88..611ae6b 100644
--- a/tests/test-publish-async.cpp
+++ b/tests/test-publish-async.cpp
@@ -18,28 +18,38 @@
class Echo {
public:
- Echo()
+ Echo(KeyChain &keyChain)
+ : keyChain_(keyChain), responseCount_(0)
{
- interestCount_ = 0;
}
+ // onInterest.
void operator()
- (const shared_ptr<const Name>& prefix, const shared_ptr<const Interest>& interest, Transport& transport) {
- ++interestCount_;
+ (const shared_ptr<const Name>& prefix, const shared_ptr<const Interest>& interest, Transport& transport)
+ {
+ ++responseCount_;
// Make and sign a Data packet.
Data data(interest->getName());
string content(string("Echo ") + interest->getName().toUri());
data.setContent((const unsigned char *)&content[0], content.size());
data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
- KeyChain::defaultSign(data);
+ keyChain_.signData(data);
Blob encodedData = data.wireEncode();
cout << "Sent content " << content << endl;
transport.send(*encodedData);
}
+
+ // onRegisterFailed.
+ void operator()(const ptr_lib::shared_ptr<const Name>& prefix)
+ {
+ ++responseCount_;
+ cout << "Register failed for prefix " << prefix->toUri() << endl;
+ }
- int interestCount_;
+ KeyChain keyChain_;
+ int responseCount_;
};
int main(int argc, char** argv)
@@ -47,14 +57,19 @@
try {
Face face("localhost");
- Echo echo;
+ shared_ptr<PrivateKeyStorage> privateKeyStorage(new PrivateKeyStorage());
+ shared_ptr<IdentityManager> identityManager(new IdentityManager(privateKeyStorage));
+ KeyChain keyChain(identityManager);
+ keyChain.setFace(&face);
+
+ Echo echo(keyChain);
Name prefix("/testecho");
cout << "Register prefix " << prefix.toUri() << endl;
- face.registerPrefix(prefix, ref(echo));
+ face.registerPrefix(prefix, ref(echo), ref(echo), keyChain, Name());
// The main event loop.
// Wait forever to receive one interest for the prefix.
- while (echo.interestCount_ < 1) {
+ while (echo.responseCount_ < 1) {
face.processEvents();
// We need to sleep for a few milliseconds so we don't use 100% of the CPU.
usleep(10000);