security: Integrate certificate exchanging into sync

Change-Id: I6ea284b0683d75013f6b72845d894eaed29e468c
diff --git a/tests/test-socket.cc b/tests/test-socket.cc
index e4791c2..a10a2f1 100644
--- a/tests/test-socket.cc
+++ b/tests/test-socket.cc
@@ -142,93 +142,94 @@
     : m_face1(new ndn::Face(ioService))
     , m_face2(new ndn::Face(ioService))
     , m_face3(new ndn::Face(ioService))
-    , m_p1("/irl.cs.ucla.edu")
-    , m_p2("/yakshi.org")
-    , m_p3("/google.com")
-    , m_syncPrefix("/let/us/sync")
+    , m_name1("/irl.cs.ucla.edu/" + boost::lexical_cast<std::string>(ndn::time::now()))
+    , m_name2("/yakshi.org/" + boost::lexical_cast<std::string>(ndn::time::now()))
+    , m_name3("/google.com/" + boost::lexical_cast<std::string>(ndn::time::now()))
   {
-    ndn::KeyChain keyChain;
-    m_name1 = m_p1;
-    m_name1.append(boost::lexical_cast<std::string>(ndn::time::now()));
-    ndn::Name certName1 = keyChain.createIdentity(m_name1);
-    m_id1 = keyChain.getCertificate(certName1);
+    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_name2 = m_p2;
-    m_name2.append(boost::lexical_cast<std::string>(ndn::time::now()));
-    ndn::Name certName2 = keyChain.createIdentity(m_name2);
-    m_id2 = keyChain.getCertificate(certName2);
-
-    m_name3 = m_p3;
-    m_name3.append(boost::lexical_cast<std::string>(ndn::time::now()));
-    ndn::Name certName3 = keyChain.createIdentity(m_name3);
-    m_id3 = keyChain.getCertificate(certName3);
-
-    ndn::shared_ptr<ndn::SecRuleRelative> rule = ndn::make_shared<ndn::SecRuleRelative>("^(<>*)<><>$",
-                                                                                        "^(<>*)<><KEY><ksk-.*><ID-CERT>$",
-                                                                                        "==", "\\1", "\\1", true);
-
-    m_v1 = ndn::make_shared<SyncValidator>(m_syncPrefix, *m_id1, m_face1, rule);
-    m_v1->addParticipant(*m_id2);
-    m_v2 = ndn::make_shared<SyncValidator>(m_syncPrefix, *m_id2, m_face2, rule);
-    m_v2->addParticipant(*m_id1);
-    m_v2->addParticipant(*m_id3);
-    m_v3 = ndn::make_shared<SyncValidator>(m_syncPrefix, *m_id3, m_face3, rule);
-    m_v3->addParticipant(*m_id2);
+    m_rule = ndn::make_shared<ndn::SecRuleRelative>("^(<>*)<><>$",
+                                                    "^(<>*)<><KEY><ksk-.*><ID-CERT>$",
+                                                    "==", "\\1", "\\1", true);
   }
 
   void
   createSyncSocket1()
   {
     _LOG_DEBUG ("s1");
-    m_s1 = ndn::make_shared<SyncSocket>(m_syncPrefix, m_name1, m_v1, m_face1, 
-                                   bind(&TestSocketApp::fetchAll, &m_a1, _1, _2), 
-                                   bind(&TestSocketApp::pass, &m_a1, _1));
+
+    m_s1 = ndn::make_shared<SyncSocket>("/let/us/sync",
+                                        "/irl.cs.ucla.edu",
+                                        0,
+                                        *m_id1,
+                                        m_rule,
+                                        m_face1,
+                                        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::make_shared<SyncSocket>(m_syncPrefix, m_name2, m_v2, m_face2, 
-                                   bind(&TestSocketApp::fetchAll, &m_a2, _1, _2), 
-                                   bind(&TestSocketApp::pass, &m_a2, _1));
+
+    m_s2 = ndn::make_shared<SyncSocket>("/let/us/sync",
+                                        "/yakshi.org",
+                                        0,
+                                        *m_id2,
+                                        m_rule,
+                                        m_face2,
+                                        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::make_shared<SyncSocket>(m_syncPrefix, m_name3, m_v3, m_face3, 
-                                   bind(&TestSocketApp::fetchAll, &m_a3, _1, _2), 
-                                   bind(&TestSocketApp::pass, &m_a3, _1));
+
+    m_s3 = ndn::make_shared<SyncSocket>("/let/us/sync",
+                                        "/google.com",
+                                        0,
+                                        *m_id3,
+                                        m_rule, 
+                                        m_face3, 
+                                        bind(&TestSocketApp::fetchAll, &m_a3, _1, _2), 
+                                        bind(&TestSocketApp::pass, &m_a3, _1));
+    m_s3->addParticipant(*m_id2);
   }
 
   void
-  publishSocket1(uint32_t session, string data)
+  publishSocket1(string data)
   {
     _LOG_DEBUG ("s1 publish");
-    m_s1->publishData (m_p1, session, data.c_str(), data.size(), 1000); 
+    m_s1->publishData (reinterpret_cast<const uint8_t*>(data.c_str()), data.size(), 1000); 
   }
 
   void
-  publishSocket2(uint32_t session, string data)
+  publishSocket2(string data)
   {
     _LOG_DEBUG ("s2 publish");
-    m_s2->publishData (m_p2, session, data.c_str(), data.size(), 1000); 
+    m_s2->publishData (reinterpret_cast<const uint8_t*>(data.c_str()), data.size(), 1000); 
   }
 
   void
-  publishSocket3(uint32_t session, string data)
+  publishSocket3(string data)
   {
     _LOG_DEBUG ("s3 publish");
-    m_s3->publishData (m_p3, session, data.c_str(), data.size(), 1000); 
+    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 = m_p1;
+    ndn::Name name("/irl.cs.ucla.edu");
     name.append(suffix);
     m_a1.set (name, data.c_str(), data.size()); 
   }
@@ -237,7 +238,7 @@
   setSocket2(string suffix, string data)
   {
     _LOG_DEBUG ("a2 set");
-    ndn::Name name = m_p2;
+    ndn::Name name("/yakshi.org");
     name.append(suffix);
     m_a2.set (name, data.c_str(), data.size()); 
   }
@@ -246,7 +247,7 @@
   setSocket3(string suffix, string data)
   {
     _LOG_DEBUG ("a3 set");
-    ndn::Name name = m_p3;
+    ndn::Name name("/google.com");
     name.append(suffix);
     m_a3.set (name, data.c_str(), data.size()); 
   }
@@ -264,26 +265,21 @@
     m_s1.reset();
     m_s2.reset();
     m_s3.reset();
-    m_v1.reset();
-    m_v2.reset();
-    m_v3.reset();
 
-    ndn::KeyChain keyChain;
-    keyChain.deleteIdentity(m_name1);
-    keyChain.deleteIdentity(m_name2);
-    keyChain.deleteIdentity(m_name3);
+    m_keyChain.deleteIdentity(m_name1);
+    m_keyChain.deleteIdentity(m_name2);
+    m_keyChain.deleteIdentity(m_name3);
 
   }
 
+  ndn::KeyChain m_keyChain;
+  ndn::shared_ptr<ndn::SecRuleRelative> m_rule;
 
-  TestSocketApp m_a1, m_a2, m_a3;
-  ndn::shared_ptr<ndn::IdentityCertificate> m_id1, m_id2, m_id3;
-  ndn::shared_ptr<Sync::SyncValidator> m_v1, m_v2, m_v3;
   ndn::shared_ptr<ndn::Face> m_face1, m_face2, m_face3;
   ndn::Name m_name1, m_name2, m_name3;
-  ndn::Name m_p1, m_p2, m_p3;
+  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;
-  ndn::Name m_syncPrefix;
 };
 
 class TestSet2{
@@ -291,76 +287,77 @@
   TestSet2(ndn::shared_ptr<boost::asio::io_service> ioService)
     : m_face1(new ndn::Face(ioService))
     , m_face2(new ndn::Face(ioService))
-    , m_p1("/xiaonei.com")
-    , m_p2("/mitbbs.com")
-    , m_syncPrefix("/this/is/the/prefix")
+    , m_name1("/xiaonei.com/" + boost::lexical_cast<std::string>(ndn::time::now()))
+    , m_name2("/mitbbs.com/" + boost::lexical_cast<std::string>(ndn::time::now()))
   {
-    ndn::KeyChain keyChain;
-    m_name1 = m_p1;
-    m_name1.append(boost::lexical_cast<string>(ndn::time::now()));
-    ndn::Name certName1 = keyChain.createIdentity(m_name1);
-    m_id1 = keyChain.getCertificate(certName1);
+    m_id1 = m_keyChain.getCertificate(m_keyChain.createIdentity(m_name1));
+    m_id2 = m_keyChain.getCertificate(m_keyChain.createIdentity(m_name2));
 
-    m_name2 = m_p2;
-    m_name2.append(boost::lexical_cast<string>(ndn::time::now()));
-    ndn::Name certName2 = keyChain.createIdentity(m_name2);
-    m_id2 = keyChain.getCertificate(certName2);
-
-    ndn::shared_ptr<ndn::SecRuleRelative> rule = ndn::make_shared<ndn::SecRuleRelative>("^(<>*)<><>$",
-                                                                                        "^(<>*)<><KEY><ksk-.*><ID-CERT>$",
-                                                                                        "==", "\\1", "\\1", true);
-
-    m_v1 = ndn::make_shared<SyncValidator>(m_syncPrefix, *m_id1, m_face1, rule);
-    m_v1->addParticipant(*m_id2);
-    m_v2 = ndn::make_shared<SyncValidator>(m_syncPrefix, *m_id2, m_face2, rule);
-    m_v2->addParticipant(*m_id1);
-
+    m_rule = ndn::make_shared<ndn::SecRuleRelative>("^(<>*)<><>$",
+                                                    "^(<>*)<><KEY><ksk-.*><ID-CERT>$",
+                                                    "==", "\\1", "\\1", true);
   }
 
   void
   createSyncSocket1()
   {
     _LOG_DEBUG ("s1");
-    m_s1 = ndn::make_shared<SyncSocket>(m_syncPrefix, m_name1, m_v1, m_face1, 
-                                   bind(&TestSocketApp::fetchNumbers, &m_a1, _1, _2), 
-                                   bind(&TestSocketApp::pass, &m_a1, _1));
+    
+    m_s1 = ndn::make_shared<SyncSocket>("/this/is/the/prefix",
+                                        "/xiaonei.com",
+                                        0,
+                                        *m_id1,
+                                        m_rule,
+                                        m_face1,
+                                        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::make_shared<SyncSocket>(m_syncPrefix, m_name2, m_v2, m_face2, 
-                                   bind(&TestSocketApp::fetchNumbers, &m_a2, _1, _2), 
-                                   bind(&TestSocketApp::pass, &m_a2, _1));
+
+    m_s2 = ndn::make_shared<SyncSocket>("/this/is/the/prefix",
+                                        "/mitbbs.com",
+                                        0,
+                                        *m_id2,
+                                        m_rule,
+                                        m_face2,
+                                        bind(&TestSocketApp::fetchNumbers, &m_a2, _1, _2), 
+                                        bind(&TestSocketApp::pass, &m_a2, _1));
+
+    m_s2->addParticipant(*m_id1);
   }
   
   void
-  publishSocket1(uint32_t session, string data)
+  publishSocket1(string data)
   {
     _LOG_DEBUG ("s1 publish");
-    m_s1->publishData (m_p1, session, data.c_str(), data.size(), 1000); 
+    m_s1->publishData (reinterpret_cast<const uint8_t*>(data.c_str()), data.size(), 1000); 
   }
 
   void
-  publishSocket2(uint32_t session, string data)
+  publishSocket2(string data)
   {
     _LOG_DEBUG ("s2 publish");
-    m_s2->publishData (m_p2, session, data.c_str(), data.size(), 1000); 
+    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 (m_p1, ptr, size); 
+    m_a1.setNum ("/xiaonei.com", ptr, size); 
   }
 
   void
   setSocket2(const char* ptr, size_t size)
   {
     _LOG_DEBUG ("a2 setNum");
-    m_a2.setNum (m_p2, ptr, size); 
+    m_a2.setNum ("/mitbbs.com", ptr, size); 
   }
 
   void
@@ -378,22 +375,19 @@
   {
     m_s1.reset();
     m_s2.reset();
-    m_v1.reset();
-    m_v2.reset();
 
-    ndn::KeyChain keyChain;
-    keyChain.deleteIdentity(m_name1);
-    keyChain.deleteIdentity(m_name2);
+    m_keyChain.deleteIdentity(m_name1);
+    m_keyChain.deleteIdentity(m_name2);
   }
 
+  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<Sync::SyncValidator> m_v1, m_v2;
   ndn::shared_ptr<ndn::Face> m_face1, m_face2;
-  ndn::Name m_p1, m_p2;
   ndn::Name m_name1, m_name2;
   ndn::shared_ptr<SyncSocket> m_s1, m_s2;
-  ndn::Name m_syncPrefix;
 };
 
 BOOST_AUTO_TEST_CASE (AppSocketTest1)
@@ -408,34 +402,34 @@
   scheduler.scheduleEvent(ndn::time::seconds(0.05), ndn::bind(&TestSet1::createSyncSocket2, &testSet1));
   scheduler.scheduleEvent(ndn::time::seconds(0.10), ndn::bind(&TestSet1::createSyncSocket3, &testSet1));
   string data0 = "Very funny Scotty, now beam down my clothes";
-  scheduler.scheduleEvent(ndn::time::seconds(0.15), ndn::bind(&TestSet1::publishSocket1, &testSet1, 0, data0));
-  scheduler.scheduleEvent(ndn::time::seconds(1.15), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/0", data0));
+  scheduler.scheduleEvent(ndn::time::seconds(0.15), ndn::bind(&TestSet1::publishSocket1, &testSet1, data0));
+  scheduler.scheduleEvent(ndn::time::seconds(1.15), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/1", data0));
   scheduler.scheduleEvent(ndn::time::seconds(1.16), 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::seconds(1.17), ndn::bind(&TestSet1::publishSocket1, &testSet1, 0, data1));
-  scheduler.scheduleEvent(ndn::time::seconds(1.18), ndn::bind(&TestSet1::publishSocket1, &testSet1, 0, data2));
-  scheduler.scheduleEvent(ndn::time::seconds(2.15), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/1", data1));
-  scheduler.scheduleEvent(ndn::time::seconds(2.16), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/2", data2));
+  scheduler.scheduleEvent(ndn::time::seconds(1.17), ndn::bind(&TestSet1::publishSocket1, &testSet1, data1));
+  scheduler.scheduleEvent(ndn::time::seconds(1.18), ndn::bind(&TestSet1::publishSocket1, &testSet1, data2));
+  scheduler.scheduleEvent(ndn::time::seconds(2.15), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/2", data1));
+  scheduler.scheduleEvent(ndn::time::seconds(2.16), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/3", data2));
   scheduler.scheduleEvent(ndn::time::seconds(2.17), 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::seconds(3.18), ndn::bind(&TestSet1::publishSocket3, &testSet1, 0, data3));
-  scheduler.scheduleEvent(ndn::time::seconds(3.20), ndn::bind(&TestSet1::publishSocket2, &testSet1, 0, data4));
-  scheduler.scheduleEvent(ndn::time::seconds(3.21), ndn::bind(&TestSet1::publishSocket2, &testSet1, 0, data5));
-  scheduler.scheduleEvent(ndn::time::seconds(4.21), ndn::bind(&TestSet1::setSocket3, &testSet1, "/0/0", data3));
-  scheduler.scheduleEvent(ndn::time::seconds(4.22), ndn::bind(&TestSet1::setSocket2, &testSet1, "/0/0", data4));
-  scheduler.scheduleEvent(ndn::time::seconds(4.23), ndn::bind(&TestSet1::setSocket2, &testSet1, "/0/1", data5));
-  scheduler.scheduleEvent(ndn::time::seconds(4.30), ndn::bind(&TestSet1::check, &testSet1, 3));
+  scheduler.scheduleEvent(ndn::time::seconds(3.18), ndn::bind(&TestSet1::publishSocket3, &testSet1, data3));
+  scheduler.scheduleEvent(ndn::time::seconds(3.20), ndn::bind(&TestSet1::publishSocket2, &testSet1, data4));
+  scheduler.scheduleEvent(ndn::time::seconds(3.21), ndn::bind(&TestSet1::publishSocket2, &testSet1, data5));
+  scheduler.scheduleEvent(ndn::time::seconds(4.71), ndn::bind(&TestSet1::setSocket3, &testSet1, "/0/1", data3));
+  scheduler.scheduleEvent(ndn::time::seconds(4.72), ndn::bind(&TestSet1::setSocket2, &testSet1, "/0/2", data4));
+  scheduler.scheduleEvent(ndn::time::seconds(4.73), ndn::bind(&TestSet1::setSocket2, &testSet1, "/0/3", data5));
+  scheduler.scheduleEvent(ndn::time::seconds(4.80), 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::seconds(5.50), ndn::bind(&TestSet1::publishSocket1, &testSet1, 0, data6));
-  scheduler.scheduleEvent(ndn::time::seconds(5.50), ndn::bind(&TestSet1::publishSocket2, &testSet1, 0, data7));
-  scheduler.scheduleEvent(ndn::time::seconds(6.80), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/3", data6));
-  scheduler.scheduleEvent(ndn::time::seconds(6.80), ndn::bind(&TestSet1::setSocket2, &testSet1, "/0/2", data7));
+  scheduler.scheduleEvent(ndn::time::seconds(5.50), ndn::bind(&TestSet1::publishSocket1, &testSet1, data6));
+  scheduler.scheduleEvent(ndn::time::seconds(5.50), ndn::bind(&TestSet1::publishSocket2, &testSet1, data7));
+  scheduler.scheduleEvent(ndn::time::seconds(6.80), ndn::bind(&TestSet1::setSocket1, &testSet1, "/0/4", data6));
+  scheduler.scheduleEvent(ndn::time::seconds(6.80), ndn::bind(&TestSet1::setSocket2, &testSet1, "/0/4", data7));
   scheduler.scheduleEvent(ndn::time::seconds(6.90), ndn::bind(&TestSet1::check, &testSet1, 4));
   scheduler.scheduleEvent(ndn::time::seconds(7.00), ndn::bind(&TestSet1::done, &testSet1));
 
@@ -452,12 +446,12 @@
   scheduler.scheduleEvent(ndn::time::seconds(0.05), 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::seconds(0.10), ndn::bind(&TestSet2::publishSocket1, &testSet2, 0, data0));
+  scheduler.scheduleEvent(ndn::time::seconds(0.10), ndn::bind(&TestSet2::publishSocket1, &testSet2, data0));
   scheduler.scheduleEvent(ndn::time::seconds(0.15), ndn::bind(&TestSet2::setSocket1, &testSet2, (const char *) num, sizeof (num)));
   scheduler.scheduleEvent(ndn::time::seconds(1.00), 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::seconds(1.10), ndn::bind(&TestSet2::publishSocket2, &testSet2, 0, data1));
+  scheduler.scheduleEvent(ndn::time::seconds(1.10), ndn::bind(&TestSet2::publishSocket2, &testSet2, data1));
   scheduler.scheduleEvent(ndn::time::seconds(1.15), ndn::bind(&TestSet2::setSocket2, &testSet2, (const char *) newNum, sizeof (newNum)));
   scheduler.scheduleEvent(ndn::time::seconds(2.00), ndn::bind(&TestSet2::check, &testSet2, 30));
   scheduler.scheduleEvent(ndn::time::seconds(7.00), ndn::bind(&TestSet2::done, &testSet2));
diff --git a/tests/test-sync-logic.cc b/tests/test-sync-logic.cc
index 76c5fc5..ebce9c0 100644
--- a/tests/test-sync-logic.cc
+++ b/tests/test-sync-logic.cc
@@ -102,10 +102,10 @@
                   ndn::shared_ptr<Handler> h)
   { 
     ndn::Name identity("/tmp-" + boost::lexical_cast<std::string>(ndn::time::now()));
-    m_keyChain.createIdentity(identity);
+    ndn::shared_ptr<ndn::IdentityCertificate> cert = m_keyChain.getCertificate(m_keyChain.createIdentity(identity));
     m_faces[index] = ndn::make_shared<ndn::Face>(m_ioService);
     m_l[index] = new SyncLogic(ndn::Name("/bcast"), 
-                               identity,
+                               *cert,
                                m_validator, m_faces[index], 
                                bind (&Handler::wrapper, &*h, _1), 
                                bind (&Handler::onRemove, &*h, _1)); 
diff --git a/tests/test-sync-validator.cc b/tests/test-sync-validator.cc
index ca7078b..9049edc 100644
--- a/tests/test-sync-validator.cc
+++ b/tests/test-sync-validator.cc
@@ -8,28 +8,37 @@
 
 BOOST_AUTO_TEST_SUITE(TestSyncValidator)
 
-void onValidated(const ndn::shared_ptr<const ndn::Data>& data)
+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)
+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)
+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)
+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;
@@ -60,7 +69,10 @@
 
   shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>();
   shared_ptr<Face> face = make_shared<Face>(ioService);
-  SyncValidator validator(prefix, *anchor, face);
+  shared_ptr<SecRuleRelative> rule;
+  SyncValidator validator(prefix, *anchor, face, 
+                          bind(&publishData, _1, _2, _3),
+                          rule);
 
   validator.addParticipant(*introducer);
   BOOST_CHECK(validator.canTrust(certName2));
@@ -135,7 +147,10 @@
 
   shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>();
   shared_ptr<Face> face = make_shared<Face>(ioService);
-  SyncValidator validator(prefix, *anchor, face);
+  shared_ptr<SecRuleRelative> rule;
+  SyncValidator validator(prefix, *anchor, face,
+                          bind(&publishData, _1, _2, _3),
+                          rule);
 
   validator.addParticipant(*introducer);
   BOOST_CHECK(validator.canTrust(certName2));
@@ -211,7 +226,10 @@
 
   shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>();
   shared_ptr<Face> face = make_shared<Face>(ioService);
-  SyncValidator validator(prefix, *anchor, face);
+  shared_ptr<SecRuleRelative> rule;
+  SyncValidator validator(prefix, *anchor, face,
+                          bind(&publishData, _1, _2, _3),
+                          rule);
 
   validator.addParticipant(*introducer);
   BOOST_CHECK(validator.canTrust(certName2));