update sync-core tests
diff --git a/src/sync-core.cc b/src/sync-core.cc
index c325eb1..d90c463 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -288,7 +288,10 @@
m_rootHash = m_log.RememberStateInStateLog();
SyncStateMsgPtr diff = m_log.FindStateDifferences(*oldHash, *m_rootHash);
- m_stateMsgCallback(diff);
+ if (diff->state_size() > 0)
+ {
+ m_stateMsgCallback(diff);
+ }
}
void
@@ -345,3 +348,9 @@
bytes.resize(size);
msg->SerializeToArray(head(bytes), size);
}
+
+sqlite3_int64
+SyncCore::seq(const Name &name)
+{
+ return m_log.SeqNo(name);
+}
diff --git a/src/sync-core.h b/src/sync-core.h
index 998be7d..d8c9675 100644
--- a/src/sync-core.h
+++ b/src/sync-core.h
@@ -86,9 +86,13 @@
void
recover(const HashPtr &hash);
+// ------------------ only used in test -------------------------
HashPtr
root() { return m_rootHash; }
+ sqlite3_int64
+ seq(const Name &name);
+
protected:
void
sendSyncInterest();
diff --git a/src/sync-log.cc b/src/sync-log.cc
index c9f125a..8375142 100644
--- a/src/sync-log.cc
+++ b/src/sync-log.cc
@@ -34,6 +34,7 @@
cout << q << endl;
}
+
SyncLog::SyncLog (const boost::filesystem::path &path, const std::string &localName)
: DbHelper (path)
, m_localName (localName)
@@ -399,3 +400,19 @@
return msg;
}
+
+sqlite3_int64
+SyncLog::SeqNo(const Name &name)
+{
+ sqlite3_stmt *stmt;
+ sqlite3_int64 seq = -1;
+ sqlite3_prepare_v2 (m_db, "SELECT seq_no FROM SyncNodes WHERE device_name=?;", -1, &stmt, 0);
+ Ccnx::CcnxCharbufPtr nameBuf = name;
+ sqlite3_bind_blob (stmt, 1, nameBuf->buf (), nameBuf->length (), SQLITE_STATIC);
+ if (sqlite3_step (stmt) == SQLITE_ROW)
+ {
+ seq = sqlite3_column_int64 (stmt, 0);
+ }
+
+ return seq;
+}
diff --git a/src/sync-log.h b/src/sync-log.h
index 3ab8489..0a59516 100644
--- a/src/sync-log.h
+++ b/src/sync-log.h
@@ -74,6 +74,10 @@
SyncStateMsgPtr
FindStateDifferences (const Hash &oldHash, const Hash &newHash);
+ //-------- only used in test -----------------
+ sqlite3_int64
+ SeqNo(const Ccnx::Name &name);
+
protected:
void
UpdateDeviceSeqNo (sqlite3_int64 deviceId, sqlite3_int64 seqNo);