src/lsa-segment-storage: fix convergence w/o content store
refs: #4430
Change-Id: I5124e9fd49bd9850c904c31d221b42b4249553a3
diff --git a/tests/publisher/test-segment-publisher.cpp b/tests/publisher/test-segment-publisher.cpp
index e1a7232..a70e57f 100644
--- a/tests/publisher/test-segment-publisher.cpp
+++ b/tests/publisher/test-segment-publisher.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -110,8 +110,8 @@
m_buffer.appendByteArray(payload.value(), payload.value_size());
// uint64_t segmentNo = data.getName()[-1].toSegment();
- if (data.getFinalBlockId() != data.getName()[-1]) {
- return;
+ if (data.getFinalBlock().value_or(ndn::name::Component("")) != data.getName()[-1]) {
+ return;
}
// wrap data in a single Content TLV for easy parsing
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
index 04efefc..13b0b19 100644
--- a/tests/test-common.hpp
+++ b/tests/test-common.hpp
@@ -153,7 +153,7 @@
}
auto data = make_shared<ndn::Data>(name);
- data->setFinalBlockId(name[-1]);
+ data->setFinalBlock(name[-1]);
data->setContent(std::forward<ContentArgs>(contentArgs)...);
this->signDatasetReply(*data);
m_face.receive(*data);
diff --git a/tests/test-lsa-segment-storage.cpp b/tests/test-lsa-segment-storage.cpp
index e690ae8..85806c2 100644
--- a/tests/test-lsa-segment-storage.cpp
+++ b/tests/test-lsa-segment-storage.cpp
@@ -42,7 +42,6 @@
, nlsr(m_ioService, m_scheduler, face, m_keyChain)
, lsdb(nlsr.getLsdb())
, lsaStorage(lsdb.getLsaStorage())
- , lsaGeneratedBeforeNow(180)
{
}
@@ -53,7 +52,7 @@
ndn::Name s2{"name2"};
NamePrefixList npl1{s1, s2};
NameLsa nameLsa("/ndn/other-site/%C1.Router/other-router", 12,
- ndn::time::system_clock::now() - lsaGeneratedBeforeNow, npl1);
+ ndn::time::system_clock::now() + ndn::time::seconds(LSA_REFRESH_TIME_DEFAULT), npl1);
return nameLsa.serialize();
}
@@ -66,7 +65,7 @@
std::string content = makeLsaContent();
lsaSegment->setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.length());
if (isFinal) {
- lsaSegment->setFinalBlockId(lsaSegment->getName()[-1]);
+ lsaSegment->setFinalBlock(lsaSegment->getName()[-1]);
}
return signData(lsaSegment);
@@ -92,7 +91,6 @@
Nlsr nlsr;
Lsdb& lsdb;
LsaSegmentStorage& lsaStorage;
- ndn::time::seconds lsaGeneratedBeforeNow;
};
BOOST_FIXTURE_TEST_SUITE(TestLsaSegmentStorage, LsaSegmentStorageFixture)
@@ -174,7 +172,11 @@
BOOST_CHECK(lsaStorage.getLsaSegment(ndn::Interest(lsaInterestName)) != nullptr);
- advanceClocks(ndn::time::milliseconds(lsaGeneratedBeforeNow), 10);
+ // Make sure it was not deleted earlier somehow
+ advanceClocks(ndn::time::seconds(100), 10);
+ BOOST_CHECK(lsaStorage.getLsaSegment(ndn::Interest(lsaInterestName)) != nullptr);
+
+ advanceClocks(ndn::time::seconds(LSA_REFRESH_TIME_DEFAULT), 10);
BOOST_CHECK(lsaStorage.getLsaSegment(ndn::Interest(lsaInterestName)) == nullptr);
}