src: add SigningInfo and version number to SegmentPublisher

refs: #4783

Change-Id: Id5dc8d6096ff729be0b8d0f971004281e0c09eb1
diff --git a/tests/test-full-sync.cpp b/tests/test-full-sync.cpp
index 01a5375..d8335b0 100644
--- a/tests/test-full-sync.cpp
+++ b/tests/test-full-sync.cpp
@@ -394,6 +394,46 @@
   }
 }
 
+BOOST_AUTO_TEST_CASE(DelayedSecondSegment)
+{
+  addNode(0);
+
+  for (int i = 0; i < 300; i++) {
+    Name prefixToPublish("userNode0-" + to_string(i));
+    nodes[0]->addUserNode(prefixToPublish);
+    nodes[0]->publishName(prefixToPublish);
+  }
+
+  advanceClocks(ndn::time::milliseconds(10), 100);
+
+  Name syncInterestName(syncPrefix);
+  IBLT iblt(40);
+  iblt.appendToName(syncInterestName);
+
+  nodes[0]->onSyncInterest(syncPrefix, Interest(syncInterestName));
+
+  advanceClocks(ndn::time::milliseconds(10));
+
+  BOOST_CHECK_EQUAL(nodes[0]->m_segmentPublisher.m_ims.size(), 2);
+  // Expire contents from segmentPublisher
+  advanceClocks(ndn::time::milliseconds(10), 100);
+  BOOST_CHECK_EQUAL(nodes[0]->m_segmentPublisher.m_ims.size(), 0);
+
+  // Get data name from face and increase segment number to form next interest
+  Name dataName = faces[0]->sentData.front().getName();
+  Name interestName = dataName.getSubName(0, dataName.size() - 1);
+  interestName.appendSegment(1);
+  faces[0]->sentData.clear();
+
+  nodes[0]->onSyncInterest(syncPrefix, Interest(interestName));
+  advanceClocks(ndn::time::milliseconds(10));
+
+  // Should have repopulated SegmentPublisher
+  BOOST_CHECK_EQUAL(nodes[0]->m_segmentPublisher.m_ims.size(), 2);
+  // Should have received the second data segment this time
+  BOOST_CHECK_EQUAL(faces[0]->sentData.front().getName()[-1].toSegment(), 1);
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace psync
\ No newline at end of file
diff --git a/tests/test-partial-producer.cpp b/tests/test-partial-producer.cpp
index 2ff1a5d..9555c7d 100644
--- a/tests/test-partial-producer.cpp
+++ b/tests/test-partial-producer.cpp
@@ -83,6 +83,7 @@
 
   Name syncInterestName(syncPrefix);
   syncInterestName.append("sync");
+  Name syncInterestPrefix = syncInterestName;
 
   BloomFilter bf(20, 0.001);
   bf.appendToName(syncInterestName);
@@ -92,7 +93,7 @@
   Interest syncInterest(syncInterestName);
   syncInterest.setInterestLifetime(time::milliseconds(1000));
   syncInterest.setNonce(1);
-  BOOST_REQUIRE_NO_THROW(producer.onSyncInterest(syncInterestName, syncInterest));
+  BOOST_REQUIRE_NO_THROW(producer.onSyncInterest(syncInterestPrefix, syncInterest));
   face.processEvents(time::milliseconds(10));
   BOOST_CHECK_EQUAL(producer.m_pendingEntries.size(), 1);
 
@@ -100,7 +101,7 @@
 
   // Same interest again - size of pending interest should remain same, but expirationEvent should change
   syncInterest.setNonce(2);
-  BOOST_REQUIRE_NO_THROW(producer.onSyncInterest(syncInterestName, syncInterest));
+  BOOST_REQUIRE_NO_THROW(producer.onSyncInterest(syncInterestPrefix, syncInterest));
   face.processEvents(time::milliseconds(10));
   BOOST_CHECK_EQUAL(producer.m_pendingEntries.size(), 1);
 
diff --git a/tests/test-partial-sync.cpp b/tests/test-partial-sync.cpp
index 6d07644..d4c1784 100644
--- a/tests/test-partial-sync.cpp
+++ b/tests/test-partial-sync.cpp
@@ -362,6 +362,19 @@
   consumers[0]->sendHelloInterest();
   advanceClocks(ndn::time::milliseconds(10));
   BOOST_CHECK_EQUAL(numHelloDataRcvd, 1);
+
+  // Simulate sending delayed interest for second segment
+  Name dataName = face.sentData.back().getName();
+  face.sentData.clear();
+  BOOST_CHECK_EQUAL(producer->m_segmentPublisher.m_ims.size(), 2);
+
+  advanceClocks(ndn::time::milliseconds(1000));
+  BOOST_CHECK_EQUAL(producer->m_segmentPublisher.m_ims.size(), 0);
+
+  producer->onHelloInterest(consumers[0]->m_helloInterestPrefix, Interest(dataName));
+  advanceClocks(ndn::time::milliseconds(10));
+  BOOST_CHECK_EQUAL(producer->m_segmentPublisher.m_ims.size(), 2);
+  BOOST_CHECK_EQUAL(face.sentData.front().getName()[-1].toSegment(), 1);
 }
 
 BOOST_AUTO_TEST_CASE(SegmentedSync)
@@ -382,6 +395,13 @@
   advanceClocks(ndn::time::milliseconds(10));
   BOOST_CHECK_EQUAL(numHelloDataRcvd, 1);
 
+  // To be used later to simulate sending delayed segmented interest
+  ndn::Name syncInterestName(consumers[0]->m_syncInterestPrefix);
+  consumers[0]->m_bloomFilter.appendToName(syncInterestName);
+  syncInterestName.append(consumers[0]->m_iblt);
+  syncInterestName.appendVersion();
+  syncInterestName.appendSegment(1);
+
   oldSeqMap = producer->m_prefixes;
   for (int i = 1; i < 10; i++) {
     producer->updateSeqNo(longNameToExceedDataSize.toUri() + "-" + to_string(i), 1);
@@ -392,6 +412,20 @@
 
   advanceClocks(ndn::time::milliseconds(1500));
   BOOST_CHECK_EQUAL(numSyncDataRcvd, 1);
+
+  // Simulate sending delayed interest for second segment
+  face.sentData.clear();
+  consumerFaces[0]->sentData.clear();
+
+  BOOST_CHECK_EQUAL(producer->m_segmentPublisher.m_ims.size(), 2);
+
+  advanceClocks(ndn::time::milliseconds(2000));
+  BOOST_CHECK_EQUAL(producer->m_segmentPublisher.m_ims.size(), 0);
+
+  producer->onSyncInterest(consumers[0]->m_syncInterestPrefix, Interest(syncInterestName));
+  advanceClocks(ndn::time::milliseconds(10));
+  BOOST_CHECK_EQUAL(producer->m_segmentPublisher.m_ims.size(), 2);
+  BOOST_CHECK_EQUAL(face.sentData.front().getName()[-1].toSegment(), 1);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/test-segment-publisher.cpp b/tests/test-segment-publisher.cpp
index 39881d8..db81f30 100644
--- a/tests/test-segment-publisher.cpp
+++ b/tests/test-segment-publisher.cpp
@@ -126,7 +126,7 @@
   BOOST_CHECK_EQUAL(numRepliesFromStore, 2);
 
   numRepliesFromStore = 0;
-  face.expressInterest(Interest(Name("/hello/world/").appendSegment(0)),
+  face.expressInterest(Interest(Name("/hello/world/")),
                        [this] (const Interest& interest, const Data& data) {
                          numComplete++;
                        },