test: Disable test cases

All test cases are disabled temporarily. We wil fix them one-by-one in later commits.

Change-Id: I16c20fa86cd9472f48125210b89805c865af79e1
diff --git a/tests/unit-tests/test-data-fetch-and-publish.cpp.outdated b/tests/unit-tests/test-data-fetch-and-publish.cpp.outdated
new file mode 100644
index 0000000..583717c
--- /dev/null
+++ b/tests/unit-tests/test-data-fetch-and-publish.cpp.outdated
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+#include <boost/test/unit_test.hpp>
+#include <boost/test/output_test_stream.hpp>
+#include <map>
+using boost::test_tools::output_test_stream;
+
+#include <boost/make_shared.hpp>
+
+#include "sync-ccnx-wrapper.h"
+#include "sync-app-data-fetch.h"
+#include "sync-app-data-publish.h"
+
+using namespace Sync;
+using namespace std;
+using namespace boost;
+
+class TestStructApp {
+public:
+  map<string, string> data;
+  void set(string str1, string str2) {
+    data.insert(make_pair(str1, str2));
+  }
+
+  void erase(string str1, string str2) {
+    data.erase(str1);
+  }
+
+  string toString(){
+    map<string, string>::iterator it = data.begin();
+    string str = "";
+    for (; it != data.end(); ++it){
+      str += "<";
+      str += it->first;
+      str += "|";
+      str += it->second;
+      str += ">";
+    }
+    return str;
+  }
+
+};
+
+BOOST_AUTO_TEST_CASE (AppDataPublishAndFetchTest)
+{
+  TestStructApp foo;
+  TestStructApp bar;
+
+  string interest = "/april/fool";
+  string seq[5] = {"0", "1", "2", "3", "4" };
+  string str[5] = {"panda", "express", "tastes", "so", "good"};
+
+  for (int i = 0; i < 5; i++) {
+    foo.set(interest + "/" + "0/" + seq[i], str[i]);
+  }
+
+  boost::function<void (string, string)> setFunc =
+    bind(&TestStructApp::set, &bar, _1, _2);
+
+  shared_ptr<CcnxWrapper> handle(new CcnxWrapper());
+
+  AppDataFetch fetcher(handle, setFunc);
+  AppDataPublish publisher(handle);
+
+  for (int i = 1; i <= 5; i++) {
+    publisher.publishData(interest, 0, str[i - 1], 5);
+  }
+
+  BOOST_CHECK_EQUAL(publisher.getNextSeq(interest, 0), 5);
+  BOOST_CHECK_EQUAL(publisher.getRecentData(interest, 0), str[4]);
+
+  fetcher.onUpdate (interest, SeqNo (0,4), SeqNo (0,-1));
+  // give time for ccnd to react
+  sleep(1);
+  BOOST_CHECK_EQUAL(foo.toString(), bar.toString());
+
+
+  boost::function<void (string, string)> eraseFunc =
+    bind(&TestStructApp::erase, &bar, _1, _2);
+  fetcher.setDataCallback(eraseFunc);
+
+  fetcher.onUpdate (interest, SeqNo (0,4), SeqNo (0,-1));
+  // give time for ccnd to react
+  sleep(1);
+  TestStructApp poo;
+
+  BOOST_CHECK_EQUAL(poo.toString(), bar.toString());
+
+}
+*/
diff --git a/tests/unit-tests/test-digest.cpp.outdated b/tests/unit-tests/test-digest.cpp.outdated
new file mode 100644
index 0000000..cbc5ced
--- /dev/null
+++ b/tests/unit-tests/test-digest.cpp.outdated
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/output_test_stream.hpp>
+using boost::test_tools::output_test_stream;
+
+#include "sync-digest.h"
+#include <iostream>
+#include <sstream>
+
+using namespace Sync;
+using namespace Sync::Error;
+using namespace std;
+using namespace boost;
+
+BOOST_AUTO_TEST_SUITE(DigestTests)
+
+BOOST_AUTO_TEST_CASE (BasicTest)
+{
+  Digest d0;
+  BOOST_REQUIRE (d0.empty ());
+}
+
+BOOST_AUTO_TEST_CASE (DigestGenerationTest)
+{
+  Digest d1;
+  BOOST_CHECK_NO_THROW (d1 << "1\n");
+
+  // without explicit finalizing, Digest will not be complete and printing out will cause assert
+  BOOST_CHECK (d1.empty ());
+
+  // fix hash
+  d1.finalize ();
+
+  BOOST_CHECK_NO_THROW (d1.getHash ());
+  BOOST_CHECK (!d1.empty ());
+  BOOST_CHECK (d1 == d1);
+
+  BOOST_CHECK_THROW (d1 << "2", DigestCalculationError);
+
+  output_test_stream output;
+  BOOST_CHECK_NO_THROW (output << d1);
+  // BOOST_CHECK (output.check_length (40, false) );
+  // BOOST_CHECK (output.is_equal ("e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e", true)); // for sha1
+	BOOST_CHECK (output.check_length (64, false) );
+	BOOST_CHECK (output.is_equal ("4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865", true)); // for sha256
+}
+
+BOOST_AUTO_TEST_CASE (DigestComparison)
+{
+  Digest d1;
+  BOOST_CHECK_NO_THROW (d1 << "1\n");
+  // BOOST_CHECK_THROW (d1 == d1, DigestCalculationError);
+  BOOST_CHECK_NO_THROW (d1.finalize ());
+  BOOST_CHECK (d1 == d1);
+
+  Digest d2;
+  BOOST_CHECK_NO_THROW (d2 << "2\n");
+  BOOST_CHECK_NO_THROW (d2.finalize ());
+  BOOST_CHECK (d1 != d2);
+
+  Digest d3;
+  // istringstream is (string ("e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e")); // real sha-1 for "1\n"
+	istringstream is (string ("4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865")); // real sha256 for "1\n"
+  BOOST_CHECK_NO_THROW (is >> d3);
+  BOOST_CHECK (!d3.empty ());
+  BOOST_CHECK (d3 == d1);
+  BOOST_CHECK (d3 != d2);
+
+  istringstream is2 (string ("25fa44f2b31c1fb553b6021e7360d07d5d91ff5e")); // some fake hash
+  BOOST_CHECK_THROW (is2 >> d3, DigestCalculationError); // >> can be used only once
+
+  Digest d4;
+  BOOST_CHECK_THROW (is2 >> d4, DigestCalculationError); // is2 is now empty. empty >> is not allowed
+
+  istringstream is3 (string ("25fa44f2b31c1fb553b6021e7360d07d5d91ff5e")); // some fake hash
+  BOOST_CHECK_NO_THROW (is3 >> d4);
+
+  BOOST_CHECK (d4 != d1);
+  BOOST_CHECK (d4 != d2);
+  BOOST_CHECK (d4 != d3);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/unit-tests/test-empty.cpp b/tests/unit-tests/test-empty.cpp
new file mode 100644
index 0000000..e4abe0c
--- /dev/null
+++ b/tests/unit-tests/test-empty.cpp
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "boost-test.hpp"
+
+BOOST_AUTO_TEST_CASE(EmptyTest)
+{
+
+}
diff --git a/tests/unit-tests/test-interest-table.cpp.outdated b/tests/unit-tests/test-interest-table.cpp.outdated
new file mode 100644
index 0000000..2db3eed
--- /dev/null
+++ b/tests/unit-tests/test-interest-table.cpp.outdated
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/output_test_stream.hpp>
+#include <map>
+using boost::test_tools::output_test_stream;
+
+#include <boost/make_shared.hpp>
+
+#include "sync-interest-table.h"
+
+using namespace Sync;
+using namespace std;
+using namespace boost;
+
+BOOST_AUTO_TEST_CASE (InterestTableTest)
+{
+  // Alex: test is broken due to changes in SyncInterestTable
+  // cerr << "InterestTableTest is broken" << endl;
+
+  // SyncInterestTable *table = 0;
+  // BOOST_CHECK_NO_THROW (table = new SyncInterestTable ());
+
+  // BOOST_CHECK_NO_THROW (delete table);
+}
diff --git a/tests/unit-tests/test-pit.cpp.outdated b/tests/unit-tests/test-pit.cpp.outdated
new file mode 100644
index 0000000..39b36b9
--- /dev/null
+++ b/tests/unit-tests/test-pit.cpp.outdated
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/output_test_stream.hpp>
+using boost::test_tools::output_test_stream;
+#include <vector>
+
+#include <boost/make_shared.hpp>
+
+#include "sync-interest-table.h"
+#include "sync-logging.h"
+
+using namespace Sync;
+using namespace std;
+using namespace boost;
+
+// string sitToString(SyncInterestTable *sit) {
+//   vector<string> ent = sit->fetchAll();
+//   sort(ent.begin(), ent.end());
+//   string str = "";
+//   while(!ent.empty()){
+//     str += ent.back();
+//     ent.pop_back();
+//   }
+//   return str;
+// }
+
+BOOST_AUTO_TEST_CASE (SyncInterestTableTest)
+{
+  cerr << "SyncInterestTableTest is broken" << endl;
+
+  // INIT_LOGGERS ();
+  // INIT_LOGGER ("Test.Pit");
+
+  // SyncInterestTable sit;
+  // sit.insert("/ucla.edu/0");
+  // sit.insert("/ucla.edu/1");
+  // string str = sitToString(&sit);
+  // BOOST_CHECK_EQUAL(str, "/ucla.edu/1/ucla.edu/0");
+
+  // str = sitToString(&sit);
+  // BOOST_CHECK_EQUAL(str, "");
+
+  // _LOG_DEBUG ("Adding 0 and 1");
+  // sit.insert("/ucla.edu/0");
+  // sit.insert("/ucla.edu/1");
+  // sleep(2);
+  // _LOG_DEBUG ("Adding 0 and 2");
+  // sit.insert("/ucla.edu/0");
+  // sit.insert("/ucla.edu/2");
+  // sleep(3);
+  // _LOG_DEBUG ("Checking");
+  // str = sitToString(&sit);
+  // BOOST_CHECK_EQUAL(str, "/ucla.edu/2/ucla.edu/0");
+}
diff --git a/tests/unit-tests/test-scheduler.cc.tmp b/tests/unit-tests/test-scheduler.cc.tmp
new file mode 100644
index 0000000..2a53a22
--- /dev/null
+++ b/tests/unit-tests/test-scheduler.cc.tmp
@@ -0,0 +1,175 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/output_test_stream.hpp>
+#include <map>
+using boost::test_tools::output_test_stream;
+
+#include <boost/make_shared.hpp>
+#include "sync-scheduler.h"
+#include "sync-logic.h"
+
+using namespace Sync;
+using namespace std;
+using namespace boost;
+
+
+
+// void funcUpdate (const std::string &, const SeqNo &newSeq, const SeqNo &oldSeq)
+// {
+//   cout << "funcUpdate\n";
+// }
+
+// void funcRemove (const std::string &)
+// {
+//   cout << "funcRemove\n";
+// }
+
+enum SCHEDULE_LABELS
+  {
+    TEST_LABEL,
+    ANOTHER_LABEL
+  };
+
+struct SchedulerFixture
+{
+  SchedulerFixture ()
+    : counter (0)
+  {}
+
+  int counter;
+
+  Scheduler *scheduler;
+
+  void everySecond ()
+  {
+    // cout << "." << flush;
+    counter ++;
+
+    if (counter < 9)
+    scheduler->schedule (boost::posix_time::milliseconds (100),
+                         boost::bind (&SchedulerFixture::everySecond, this),
+                         TEST_LABEL);
+  }
+
+  void setCounterFive ()
+  {
+    counter = 5;
+  }
+
+  void setCounterThree ()
+  {
+    counter = 3;
+  }
+};
+
+
+#ifdef _DEBUG
+
+BOOST_FIXTURE_TEST_SUITE (SchedulerTestSuite, SchedulerFixture)
+
+BOOST_AUTO_TEST_CASE (BasicTest)
+{
+  BOOST_CHECK_NO_THROW (scheduler = new Scheduler ());
+
+  scheduler->schedule (posix_time::milliseconds (100),
+                       bind (&SchedulerFixture::everySecond, this),
+                       TEST_LABEL);
+
+  sleep (1);
+  // cout << counter << endl;
+  BOOST_CHECK_EQUAL (counter, 9); // generally, should be 9
+
+  scheduler->schedule (posix_time::seconds (2),
+		       bind (&SchedulerFixture::setCounterFive, this),
+                       TEST_LABEL);
+
+  this_thread::sleep (posix_time::milliseconds (400)); // just in case
+
+  scheduler->schedule (posix_time::milliseconds (600),
+		       bind (&SchedulerFixture::setCounterThree, this),
+                       TEST_LABEL);
+
+  this_thread::sleep (posix_time::milliseconds (500));
+  BOOST_CHECK_EQUAL (counter, 9); // still 9
+
+  this_thread::sleep (posix_time::milliseconds (200));
+  BOOST_CHECK_EQUAL (counter, 3);
+
+  this_thread::sleep (posix_time::milliseconds (1000));
+  BOOST_CHECK_EQUAL (counter, 5);
+
+  scheduler->schedule (posix_time::milliseconds (100),
+		       bind (&SchedulerFixture::setCounterThree, this),
+                       ANOTHER_LABEL);
+  this_thread::sleep (posix_time::milliseconds (50));
+  scheduler->cancel (ANOTHER_LABEL);
+  this_thread::sleep (posix_time::milliseconds (150));
+  BOOST_CHECK_EQUAL (counter, 5);
+
+  BOOST_CHECK_NO_THROW (delete scheduler);
+}
+
+BOOST_AUTO_TEST_SUITE_END ()
+
+
+void funcUpdate( const std::string &/*prefix*/, const SeqNo &/*newSeq*/, const SeqNo &/*oldSeq*/ )
+{
+}
+
+void funcPass( const std::vector<MissingDataInfo> &v)
+{
+}
+
+void funcRemove( const std::string &/*prefix*/ )
+{
+}
+
+BOOST_AUTO_TEST_CASE (SyncLogicSchedulerTest)
+{
+  SyncLogic *logic = 0;
+  BOOST_CHECK_NO_THROW (logic = new SyncLogic ("/prefix", funcPass, funcRemove));
+  this_thread::sleep (posix_time::milliseconds (100));
+
+  Scheduler &scheduler = logic->getScheduler ();
+  BOOST_CHECK_EQUAL (scheduler.getEventsSize (), 1);
+
+  BOOST_CHECK_NO_THROW (logic->respondSyncInterest ("/prefix/e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e"));
+  BOOST_CHECK_EQUAL (scheduler.getEventsSize (), 2);
+
+  this_thread::sleep (posix_time::milliseconds (100)); // max waiting time
+  BOOST_CHECK_EQUAL (scheduler.getEventsSize (), 1);
+
+  BOOST_CHECK_NO_THROW (logic->respondSyncInterest ("/prefix/e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e"));
+  BOOST_CHECK_NO_THROW (logic->respondSyncInterest ("/prefix/e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e"));
+  BOOST_CHECK_NO_THROW (logic->respondSyncInterest ("/prefix/e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e"));
+  BOOST_CHECK_NO_THROW (logic->respondSyncInterest ("/prefix/e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e"));
+  BOOST_CHECK_EQUAL (scheduler.getEventsSize (), 5);
+
+  this_thread::sleep (posix_time::milliseconds (19)); // min waiting time is 20
+  BOOST_CHECK_EQUAL (scheduler.getEventsSize (), 5);
+
+  this_thread::sleep (posix_time::milliseconds (100)); // max waiting time
+  BOOST_CHECK_EQUAL (scheduler.getEventsSize (), 1);
+
+  BOOST_CHECK_NO_THROW (delete logic);
+}
+
+#endif
diff --git a/tests/unit-tests/test-socket.cpp.outdated b/tests/unit-tests/test-socket.cpp.outdated
new file mode 100644
index 0000000..d04ded9
--- /dev/null
+++ b/tests/unit-tests/test-socket.cpp.outdated
@@ -0,0 +1,619 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/output_test_stream.hpp>
+using boost::test_tools::output_test_stream;
+
+#include <boost/make_shared.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+
+#include "sync-logging.h"
+#include "sync-socket.h"
+#include "sync-validator.h"
+#include <ndn-cxx/security/validator-null.hpp>
+
+extern "C" {
+#include <unistd.h>
+}
+
+using namespace Sync;
+using namespace std;
+using namespace boost;
+
+INIT_LOGGER ("Test.AppSocket");
+
+#define PRINT
+// std::cout << "Line: " << __LINE__ << std::endl;
+
+class TestSocketApp {
+public:
+  TestSocketApp()
+    : sum(0)
+  {}
+
+  map<ndn::Name, string> data;
+  void set(const ndn::shared_ptr<const ndn::Data>& dataPacket) {
+    // _LOG_FUNCTION (this << ", " << str1);
+    ndn::Name dataName(dataPacket->getName());
+    string str2(reinterpret_cast<const char*>(dataPacket->getContent().value()), dataPacket->getContent().value_size());
+    data.insert(make_pair(dataName, str2));
+    // cout << str1 << ", " << str2 << endl;
+  }
+
+  void set(ndn::Name name, const char * buf, int len) {
+    string str2(buf, len);
+    data.insert(make_pair(name, str2));
+  }
+
+  void setNum(const ndn::shared_ptr<const ndn::Data>& data) {
+    int n = data->getContent().value_size() / 4;
+    uint32_t *numbers = new uint32_t [n];
+    memcpy(numbers, data->getContent().value(), data->getContent().value_size());
+    for (int i = 0; i < n; i++) {
+      sum += numbers[i];
+    }
+    delete numbers;
+
+  }
+
+  void setNum(ndn::Name name, const char * buf, int len) {
+    int n = len / 4;
+    int *numbers = new int [n];
+    memcpy(numbers, buf, len);
+    for (int i = 0; i < n; i++) {
+      sum += numbers[i];
+    }
+    delete numbers;
+  }
+
+  uint32_t sum;
+
+  void fetchAll(const vector<MissingDataInfo> &v, SyncSocket *socket) {
+    int n = v.size();
+
+    PRINT
+
+    for (int i = 0; i < n; i++) {
+      for(SeqNo s = v[i].low; s <= v[i].high; ++s) {
+        //PRINT
+        socket->fetchData(v[i].prefix, s, bind(&TestSocketApp::set, this, _1));
+      }
+    }
+  }
+
+  void fetchNumbers(const vector<MissingDataInfo> &v, SyncSocket *socket) {
+    int n = v.size();
+
+    PRINT
+
+    // std::cout << "In fetchNumbers. size of v is:  " << n << std::endl;
+    for (int i = 0; i < n; i++) {
+      // std::cout << "In fetchNumbers. v[i].low is (" <<v[i].low.getSession() <<", " << v[i].low.getSeq() << ") v[i].high is ("<<v[i].high.getSession() <<", " <<v[i].high.getSeq()<<")" << std::endl;
+      for(SeqNo s = v[i].low; s <= v[i].high; ++s) {
+        PRINT
+        socket->fetchData(v[i].prefix, s, bind(&TestSocketApp::setNum, this, _1));
+      }
+    }
+  }
+
+  void pass(const string &prefix) {
+  }
+
+  string toString(){
+    map<ndn::Name, string>::iterator it = data.begin();
+    string str = "\n";
+    for (; it != data.end(); ++it){
+      str += "<";
+      str += it->first.toUri();
+      str += "|";
+      str += it->second;
+      str += ">";
+      str += "\n";
+    }
+
+    return str;
+  }
+
+};
+
+class TestSet1{
+public:
+  TestSet1(ndn::shared_ptr<boost::asio::io_service> ioService)
+    : m_face1(new ndn::Face(*ioService))
+    , m_face2(new ndn::Face(*ioService))
+    , m_face3(new ndn::Face(*ioService))
+    , m_name1("/irl.cs.ucla.edu/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()))
+    , m_name2("/yakshi.org/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()))
+    , m_name3("/google.com/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()))
+  {
+    m_id1 = m_keyChain.getCertificate(m_keyChain.createIdentity(m_name1));
+    m_id2 = m_keyChain.getCertificate(m_keyChain.createIdentity(m_name2));
+    m_id3 = m_keyChain.getCertificate(m_keyChain.createIdentity(m_name3));
+
+    m_rule = ndn::make_shared<ndn::SecRuleRelative>("^(<>*)<><>$",
+                                                    "^(<>*)<><KEY><ksk-.*><ID-CERT>$",
+                                                    "==", "\\1", "\\1", true);
+  }
+
+  void
+  createSyncSocket1()
+  {
+    _LOG_DEBUG ("s1");
+
+    m_s1 = ndn::shared_ptr<SyncSocket>
+      (new SyncSocket("/let/us/sync",
+                      "/irl.cs.ucla.edu",
+                      0,
+                      false,
+                      "/",
+                      m_face1,
+                      *m_id1,
+                      m_rule,
+                      bind(&TestSocketApp::fetchAll, &m_a1, _1, _2),
+                      bind(&TestSocketApp::pass, &m_a1, _1)));
+
+    m_s1->addParticipant(*m_id2);
+  }
+
+  void
+  createSyncSocket2()
+  {
+    _LOG_DEBUG ("s2");
+
+    m_s2 = ndn::shared_ptr<SyncSocket>
+      (new SyncSocket("/let/us/sync",
+                      "/yakshi.org",
+                      0,
+                      false,
+                      "/",
+                      m_face2,
+                      *m_id2,
+                      m_rule,
+                      bind(&TestSocketApp::fetchAll, &m_a2, _1, _2),
+                      bind(&TestSocketApp::pass, &m_a2, _1)));
+
+    m_s2->addParticipant(*m_id1);
+    m_s2->addParticipant(*m_id3);
+  }
+
+  void
+  createSyncSocket3()
+  {
+    _LOG_DEBUG ("s3");
+
+    m_s3 = ndn::shared_ptr<SyncSocket>
+      (new SyncSocket("/let/us/sync",
+                      "/google.com",
+                      0,
+                      false,
+                      "/",
+                      m_face3,
+                      *m_id3,
+                      m_rule,
+                      bind(&TestSocketApp::fetchAll, &m_a3, _1, _2),
+                      bind(&TestSocketApp::pass, &m_a3, _1)));
+
+    m_s3->addParticipant(*m_id2);
+  }
+
+  void
+  publishSocket1(string data)
+  {
+    _LOG_DEBUG ("s1 publish");
+    m_s1->publishData (reinterpret_cast<const uint8_t*>(data.c_str()), data.size(), 1000);
+  }
+
+  void
+  publishSocket2(string data)
+  {
+    _LOG_DEBUG ("s2 publish");
+    m_s2->publishData (reinterpret_cast<const uint8_t*>(data.c_str()), data.size(), 1000);
+  }
+
+  void
+  publishSocket3(string data)
+  {
+    _LOG_DEBUG ("s3 publish");
+    m_s3->publishData (reinterpret_cast<const uint8_t*>(data.c_str()), data.size(), 1000);
+  }
+
+  void
+  setSocket1(string suffix, string data)
+  {
+    _LOG_DEBUG ("a1 set");
+    ndn::Name name("/irl.cs.ucla.edu");
+    name.append(suffix);
+    m_a1.set (name, data.c_str(), data.size());
+  }
+
+  void
+  setSocket2(string suffix, string data)
+  {
+    _LOG_DEBUG ("a2 set");
+    ndn::Name name("/yakshi.org");
+    name.append(suffix);
+    m_a2.set (name, data.c_str(), data.size());
+  }
+
+  void
+  setSocket3(string suffix, string data)
+  {
+    _LOG_DEBUG ("a3 set");
+    ndn::Name name("/google.com");
+    name.append(suffix);
+    m_a3.set (name, data.c_str(), data.size());
+  }
+
+  void
+  check(int round)
+  {
+    BOOST_CHECK_EQUAL(m_a1.toString(), m_a2.toString());
+    BOOST_CHECK_EQUAL(m_a2.toString(), m_a3.toString());
+  }
+
+  void
+  done(ndn::shared_ptr<boost::asio::io_service> ioService)
+  {
+    m_s1.reset();
+    m_s2.reset();
+    m_s3.reset();
+
+    m_keyChain.deleteIdentity(m_name1);
+    m_keyChain.deleteIdentity(m_name2);
+    m_keyChain.deleteIdentity(m_name3);
+
+    ioService->stop();
+  }
+
+  ndn::KeyChain m_keyChain;
+  ndn::shared_ptr<ndn::SecRuleRelative> m_rule;
+
+  ndn::shared_ptr<ndn::Face> m_face1, m_face2, m_face3;
+  ndn::Name m_name1, m_name2, m_name3;
+  TestSocketApp m_a1, m_a2, m_a3;
+  ndn::shared_ptr<ndn::IdentityCertificate> m_id1, m_id2, m_id3;
+  ndn::shared_ptr<SyncSocket> m_s1, m_s2, m_s3;
+};
+
+class TestSet2{
+public:
+  TestSet2(ndn::shared_ptr<boost::asio::io_service> ioService)
+    : m_face1(new ndn::Face(*ioService))
+    , m_face2(new ndn::Face(*ioService))
+    , m_name1("/xiaonei.com/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()))
+    , m_name2("/mitbbs.com/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()))
+  {
+    m_id1 = m_keyChain.getCertificate(m_keyChain.createIdentity(m_name1));
+    m_id2 = m_keyChain.getCertificate(m_keyChain.createIdentity(m_name2));
+
+    m_rule = ndn::make_shared<ndn::SecRuleRelative>("^(<>*)<><>$",
+                                                    "^(<>*)<><KEY><ksk-.*><ID-CERT>$",
+                                                    "==", "\\1", "\\1", true);
+  }
+
+  void
+  createSyncSocket1()
+  {
+    _LOG_DEBUG ("s1");
+
+    m_s1 = ndn::shared_ptr<SyncSocket>
+      (new SyncSocket("/this/is/the/prefix",
+                      "/xiaonei.com",
+                      0,
+                      false,
+                      "/",
+                      m_face1,
+                      *m_id1,
+                      m_rule,
+                      bind(&TestSocketApp::fetchNumbers, &m_a1, _1, _2),
+                      bind(&TestSocketApp::pass, &m_a1, _1)));
+
+    m_s1->addParticipant(*m_id2);
+  }
+
+  void
+  createSyncSocket2()
+  {
+    _LOG_DEBUG ("s2");
+
+    m_s2 = ndn::shared_ptr<SyncSocket>
+      (new SyncSocket("/this/is/the/prefix",
+                      "/mitbbs.com",
+                      0,
+                      false,
+                      "/",
+                      m_face2,
+                      *m_id2,
+                      m_rule,
+                      bind(&TestSocketApp::fetchNumbers, &m_a2, _1, _2),
+                      bind(&TestSocketApp::pass, &m_a2, _1)));
+
+    m_s2->addParticipant(*m_id1);
+  }
+
+  void
+  publishSocket1(string data)
+  {
+    _LOG_DEBUG ("s1 publish");
+    m_s1->publishData (reinterpret_cast<const uint8_t*>(data.c_str()), data.size(), 1000);
+  }
+
+  void
+  publishSocket2(string data)
+  {
+    _LOG_DEBUG ("s2 publish");
+    m_s2->publishData (reinterpret_cast<const uint8_t*>(data.c_str()), data.size(), 1000);
+  }
+
+  void
+  setSocket1(const char* ptr, size_t size)
+  {
+    _LOG_DEBUG ("a1 setNum");
+    m_a1.setNum ("/xiaonei.com", ptr, size);
+  }
+
+  void
+  setSocket2(const char* ptr, size_t size)
+  {
+    _LOG_DEBUG ("a2 setNum");
+    m_a2.setNum ("/mitbbs.com", ptr, size);
+  }
+
+  void
+  check(int num)
+  {
+    _LOG_DEBUG ("codnum " << num);
+    _LOG_DEBUG ("a1 sum " << m_a1.sum);
+    _LOG_DEBUG ("a2 sum " << m_a2.sum);
+
+    BOOST_CHECK(m_a1.sum == m_a2.sum && m_a1.sum == num);
+  }
+
+  void
+  done(ndn::shared_ptr<boost::asio::io_service> ioService)
+  {
+    m_s1.reset();
+    m_s2.reset();
+
+    m_keyChain.deleteIdentity(m_name1);
+    m_keyChain.deleteIdentity(m_name2);
+
+    ioService->stop();
+  }
+
+  ndn::KeyChain m_keyChain;
+  ndn::shared_ptr<ndn::SecRuleRelative> m_rule;
+
+  TestSocketApp m_a1, m_a2;
+  ndn::shared_ptr<ndn::IdentityCertificate> m_id1, m_id2;
+  ndn::shared_ptr<ndn::Face> m_face1, m_face2;
+  ndn::Name m_name1, m_name2;
+  ndn::shared_ptr<SyncSocket> m_s1, m_s2;
+};
+
+
+
+class TestSet3{
+public:
+  TestSet3(ndn::shared_ptr<boost::asio::io_service> ioService)
+    : m_face1(new ndn::Face(*ioService))
+    , m_face2(new ndn::Face(*ioService))
+    , m_name1("/xiaonei.com/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()))
+    , m_name2("/mitbbs.com/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()))
+  {
+    m_id1 = m_keyChain.getCertificate(m_keyChain.createIdentity(m_name1));
+    m_id2 = m_keyChain.getCertificate(m_keyChain.createIdentity(m_name2));
+
+    m_rule = ndn::make_shared<ndn::SecRuleRelative>("^(<>*)<><>$",
+                                                    "^(<>*)<><KEY><ksk-.*><ID-CERT>$",
+                                                    "==", "\\1", "\\1", true);
+  }
+
+  void
+  createSyncSocket1()
+  {
+    _LOG_DEBUG ("s1");
+
+    m_s1 = ndn::shared_ptr<SyncSocket>
+      (new SyncSocket("/this/is/the/prefix",
+                      "/xiaonei.com",
+                      1,
+                      true,
+                      "/abc",
+                      m_face1,
+                      *m_id1,
+                      m_rule,
+                      bind(&TestSocketApp::fetchNumbers, &m_a1, _1, _2),
+                      bind(&TestSocketApp::pass, &m_a1, _1)));
+
+    m_s1->addParticipant(*m_id2);
+  }
+
+  void
+  createSyncSocket2()
+  {
+    _LOG_DEBUG ("s2");
+
+    m_s2 = ndn::shared_ptr<SyncSocket>
+      (new SyncSocket("/this/is/the/prefix",
+                      "/mitbbs.com",
+                      1,
+                      false,
+                      "/",
+                      m_face2,
+                      *m_id2,
+                      m_rule,
+                      bind(&TestSocketApp::fetchNumbers, &m_a2, _1, _2),
+                      bind(&TestSocketApp::pass, &m_a2, _1)));
+
+    m_s2->addParticipant(*m_id1);
+  }
+
+  void
+  publishSocket1(string data)
+  {
+    _LOG_DEBUG ("s1 publish");
+    m_s1->publishData (reinterpret_cast<const uint8_t*>(data.c_str()), data.size(), 1000);
+  }
+
+  void
+  publishSocket2(string data)
+  {
+    _LOG_DEBUG ("s2 publish");
+    m_s2->publishData (reinterpret_cast<const uint8_t*>(data.c_str()), data.size(), 1000);
+  }
+
+  void
+  setSocket1(const char* ptr, size_t size)
+  {
+    _LOG_DEBUG ("a1 setNum");
+    m_a1.setNum ("/xiaonei.com", ptr, size);
+  }
+
+  void
+  setSocket2(const char* ptr, size_t size)
+  {
+    _LOG_DEBUG ("a2 setNum");
+    m_a2.setNum ("/mitbbs.com", ptr, size);
+  }
+
+  void
+  check(int num)
+  {
+    _LOG_DEBUG ("codnum " << num);
+    _LOG_DEBUG ("a1 sum " << m_a1.sum);
+    _LOG_DEBUG ("a2 sum " << m_a2.sum);
+
+    BOOST_CHECK(m_a1.sum == m_a2.sum && m_a1.sum == num);
+  }
+
+  void
+  done(ndn::shared_ptr<boost::asio::io_service> ioService)
+  {
+    m_s1.reset();
+    m_s2.reset();
+
+    m_keyChain.deleteIdentity(m_name1);
+    m_keyChain.deleteIdentity(m_name2);
+
+    ioService->stop();
+  }
+
+  ndn::KeyChain m_keyChain;
+  ndn::shared_ptr<ndn::SecRuleRelative> m_rule;
+
+  TestSocketApp m_a1, m_a2;
+  ndn::shared_ptr<ndn::IdentityCertificate> m_id1, m_id2;
+  ndn::shared_ptr<ndn::Face> m_face1, m_face2;
+  ndn::Name m_name1, m_name2;
+  ndn::shared_ptr<SyncSocket> m_s1, m_s2;
+};
+
+BOOST_AUTO_TEST_CASE (AppSocketTest1)
+{
+  INIT_LOGGERS ();
+
+  ndn::shared_ptr<boost::asio::io_service> ioService = ndn::make_shared<boost::asio::io_service>();
+  ndn::Scheduler scheduler(*ioService);
+  TestSet1 testSet1(ioService);
+
+  scheduler.scheduleEvent(ndn::time::milliseconds(0), ndn::bind(&TestSet1::createSyncSocket1, &testSet1));
+  scheduler.scheduleEvent(ndn::time::milliseconds(50), ndn::bind(&TestSet1::createSyncSocket2, &testSet1));
+  scheduler.scheduleEvent(ndn::time::milliseconds(100), ndn::bind(&TestSet1::createSyncSocket3, &testSet1));
+  string data0 = "Very funny Scotty, now beam down my clothes";
+  scheduler.scheduleEvent(ndn::time::milliseconds(150), ndn::bind(&TestSet1::publishSocket1, &testSet1, data0));
+  scheduler.scheduleEvent(ndn::time::milliseconds(1150), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/1", data0));
+  scheduler.scheduleEvent(ndn::time::milliseconds(1160), ndn::bind(&TestSet1::check, &testSet1, 1));
+  string data1 = "Yes, give me that ketchup";
+  string data2 = "Don't look conspicuous, it draws fire";
+  scheduler.scheduleEvent(ndn::time::milliseconds(1170), ndn::bind(&TestSet1::publishSocket1, &testSet1, data1));
+  scheduler.scheduleEvent(ndn::time::milliseconds(1180), ndn::bind(&TestSet1::publishSocket1, &testSet1, data2));
+  scheduler.scheduleEvent(ndn::time::milliseconds(2150), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/2", data1));
+  scheduler.scheduleEvent(ndn::time::milliseconds(2160), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/3", data2));
+  scheduler.scheduleEvent(ndn::time::milliseconds(2170), ndn::bind(&TestSet1::check, &testSet1, 2));
+  string data3 = "You surf the Internet, I surf the real world";
+  string data4 = "I got a fortune cookie once that said 'You like Chinese food'";
+  string data5 = "Real men wear pink. Why? Because their wives make them";
+  scheduler.scheduleEvent(ndn::time::milliseconds(3180), ndn::bind(&TestSet1::publishSocket3, &testSet1, data3));
+  scheduler.scheduleEvent(ndn::time::milliseconds(3200), ndn::bind(&TestSet1::publishSocket2, &testSet1, data4));
+  scheduler.scheduleEvent(ndn::time::milliseconds(3210), ndn::bind(&TestSet1::publishSocket2, &testSet1, data5));
+  scheduler.scheduleEvent(ndn::time::milliseconds(4710), ndn::bind(&TestSet1::setSocket3, &testSet1, "/0/1", data3));
+  scheduler.scheduleEvent(ndn::time::milliseconds(4720), ndn::bind(&TestSet1::setSocket2, &testSet1, "/0/2", data4));
+  scheduler.scheduleEvent(ndn::time::milliseconds(4730), ndn::bind(&TestSet1::setSocket2, &testSet1, "/0/3", data5));
+  scheduler.scheduleEvent(ndn::time::milliseconds(4800), ndn::bind(&TestSet1::check, &testSet1, 3));
+  // not sure weither this is simultanous data generation from multiple sources
+  _LOG_DEBUG ("Simultaneous publishing");
+  string data6 = "Shakespeare says: 'Prose before hos.'";
+  string data7 = "Pick good people, talent never wears out";
+  scheduler.scheduleEvent(ndn::time::milliseconds(5500), ndn::bind(&TestSet1::publishSocket1, &testSet1, data6));
+  scheduler.scheduleEvent(ndn::time::milliseconds(5500), ndn::bind(&TestSet1::publishSocket2, &testSet1, data7));
+  scheduler.scheduleEvent(ndn::time::milliseconds(6800), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/4", data6));
+  scheduler.scheduleEvent(ndn::time::milliseconds(6800), ndn::bind(&TestSet1::setSocket2, &testSet1, "/0/4", data7));
+  scheduler.scheduleEvent(ndn::time::milliseconds(6900), ndn::bind(&TestSet1::check, &testSet1, 4));
+  scheduler.scheduleEvent(ndn::time::milliseconds(7000), ndn::bind(&TestSet1::done, &testSet1, ioService));
+
+  ioService->run();
+}
+
+BOOST_AUTO_TEST_CASE (AppSocketTest2)
+{
+  ndn::shared_ptr<boost::asio::io_service> ioService = ndn::make_shared<boost::asio::io_service>();
+  ndn::Scheduler scheduler(*ioService);
+  TestSet2 testSet2(ioService);
+
+  scheduler.scheduleEvent(ndn::time::milliseconds(0), ndn::bind(&TestSet2::createSyncSocket1, &testSet2));
+  scheduler.scheduleEvent(ndn::time::milliseconds(50), ndn::bind(&TestSet2::createSyncSocket2, &testSet2));
+  uint32_t num[5] = {0, 1, 2, 3, 4};
+  string data0((const char *) num, sizeof(num));
+  scheduler.scheduleEvent(ndn::time::milliseconds(100), ndn::bind(&TestSet2::publishSocket1, &testSet2, data0));
+  scheduler.scheduleEvent(ndn::time::milliseconds(150), ndn::bind(&TestSet2::setSocket1, &testSet2, (const char *) num, sizeof (num)));
+  scheduler.scheduleEvent(ndn::time::milliseconds(1000), ndn::bind(&TestSet2::check, &testSet2, 10));
+  uint32_t newNum[5] = {9, 7, 2, 1, 1};
+  string data1((const char *) newNum, sizeof(newNum));
+  scheduler.scheduleEvent(ndn::time::milliseconds(1100), ndn::bind(&TestSet2::publishSocket2, &testSet2, data1));
+  scheduler.scheduleEvent(ndn::time::milliseconds(1150), ndn::bind(&TestSet2::setSocket2, &testSet2, (const char *) newNum, sizeof (newNum)));
+  scheduler.scheduleEvent(ndn::time::milliseconds(2000), ndn::bind(&TestSet2::check, &testSet2, 30));
+  scheduler.scheduleEvent(ndn::time::milliseconds(7000), ndn::bind(&TestSet2::done, &testSet2, ioService));
+
+  ioService->run();
+}
+
+BOOST_AUTO_TEST_CASE (AppSocketTest3)
+{
+  ndn::shared_ptr<boost::asio::io_service> ioService = ndn::make_shared<boost::asio::io_service>();
+  ndn::Scheduler scheduler(*ioService);
+  TestSet3 testSet3(ioService);
+
+  scheduler.scheduleEvent(ndn::time::milliseconds(0), ndn::bind(&TestSet3::createSyncSocket1, &testSet3));
+  scheduler.scheduleEvent(ndn::time::milliseconds(200), ndn::bind(&TestSet3::createSyncSocket2, &testSet3));
+  uint32_t num[5] = {0, 1, 2, 3, 4};
+  string data0((const char *) num, sizeof(num));
+  scheduler.scheduleEvent(ndn::time::milliseconds(1000), ndn::bind(&TestSet3::publishSocket1, &testSet3, data0));
+  scheduler.scheduleEvent(ndn::time::milliseconds(1500), ndn::bind(&TestSet3::setSocket1, &testSet3, (const char *) num, sizeof (num)));
+  scheduler.scheduleEvent(ndn::time::milliseconds(2000), ndn::bind(&TestSet3::check, &testSet3, 10));
+  uint32_t newNum[5] = {9, 7, 2, 1, 1};
+  string data1((const char *) newNum, sizeof(newNum));
+  scheduler.scheduleEvent(ndn::time::milliseconds(3000), ndn::bind(&TestSet3::publishSocket2, &testSet3, data1));
+  scheduler.scheduleEvent(ndn::time::milliseconds(3500), ndn::bind(&TestSet3::setSocket2, &testSet3, (const char *) newNum, sizeof (newNum)));
+  scheduler.scheduleEvent(ndn::time::milliseconds(5000), ndn::bind(&TestSet3::check, &testSet3, 30));
+  scheduler.scheduleEvent(ndn::time::milliseconds(7000), ndn::bind(&TestSet3::done, &testSet3, ioService));
+
+  ioService->run();
+}
diff --git a/tests/unit-tests/test-state.cc.outdated b/tests/unit-tests/test-state.cc.outdated
new file mode 100644
index 0000000..433f8d9
--- /dev/null
+++ b/tests/unit-tests/test-state.cc.outdated
@@ -0,0 +1,291 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define BOOST_TEST_DYN_LINK 1
+#define BOOST_TEST_NO_MAIN 1
+// #define BOOST_TEST_MODULE StateTests
+#include <boost/test/unit_test.hpp>
+#include <boost/test/output_test_stream.hpp>
+using boost::test_tools::output_test_stream;
+
+#include <boost/make_shared.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+
+#include "sync-std-name-info.h"
+#include "sync-full-state.h"
+#include "sync-diff-state.h"
+
+using namespace Sync;
+using namespace std;
+using namespace boost;
+
+BOOST_AUTO_TEST_SUITE(StateTests)
+
+BOOST_AUTO_TEST_CASE (FullStateTest)
+{
+  BOOST_CHECK_NO_THROW (FullState ());
+  FullState state;
+  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 0);
+
+  output_test_stream output;
+  output << state.getTimeFromLastUpdate ();
+  BOOST_CHECK (output.is_equal ("not-a-date-time", true));
+
+  NameInfoConstPtr name = StdNameInfo::FindOrCreate ("/test/name");
+  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
+  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
+  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
+  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 1);
+  BOOST_CHECK_EQUAL ((*state.getLeaves ().begin ())->getSeq ().getSeq (), 12);
+
+  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (13)));
+  BOOST_CHECK_EQUAL ((*state.getLeaves ().begin ())->getSeq ().getSeq (), 13);
+
+  BOOST_CHECK_NO_THROW (state.remove (name));
+  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 0);
+
+  BOOST_CHECK_EQUAL (state.getTimeFromLastUpdate ().total_milliseconds (), 0);
+}
+
+BOOST_AUTO_TEST_CASE (DiffStateTest)
+{
+  BOOST_CHECK_NO_THROW (DiffState ());
+  DiffState state;
+  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 0);
+
+  NameInfoConstPtr name = StdNameInfo::FindOrCreate ("/test/name");
+  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
+  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
+  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
+  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 1);
+  BOOST_CHECK_EQUAL ((*state.getLeaves ().begin ())->getSeq ().getSeq (), 12);
+
+  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (13)));
+  BOOST_CHECK_EQUAL ((*state.getLeaves ().begin ())->getSeq ().getSeq (), 13);
+
+  BOOST_CHECK_NO_THROW (state.remove (name));
+  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 1);
+  BOOST_CHECK_EQUAL ((*state.getLeaves ().begin ())->getSeq ().getSeq (), 0);
+}
+
+BOOST_AUTO_TEST_CASE (FullStateDigestTest)
+{
+  FullState state;
+  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 0);
+
+  NameInfoConstPtr name3 = StdNameInfo::FindOrCreate ("3");
+  NameInfoConstPtr name2 = StdNameInfo::FindOrCreate ("2");
+  NameInfoConstPtr name1 = StdNameInfo::FindOrCreate ("1");
+
+  state.update (name1, SeqNo (10));
+  DigestConstPtr digest1 = state.getDigest ();
+
+  state.update (name2, SeqNo (12));
+  DigestConstPtr digest2 = state.getDigest ();
+
+  BOOST_CHECK (digest1.get () != digest2.get ());
+  BOOST_CHECK (!digest1->empty ());
+  BOOST_CHECK (!digest2->empty ());
+
+  state.update (name3, SeqNo (8));
+  DigestConstPtr digest3 = state.getDigest ();
+
+  BOOST_CHECK (digest1.get () != digest2.get ());
+  BOOST_CHECK (digest2.get () != digest3.get ());
+  BOOST_CHECK (digest1.get () != digest3.get ());
+
+  BOOST_CHECK (*digest1 != *digest2);
+  BOOST_CHECK (*digest2 != *digest3);
+  BOOST_CHECK (*digest1 != *digest3);
+
+  // removing elements. Digest should get reverted to digest1
+  state.remove (name2);
+  state.remove (name3);
+  DigestConstPtr digest4 = state.getDigest ();
+  BOOST_CHECK (*digest1 == *digest4);
+
+  name2.reset (); // force destructor
+  name3.reset (); // force destructor
+  name3 = StdNameInfo::FindOrCreate ("3"); // this will enforce different (larger) hashing ID of name
+  name2 = StdNameInfo::FindOrCreate ("2"); // this will enforce different (larger) hashing ID of name
+
+  // adding in different order
+  state.update (name3, SeqNo (8));
+  state.update (name2, SeqNo (12));
+  DigestConstPtr digest5 = state.getDigest ();
+  BOOST_CHECK (*digest5 == *digest3);
+}
+
+BOOST_AUTO_TEST_CASE (FullStateXml)
+{
+  FullState state;
+
+  NameInfoConstPtr name3 = StdNameInfo::FindOrCreate ("3");
+  NameInfoConstPtr name2 = StdNameInfo::FindOrCreate ("2");
+  NameInfoConstPtr name1 = StdNameInfo::FindOrCreate ("1");
+
+  state.update (name1, SeqNo (10));
+  state.update (name2, SeqNo (12));
+  state.update (name3, SeqNo (8));
+
+  string xml1 = "<state>"
+    "<item><name>1</name><seq><session>0</session><seqno>10</seqno></seq></item>"
+    "<item><name>2</name><seq><session>0</session><seqno>12</seqno></seq></item>"
+    "<item><name>3</name><seq><session>0</session><seqno>8</seqno></seq></item>"
+    "</state>";
+  {
+  ostringstream os;
+  os << state;
+  string s = os.str ();
+  // cout << s << endl;
+  erase_all (s, "\n");
+  BOOST_CHECK_EQUAL (s, xml1);
+  }
+
+  state.remove (name2);
+  string xml2 = "<state>"
+    "<item><name>1</name><seq><session>0</session><seqno>10</seqno></seq></item>"
+    "<item><name>3</name><seq><session>0</session><seqno>8</seqno></seq></item>"
+    "</state>";
+  {
+  ostringstream os;
+  os << state;
+  string s = os.str ();
+  erase_all (s, "\n");
+  BOOST_CHECK_EQUAL (s, xml2);
+  }
+
+  FullState state2;
+  istringstream xml1_is (xml1);
+  BOOST_CHECK_NO_THROW (xml1_is >> state2);
+  {
+  ostringstream os;
+  os << state2;
+  string xml1_test = os.str ();
+  erase_all (xml1_test, "\n");
+  BOOST_CHECK_EQUAL (xml1_test, xml1);
+  }
+
+  istringstream xml2_is ("<state><item action=\"remove\"><name>2</name></item></state>");
+  BOOST_CHECK_NO_THROW (xml2_is >> state2);
+
+  {
+  ostringstream os;
+  os << state2;
+  string xml2_test = os.str ();
+  erase_all (xml2_test, "\n");
+  BOOST_CHECK_EQUAL (xml2_test, xml2);
+  }
+}
+
+BOOST_AUTO_TEST_CASE (DiffStateXml)
+{
+  DiffState state;
+
+  NameInfoConstPtr name3 = StdNameInfo::FindOrCreate ("3");
+  NameInfoConstPtr name2 = StdNameInfo::FindOrCreate ("2");
+  NameInfoConstPtr name1 = StdNameInfo::FindOrCreate ("1");
+
+  state.update (name1, SeqNo (10));
+  state.update (name2, SeqNo (12));
+  state.update (name3, SeqNo (8));
+
+  string xml1 = "<state>"
+    "<item action=\"update\"><name>1</name><seq><session>0</session><seqno>10</seqno></seq></item>"
+    "<item action=\"update\"><name>2</name><seq><session>0</session><seqno>12</seqno></seq></item>"
+    "<item action=\"update\"><name>3</name><seq><session>0</session><seqno>8</seqno></seq></item>"
+    "</state>";
+  {
+  ostringstream os;
+  os << state;
+  string xml1_test = os.str ();
+  erase_all (xml1_test, "\n");
+  BOOST_CHECK_EQUAL (xml1_test, xml1);
+  }
+
+  state.remove (name2);
+  string xml2 = "<state>"
+    "<item action=\"update\"><name>1</name><seq><session>0</session><seqno>10</seqno></seq></item>"
+    "<item action=\"remove\"><name>2</name></item>"
+    "<item action=\"update\"><name>3</name><seq><session>0</session><seqno>8</seqno></seq></item>"
+    "</state>";
+  {
+  ostringstream os;
+  os << state;
+  string xml2_test = os.str ();
+  erase_all (xml2_test, "\n");
+  BOOST_CHECK_EQUAL (xml2_test, xml2);
+  }
+
+  ////////////  ////////////  ////////////  ////////////  ////////////  ////////////
+
+  DiffState state2;
+  istringstream xml1_is (xml1);
+  BOOST_CHECK_NO_THROW (xml1_is >> state2);
+
+  {
+  ostringstream os;
+  os << state2;
+  string xml1_test = os.str ();
+  erase_all (xml1_test, "\n");
+  BOOST_CHECK_EQUAL (xml1_test, xml1);
+  }
+
+  istringstream xml2_is ("<state><item action=\"remove\"><name>2</name></item></state>");
+  BOOST_CHECK_NO_THROW (xml2_is >> state2);
+
+  {
+  ostringstream os;
+  os << state2;
+  string xml2_test = os.str ();
+  erase_all (xml2_test, "\n");
+  BOOST_CHECK_EQUAL (xml2_test, xml2);
+  }
+
+}
+
+BOOST_AUTO_TEST_CASE (DiffStateDiffTest)
+{
+  DiffStatePtr root = make_shared<DiffState> ();
+
+  DiffStatePtr head = make_shared<DiffState> ();
+  root->setNext (head);
+
+  head->update (StdNameInfo::FindOrCreate ("3"), SeqNo (1));
+  head->remove (StdNameInfo::FindOrCreate ("1"));
+
+  DiffStatePtr tail = make_shared<DiffState> ();
+  head->setNext (tail);
+
+  tail->update (StdNameInfo::FindOrCreate ("3"), SeqNo (2));
+
+  {
+  ostringstream os;
+  os << *root->diff ();
+  string diffState = os.str ();
+  erase_all (diffState, "\n");
+  BOOST_CHECK_EQUAL (diffState,
+                     "<state>"
+                     "<item action=\"remove\"><name>1</name></item>"
+                     "<item action=\"update\"><name>3</name><seq><session>0</session><seqno>2</seqno></seq></item>"
+                     "</state>");
+  }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/unit-tests/test-sync-logic.cpp.outdated b/tests/unit-tests/test-sync-logic.cpp.outdated
new file mode 100644
index 0000000..e916ad5
--- /dev/null
+++ b/tests/unit-tests/test-sync-logic.cpp.outdated
@@ -0,0 +1,181 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/output_test_stream.hpp>
+#include <map>
+using boost::test_tools::output_test_stream;
+
+#include <boost/make_shared.hpp>
+
+#include <ndn-cxx/security/validator-null.hpp>
+#include "sync-logic.h"
+#include "sync-seq-no.h"
+
+using namespace std;
+using namespace boost;
+using namespace Sync;
+
+struct Handler
+{
+  string instance;
+
+  Handler (const string &_instance)
+  : instance (_instance)
+  {
+  }
+
+  void wrapper (const vector<MissingDataInfo> &v) {
+    int n = v.size();
+    for (int i = 0; i < n; i++) {
+      onUpdate (v[i].prefix, v[i].high, v[i].low);
+    }
+  }
+
+  void onUpdate (const string &p/*prefix*/, const SeqNo &seq/*newSeq*/, const SeqNo &oldSeq/*oldSeq*/)
+  {
+    m_map[p] = seq.getSeq ();
+
+    // cout << instance << "\t";
+    // if (!oldSeq.isValid ())
+    //   cout << "Inserted: " << p << " (" << seq << ")" << endl;
+    // else
+    //   cout << "Updated: " << p << "  ( " << oldSeq << ".." << seq << ")" << endl;
+  }
+
+  void onRemove (const string &p/*prefix*/)
+  {
+    // cout << instance << "\tRemoved: " << p << endl;
+    m_map.erase (p);
+  }
+
+  map<string, uint32_t> m_map;
+};
+
+class TestCore
+{
+public:
+  TestCore(ndn::shared_ptr<boost::asio::io_service> ioService)
+    : m_ioService(ioService)
+  {
+    m_l[0] = 0;
+    m_l[1] = 0;
+
+    m_validator = ndn::make_shared<ndn::ValidatorNull>();
+  }
+
+  ~TestCore()
+  {
+    if(m_l[0] != 0)
+      delete m_l[0];
+
+    if(m_l[1] != 0)
+      delete m_l[1];
+  }
+
+  void
+  finish(ndn::shared_ptr<boost::asio::io_service> ioService)
+  {
+    ioService->stop();
+  }
+
+  void
+  createSyncLogic(int index,
+                  ndn::shared_ptr<Handler> h)
+  {
+    ndn::Name identity("/tmp-" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+    ndn::shared_ptr<ndn::IdentityCertificate> cert = m_keyChain.getCertificate(m_keyChain.createIdentity(identity));
+    m_faces[index] = ndn::make_shared<ndn::Face>(ndn::ref(*m_ioService));
+    m_l[index] = new SyncLogic(ndn::Name("/bcast"),
+                               *cert,
+                               m_validator, m_faces[index],
+                               bind (&Handler::wrapper, &*h, _1),
+                               bind (&Handler::onRemove, &*h, _1));
+  }
+
+  void
+  getOldDigestForOne()
+  {
+    m_oldDigest = m_l[0]->getRootDigest();
+  }
+
+  void
+  getNewDigestForOne()
+  {
+    m_newDigest = m_l[0]->getRootDigest();
+  }
+
+  void
+  addLocalNamesForOne(ndn::Name name, uint64_t session, uint64_t seq)
+  {
+    m_l[0]->addLocalNames(name, session, seq);
+  }
+
+  void
+  removeForOne(ndn::Name name)
+  {
+    m_l[0]->remove(name);
+  }
+
+  void
+  checkDigest()
+  {
+    BOOST_CHECK(m_oldDigest != m_newDigest);
+  }
+
+
+public:
+  ndn::KeyChain m_keyChain;
+  ndn::shared_ptr<boost::asio::io_service> m_ioService;
+  SyncLogic* m_l[2];
+  ndn::shared_ptr<ndn::Face> m_faces[2];
+  ndn::shared_ptr<ndn::ValidatorNull> m_validator;
+  string m_oldDigest;
+  string m_newDigest;
+};
+
+void
+checkMapSize(ndn::shared_ptr<Handler> h, int size)
+{ BOOST_CHECK_EQUAL (h->m_map.size (), size); }
+
+
+BOOST_AUTO_TEST_CASE (SyncLogicTest)
+{
+  ndn::shared_ptr<boost::asio::io_service> ioService = ndn::make_shared<boost::asio::io_service>();
+  ndn::Scheduler scheduler(*ioService);
+  TestCore testCore(ioService);
+
+  ndn::shared_ptr<Handler> h1 = ndn::make_shared<Handler>("1");
+  ndn::shared_ptr<Handler> h2 = ndn::make_shared<Handler>("2");
+
+  scheduler.scheduleEvent(ndn::time::milliseconds(0), ndn::bind(&TestCore::createSyncLogic, &testCore, 0, h1));
+  scheduler.scheduleEvent(ndn::time::milliseconds(100), ndn::bind(&TestCore::getOldDigestForOne, &testCore));
+  scheduler.scheduleEvent(ndn::time::milliseconds(200), ndn::bind(&TestCore::addLocalNamesForOne, &testCore, "/one", 1, 2));
+  scheduler.scheduleEvent(ndn::time::milliseconds(300), ndn::bind(&checkMapSize, h1, 0));
+  scheduler.scheduleEvent(ndn::time::milliseconds(400), ndn::bind(&TestCore::createSyncLogic, &testCore, 1, h2));
+  scheduler.scheduleEvent(ndn::time::milliseconds(500), ndn::bind(&checkMapSize, h1, 0));
+  scheduler.scheduleEvent(ndn::time::milliseconds(600), ndn::bind(&checkMapSize, h2, 1));
+  scheduler.scheduleEvent(ndn::time::milliseconds(700), ndn::bind(&TestCore::removeForOne, &testCore, "/one"));
+  scheduler.scheduleEvent(ndn::time::milliseconds(800), ndn::bind(&TestCore::getNewDigestForOne, &testCore));
+  scheduler.scheduleEvent(ndn::time::milliseconds(900), ndn::bind(&TestCore::checkDigest, &testCore));
+  scheduler.scheduleEvent(ndn::time::milliseconds(1000), ndn::bind(&TestCore::finish, &testCore, ioService));
+
+  ioService->run();
+
+}
diff --git a/tests/unit-tests/test-sync-validator.cpp.outdated b/tests/unit-tests/test-sync-validator.cpp.outdated
new file mode 100644
index 0000000..7c8c300
--- /dev/null
+++ b/tests/unit-tests/test-sync-validator.cpp.outdated
@@ -0,0 +1,349 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <boost/test/unit_test.hpp>
+#include "sync-validator.h"
+
+#include <boost/lexical_cast.hpp>
+#include <boost/asio.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
+
+BOOST_AUTO_TEST_SUITE(TestSyncValidator)
+
+void
+onValidated(const ndn::shared_ptr<const ndn::Data>& data)
+{
+  BOOST_CHECK(true);
+}
+
+void
+onValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
+                   const std::string& failureInfo)
+{
+  BOOST_CHECK(false);
+}
+
+void
+onValidated2(const ndn::shared_ptr<const ndn::Data>& data)
+{
+  BOOST_CHECK(false);
+}
+
+void
+onValidationFailed2(const ndn::shared_ptr<const ndn::Data>& data,
+                    const std::string& failureInfo)
+{
+  BOOST_CHECK(true);
+}
+
+void
+publishData(const uint8_t* buf, size_t len, int freshness)
+{
+}
+
+BOOST_AUTO_TEST_CASE (Graph)
+{
+  using namespace Sync;
+  using namespace ndn;
+
+  Name prefix("/Sync/TestSyncValidator/AddEdge");
+  KeyChain keychain;
+
+  Name identity1("/TestSyncValidator/AddEdge-1/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName1 = keychain.createIdentity(identity1);
+  shared_ptr<IdentityCertificate> anchor = keychain.getCertificate(certName1);
+
+  Name identity2("/TestSyncValidator/AddEdge-2/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName2 = keychain.createIdentity(identity2);
+  shared_ptr<IdentityCertificate> introducer = keychain.getCertificate(certName2);
+
+  Name identity3("/TestSyncValidator/AddEdge-3/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName3 = keychain.createIdentity(identity3);
+  shared_ptr<IdentityCertificate> introducee = keychain.getCertificate(certName3);
+
+  Name identity4("/TestSyncValidator/AddEdge-4/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName4 = keychain.createIdentity(identity4);
+  shared_ptr<IdentityCertificate> introducer2 = keychain.getCertificate(certName4);
+
+  Name identity5("/TestSyncValidator/AddEdge-5/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName5 = keychain.createIdentity(identity5);
+  shared_ptr<IdentityCertificate> introducee2 = keychain.getCertificate(certName5);
+
+  shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>();
+  shared_ptr<Face> face = make_shared<Face>(ref(*ioService));
+  shared_ptr<SecRuleRelative> rule;
+  SyncValidator validator(prefix, *anchor, *face,
+                          bind(&publishData, _1, _2, _3),
+                          rule);
+
+  validator.addParticipant(*introducer);
+  BOOST_CHECK(validator.canTrust(certName2));
+
+  IntroCertificate introCert(prefix, *introducee, certName2.getPrefix(-1));
+  keychain.sign(introCert, certName2);
+  validator.addParticipant(introCert);
+  BOOST_CHECK(validator.canTrust(certName3));
+
+  IntroCertificate introCert1(prefix, *anchor, certName3.getPrefix(-1));
+  keychain.sign(introCert1, certName3);
+  validator.addParticipant(introCert1);
+  validator.setAnchor(*introducer);
+  BOOST_CHECK(validator.canTrust(certName2));
+  BOOST_CHECK(validator.canTrust(certName3));
+  BOOST_CHECK(validator.canTrust(certName1));
+
+  IntroCertificate introCert2(prefix, *introducee2, certName4.getPrefix(-1));
+  keychain.sign(introCert2, certName4);
+  validator.addParticipant(introCert2);
+  BOOST_CHECK(validator.canTrust(certName5) == false);
+  BOOST_CHECK(validator.canTrust(certName4) == false);
+
+  IntroCertificate introCert3(prefix, *introducee, certName5.getPrefix(-1));
+  keychain.sign(introCert3, certName5);
+  validator.addParticipant(introCert3);
+  BOOST_CHECK(validator.canTrust(certName5) == false);
+  BOOST_CHECK(validator.canTrust(certName4) == false);
+
+  validator.setAnchor(*introducee2);
+  BOOST_CHECK(validator.canTrust(certName1));
+  BOOST_CHECK(validator.canTrust(certName2));
+  BOOST_CHECK(validator.canTrust(certName3));
+  BOOST_CHECK(validator.canTrust(certName4) == false);
+  BOOST_CHECK(validator.canTrust(certName5));
+
+
+  keychain.deleteIdentity(identity1);
+  keychain.deleteIdentity(identity2);
+  keychain.deleteIdentity(identity3);
+  keychain.deleteIdentity(identity4);
+  keychain.deleteIdentity(identity5);
+}
+
+BOOST_AUTO_TEST_CASE (OfflineValidate)
+{
+  using namespace Sync;
+  using namespace ndn;
+
+  Name prefix("/Sync/TestSyncValidator/OfflineValidate");
+  KeyChain keychain;
+
+  Name identity1("/TestSyncValidator/OfflineValidate-1/"
+                 + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName1 = keychain.createIdentity(identity1);
+  shared_ptr<IdentityCertificate> anchor = keychain.getCertificate(certName1);
+
+  Name identity2("/TestSyncValidator/OfflineValidate-2/"
+                 + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName2 = keychain.createIdentity(identity2);
+  shared_ptr<IdentityCertificate> introducer = keychain.getCertificate(certName2);
+
+  Name identity3("/TestSyncValidator/OfflineValidate-3/"
+                 + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName3 = keychain.createIdentity(identity3);
+  shared_ptr<IdentityCertificate> introducee = keychain.getCertificate(certName3);
+
+  Name identity4("/TestSyncValidator/OfflineValidate-4/"
+                 + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName4 = keychain.createIdentity(identity4);
+  shared_ptr<IdentityCertificate> introducer2 = keychain.getCertificate(certName4);
+
+  Name identity5("/TestSyncValidator/OfflineValidate-5/"
+                 + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName5 = keychain.createIdentity(identity5);
+  shared_ptr<IdentityCertificate> introducee2 = keychain.getCertificate(certName5);
+
+  shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>();
+  shared_ptr<Face> face = make_shared<Face>(ref(*ioService));
+  shared_ptr<SecRuleRelative> rule;
+  SyncValidator validator(prefix, *anchor, *face,
+                          bind(&publishData, _1, _2, _3),
+                          rule);
+
+  validator.addParticipant(*introducer);
+  BOOST_CHECK(validator.canTrust(certName2));
+
+  IntroCertificate introCert(prefix, *introducee, certName2.getPrefix(-1));
+  keychain.sign(introCert, certName2);
+  validator.addParticipant(introCert);
+  BOOST_CHECK(validator.canTrust(certName3));
+
+  IntroCertificate introCert2(prefix, *introducee2, certName4.getPrefix(-1));
+  keychain.sign(introCert2, certName4);
+  validator.addParticipant(introCert2);
+  BOOST_CHECK(validator.canTrust(certName5) == false);
+  BOOST_CHECK(validator.canTrust(certName4) == false);
+
+  validator.setAnchor(*introducer2);
+  BOOST_CHECK(validator.canTrust(certName1) == false);
+  BOOST_CHECK(validator.canTrust(certName2) == false);
+  BOOST_CHECK(validator.canTrust(certName3) == false);
+  BOOST_CHECK(validator.canTrust(certName4));
+  BOOST_CHECK(validator.canTrust(certName5));
+
+  Name dataName1 = prefix;
+  dataName1.append("data-1");
+  shared_ptr<Data> data1 = make_shared<Data>(dataName1);
+  keychain.sign(*data1, certName5);
+
+  validator.validate(*data1,
+		     bind(&onValidated, _1),
+		     bind(&onValidationFailed, _1, _2));
+
+  Name dataName2 = prefix;
+  dataName2.append("data-2");
+  shared_ptr<Data> data2 = make_shared<Data>(dataName2);
+  keychain.sign(*data2, certName1);
+
+  validator.validate(*data2,
+		     bind(&onValidated2, _1),
+		     bind(&onValidationFailed2, _1, _2));
+
+  // ioService->run();
+
+  keychain.deleteIdentity(identity1);
+  keychain.deleteIdentity(identity2);
+  keychain.deleteIdentity(identity3);
+  keychain.deleteIdentity(identity4);
+  keychain.deleteIdentity(identity5);
+}
+
+struct FacesFixture
+{
+  FacesFixture()
+    : regPrefixId(0)
+    , regPrefixId2(0)
+  {}
+
+  void
+  onInterest(ndn::shared_ptr<ndn::Face> face, ndn::shared_ptr<ndn::Data> data)
+  {
+    face->put(*data);
+    face->unsetInterestFilter(regPrefixId);
+  }
+
+  void
+  onInterest2(ndn::shared_ptr<ndn::Face> face, ndn::shared_ptr<ndn::Data> data)
+  {
+    face->put(*data);
+    face->unsetInterestFilter(regPrefixId2);
+  }
+
+  void
+  onRegFailed()
+  {}
+
+  void
+  validate(ndn::shared_ptr<Sync::SyncValidator> validator, ndn::shared_ptr<ndn::Data> data,
+           const ndn::Name& certName3, const ndn::Name& certName4)
+  {
+    validator->validate(*data,
+                        bind(&onValidated, _1),
+                        bind(&onValidationFailed, _1, _2));
+
+
+    BOOST_CHECK(validator->canTrust(certName3));
+    BOOST_CHECK(validator->canTrust(certName4));
+  }
+
+  void
+  terminate(ndn::shared_ptr<ndn::Face> face)
+  {
+    face->getIoService().stop();
+  }
+
+  const ndn::RegisteredPrefixId* regPrefixId;
+  const ndn::RegisteredPrefixId* regPrefixId2;
+};
+
+BOOST_FIXTURE_TEST_CASE(OnlineValidate, FacesFixture)
+{
+  using namespace Sync;
+  using namespace ndn;
+
+  Name prefix("/Sync/TestSyncValidator/OnlineValidate");
+  KeyChain keychain;
+
+  Name identity1("/TestSyncValidator/OnlineValidate-1/"
+                 + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName1 = keychain.createIdentity(identity1);
+  shared_ptr<IdentityCertificate> anchor = keychain.getCertificate(certName1);
+
+  Name identity2("/TestSyncValidator/OnlineValidate-2/"
+                 + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName2 = keychain.createIdentity(identity2);
+  shared_ptr<IdentityCertificate> introducer = keychain.getCertificate(certName2);
+
+  Name identity3("/TestSyncValidator/OnlineValidate-3/"
+                 + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName3 = keychain.createIdentity(identity3);
+  shared_ptr<IdentityCertificate> introducee = keychain.getCertificate(certName3);
+
+  Name identity4("/TestSyncValidator/OnlineValidate-4/"
+                 + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
+  Name certName4 = keychain.createIdentity(identity4);
+  shared_ptr<IdentityCertificate> introducee2 = keychain.getCertificate(certName4);
+
+  shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>();
+  shared_ptr<Face> face = make_shared<Face>(ref(*ioService));
+  shared_ptr<Face> face2 = make_shared<Face>(ref(*ioService));
+
+  shared_ptr<SecRuleRelative> rule;
+  shared_ptr<SyncValidator> validator = shared_ptr<SyncValidator>
+    (new SyncValidator(prefix, *anchor, *face2, bind(&publishData, _1, _2, _3), rule));
+
+  validator->addParticipant(*introducer);
+  BOOST_CHECK(validator->canTrust(certName2));
+
+  shared_ptr<IntroCertificate> introCert = shared_ptr<IntroCertificate>(new IntroCertificate(prefix, *introducee, certName2.getPrefix(-1)));
+  keychain.sign(*introCert, certName2);
+  BOOST_CHECK(validator->canTrust(certName3) == false);
+
+  shared_ptr<IntroCertificate> introCert2 = shared_ptr<IntroCertificate>(new IntroCertificate(prefix, *introducee2, certName3.getPrefix(-1)));
+  keychain.sign(*introCert2, certName3);
+  BOOST_CHECK(validator->canTrust(certName4) == false);
+
+  Name dataName1 = prefix;
+  dataName1.append("data-1");
+  shared_ptr<Data> data1 = make_shared<Data>(dataName1);
+  keychain.sign(*data1, certName4);
+
+  ndn::Scheduler scheduler(*ioService);
+
+  scheduler.scheduleEvent(time::seconds(1),
+                          bind(&FacesFixture::terminate, this, face));
+
+  regPrefixId = face->setInterestFilter(introCert->getName().getPrefix(-1),
+                                       bind(&FacesFixture::onInterest, this, face, introCert),
+                                       bind(&FacesFixture::onRegFailed, this));
+
+  regPrefixId2 = face->setInterestFilter(introCert2->getName().getPrefix(-1),
+					bind(&FacesFixture::onInterest2, this, face, introCert2),
+					bind(&FacesFixture::onRegFailed, this));
+
+  scheduler.scheduleEvent(time::milliseconds(200),
+                          bind(&FacesFixture::validate, this,
+			       validator, data1, certName3, certName4));
+
+  keychain.deleteIdentity(identity1);
+  keychain.deleteIdentity(identity2);
+  keychain.deleteIdentity(identity3);
+  keychain.deleteIdentity(identity4);
+}
+
+BOOST_AUTO_TEST_SUITE_END()