poke: don't respond if the Interest cannot be satisfied

Change-Id: I616e974ff041a4a2c9fd738e98c83c28a21a47de
diff --git a/tests/peek/ndnpoke.t.cpp b/tests/peek/ndnpoke.t.cpp
index cdcd262..9bf51cf 100644
--- a/tests/peek/ndnpoke.t.cpp
+++ b/tests/peek/ndnpoke.t.cpp
@@ -82,7 +82,6 @@
 
   face.receive(*makeInterest("/poke/test"));
   this->advanceClocks(io, 1_ms, 10);
-  io.run();
 
   BOOST_CHECK(poke->getResult() == NdnPoke::Result::DATA_SENT);
   BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
@@ -98,6 +97,27 @@
   BOOST_CHECK_EQUAL(face.sentInterests.back().getName().getPrefix(4), "/localhost/nfd/rib/unregister");
 }
 
+BOOST_AUTO_TEST_CASE(NoMatch)
+{
+  initialize();
+
+  poke->start();
+  this->advanceClocks(io, 1_ms, 10);
+
+  face.receive(*makeInterest("/poke/test/foo"));
+  this->advanceClocks(io, 1_ms, 10);
+
+  BOOST_CHECK(poke->getResult() == NdnPoke::Result::UNKNOWN);
+  BOOST_CHECK_EQUAL(face.sentData.size(), 0);
+
+  face.receive(*makeInterest("/poke/test"));
+  this->advanceClocks(io, 1_ms, 10);
+
+  BOOST_CHECK(poke->getResult() == NdnPoke::Result::DATA_SENT);
+  BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
+  BOOST_CHECK_EQUAL(face.sentData.back().getName(), "/poke/test");
+}
+
 BOOST_AUTO_TEST_CASE(FreshnessPeriod)
 {
   auto options = makeDefaultOptions();
@@ -109,7 +129,6 @@
 
   face.receive(*makeInterest("/poke/test"));
   this->advanceClocks(io, 1_ms, 10);
-  io.run();
 
   BOOST_CHECK(poke->getResult() == NdnPoke::Result::DATA_SENT);
   BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
@@ -131,7 +150,6 @@
 
   face.receive(*makeInterest(options.name));
   this->advanceClocks(io, 1_ms, 10);
-  io.run();
 
   BOOST_CHECK(poke->getResult() == NdnPoke::Result::DATA_SENT);
   BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
@@ -153,7 +171,6 @@
 
   face.receive(*makeInterest("/poke/test"));
   this->advanceClocks(io, 1_ms, 10);
-  io.run();
 
   BOOST_CHECK(poke->getResult() == NdnPoke::Result::DATA_SENT);
   BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
diff --git a/tools/peek/ndnpoke/ndnpoke.cpp b/tools/peek/ndnpoke/ndnpoke.cpp
index 4db5ebf..4cbe0e8 100644
--- a/tools/peek/ndnpoke/ndnpoke.cpp
+++ b/tools/peek/ndnpoke/ndnpoke.cpp
@@ -94,9 +94,14 @@
     std::cerr << "INTEREST: " << interest << std::endl;
   }
 
-  m_timeoutEvent.cancel();
-  m_registeredPrefix.cancel();
-  sendData(data);
+  if (interest.matchesData(data)) {
+    m_timeoutEvent.cancel();
+    m_registeredPrefix.cancel();
+    sendData(data);
+  }
+  else if (m_options.isVerbose) {
+    std::cerr << "Interest cannot be satisfied" << std::endl;
+  }
 }
 
 void