yp test
diff --git a/src/sync-core.cc b/src/sync-core.cc
index 8319c21..164296a 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -25,6 +25,34 @@
 const double SyncCore::WAIT = 0.05;
 const double SyncCore::RANDOM_PERCENT = 0.5;
 
+// for debugging
+static void
+printMsg(SyncStateMsgPtr &msg)
+{
+  cout << " ===== start Msg ======" << endl;
+  int size = msg->state_size();
+  if (size > 0)
+  {
+    int index = 0;
+    while (index < size)
+    {
+      SyncState state = msg->state(index);
+      string strName = state.name();
+      string strLocator = state.locator();
+      sqlite3_int64 seq = state.seq();
+      cout << "Name: " << Name((const unsigned char *)strName.c_str(), strName.size());
+      cout << ", Locator: " << Name((const unsigned char *)strLocator.c_str(), strLocator.size());
+      cout << ", seq: " << seq << endl;
+      index ++;
+    }
+  }
+  else
+  {
+    cout << "Msg size 0" << endl;
+  }
+  cout << " ++++++++ end Msg  ++++++++ \n\n" << endl;
+}
+
 SyncCore::SyncCore(SyncLogPtr syncLog, const Name &userName, const Name &localPrefix, const Name &syncPrefix, const StateMsgCallback &callback, const CcnxWrapperPtr &handle, const SchedulerPtr &scheduler)
          : m_log(syncLog)
          , m_scheduler(scheduler)
@@ -68,6 +96,10 @@
   {
     locator = m_yp[deviceName];
   }
+  else
+  {
+    cout << "self: " << m_userName << ", deviceName: " << deviceName << " not found in yp " << endl;
+  }
   return locator;
 }
 
@@ -96,6 +128,7 @@
   msgToBytes(msg, syncData);
   m_handle->publishData(syncName, syncData, FRESHNESS);
   cout << m_userName << " publishes: " << *oldHash << endl;
+  printMsg(msg);
 
   // no hurry in sending out new Sync Interest; if others send the new Sync Interest first, no problem, we know the new root hash already;
   // this is trying to avoid the situation that the order of SyncData and new Sync Interest gets reversed at receivers
@@ -161,6 +194,7 @@
     msgToBytes(msg, syncData);
     m_handle->publishData(name, syncData, FRESHNESS);
     cout << m_userName << " publishes " << hash << endl;
+    printMsg(msg);
   }
   else
   {
@@ -188,6 +222,8 @@
     Bytes syncData;
     msgToBytes(msg, syncData);
     m_handle->publishData(name, syncData, FRESHNESS);
+    cout << m_userName << " publishes: " << *hash << endl;
+    printMsg(msg);
   }
   else
   {
@@ -251,6 +287,8 @@
     return;
   }
 
+  cout << m_userName << " receives Msg " << endl;
+  printMsg (msg);
   int size = msg->state_size();
   int index = 0;
   while (index < size)
@@ -272,6 +310,7 @@
         m_log->UpdateLocator(deviceName, locatorName);
         WriteLock lock(m_ypMutex);
         m_yp[deviceName] = locatorName;
+        cout << "self: " << m_userName << ", device: " << deviceName << " < == > " << locatorName << endl;
       }
     }
     else
diff --git a/test/test-sync-core.cc b/test/test-sync-core.cc
index 6936d57..e91b0f5 100644
--- a/test/test-sync-core.cc
+++ b/test/test-sync-core.cc
@@ -22,6 +22,13 @@
 BOOST_AUTO_TEST_CASE(SyncCoreTest)
 {
   string dir = "./SyncCoreTest";
+  // clean the test dir
+  path d(dir);
+  if (exists(d))
+  {
+    remove_all(d);
+  }
+
   string dir1 = "./SyncCoreTest/1";
   string dir2 = "./SyncCoreTest/2";
   Name user1("/joker");
@@ -36,12 +43,6 @@
 
   SchedulerPtr scheduler(new Scheduler());
 
-  // clean the test dir
-  path d(dir);
-  if (exists(d))
-  {
-    remove_all(d);
-  }
 
   SyncCore *core1 = new SyncCore(log1, user1, loc1, syncPrefix, bind(callback, _1), c1, scheduler);
   usleep(10000);
@@ -54,16 +55,19 @@
   usleep(100000);
   checkRoots(core1->root(), core2->root());
   BOOST_CHECK_EQUAL(core2->seq(user1), 1);
+  BOOST_CHECK_EQUAL(core2->yp(user1), loc1);
 
   core1->updateLocalState(5);
   usleep(100000);
   checkRoots(core1->root(), core2->root());
   BOOST_CHECK_EQUAL(core2->seq(user1), 5);
+  BOOST_CHECK_EQUAL(core2->yp(user1), loc1);
 
   core2->updateLocalState(10);
   usleep(100000);
   checkRoots(core1->root(), core2->root());
   BOOST_CHECK_EQUAL(core1->seq(user2), 10);
+  BOOST_CHECK_EQUAL(core1->yp(user2), loc2);
 
   // simple simultaneous data generation
   cout << "\n\n\n\n\n\n----------Simultaneous\n";
@@ -75,6 +79,11 @@
   BOOST_CHECK_EQUAL(core1->seq(user2), 15);
   BOOST_CHECK_EQUAL(core2->seq(user1), 11);
 
+  BOOST_CHECK_EQUAL(core1->yp(user1), loc1);
+  BOOST_CHECK_EQUAL(core1->yp(user2), loc2);
+  BOOST_CHECK_EQUAL(core2->yp(user1), loc1);
+  BOOST_CHECK_EQUAL(core2->yp(user2), loc2);
+
   // clean the test dir
   if (exists(d))
   {