tests: move integrated tests into unit tests

Change-Id: Ifed29e53091ca430582b1c2e7f3514e02d7c8d14
diff --git a/src/socket.cpp b/src/socket.cpp
index 695f758..7356f73 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -30,8 +30,8 @@
 
 namespace chronosync {
 
-const ndn::Name Socket::DEFAULT_PREFIX;
 const ndn::Name Socket::DEFAULT_NAME;
+const ndn::Name Socket::DEFAULT_PREFIX;
 const ndn::shared_ptr<ndn::Validator> Socket::DEFAULT_VALIDATOR;
 
 Socket::Socket(const Name& syncPrefix,
@@ -46,12 +46,30 @@
   , m_signingId(signingId)
   , m_validator(validator)
 {
+  if (m_userPrefix != DEFAULT_NAME)
+    m_registeredPrefixList[m_userPrefix] =
+      m_face.setInterestFilter(m_userPrefix,
+                               bind(&Socket::onInterest, this, _1, _2),
+                               [] (const Name& prefix, const std::string& msg) {});
 }
 
 void
 Socket::addSyncNode(const Name& prefix, const Name& signingId)
 {
+  if (prefix == DEFAULT_NAME)
+    return;
+
+  auto itr = m_registeredPrefixList.find(prefix);
+  if (itr != m_registeredPrefixList.end())
+    return;
+
+  if (m_userPrefix == DEFAULT_NAME)
+    m_userPrefix = prefix;
   m_logic.addUserNode(prefix, signingId);
+  m_registeredPrefixList[prefix] =
+    m_face.setInterestFilter(prefix,
+                             bind(&Socket::onInterest, this, _1, _2),
+                             [] (const Name& prefix, const std::string& msg) {});
 }
 
 void
@@ -79,7 +97,7 @@
   else
     m_keyChain.signByIdentity(*data, m_signingId);
 
-  m_face.put(*data);
+  m_ims.insert(*data);
 
   m_logic.updateSeqNo(newSeq, prefix);
 }
@@ -126,6 +144,15 @@
 }
 
 void
+Socket::onInterest(const Name& prefix, const Interest& interest)
+{
+  shared_ptr<const Data>data = m_ims.find(interest);
+  if (static_cast<bool>(data)) {
+    m_face.put(*data);
+  }
+}
+
+void
 Socket::onData(const Interest& interest, Data& data,
                const ndn::OnDataValidated& onValidated,
                const ndn::OnDataValidationFailed& onFailed)