table: Offload the implicit digest calculation to the library
Change-Id: I8577ec3ee194d639cce74b53fb5f02c7e718cbc3
Refs: #1678
diff --git a/tests/daemon/table/cs.cpp b/tests/daemon/table/cs.cpp
index 3e41781..3592290 100644
--- a/tests/daemon/table/cs.cpp
+++ b/tests/daemon/table/cs.cpp
@@ -165,11 +165,13 @@
Name name2("/insert/fresh");
shared_ptr<Data> data2 = makeData(name2);
data2->setFreshnessPeriod(time::milliseconds(5000));
+ signData(data2);
cs.insert(*data2);
Name name("/insert/expire");
shared_ptr<Data> data = makeData(name);
data->setFreshnessPeriod(time::milliseconds(500));
+ signData(data);
cs.insert(*data);
BOOST_CHECK_EQUAL(cs.size(), 2);
@@ -264,7 +266,8 @@
entry->setData(*data, false);
BOOST_CHECK_EQUAL_COLLECTIONS(digest1->begin(), digest1->end(),
- entry->getDigest()->begin(), entry->getDigest()->end());
+ entry->getFullName()[-1].value_begin(),
+ entry->getFullName()[-1].value_end());
}
BOOST_AUTO_TEST_CASE(InsertCanonical)
@@ -429,6 +432,7 @@
Name name("/insert/nonfresh");
shared_ptr<Data> data = makeData(name);
data->setFreshnessPeriod(time::milliseconds(500));
+ signData(data);
cs.insert(*data);
sleep(1);
@@ -477,6 +481,7 @@
fakeSignature.setKeyLocator(locator);
data2->setSignature(fakeSignature);
+ data2->wireEncode();
cs.insert(*data2);
@@ -602,6 +607,7 @@
shared_ptr<Data> data = makeData(name);
data->setFreshnessPeriod(time::milliseconds(99999));
data->setContent(reinterpret_cast<const uint8_t*>(&id), sizeof(id));
+ signData(data);
m_cs.insert(*data);
}
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
index 6b67f2f..9c60c77 100644
--- a/tests/test-common.hpp
+++ b/tests/test-common.hpp
@@ -67,10 +67,8 @@
}
inline shared_ptr<Data>
-makeData(const Name& name)
+signData(const shared_ptr<Data>& data)
{
- shared_ptr<Data> data = make_shared<Data>(name);
-
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue,
reinterpret_cast<const uint8_t*>(0), 0));
@@ -80,6 +78,15 @@
return data;
}
+inline shared_ptr<Data>
+makeData(const Name& name)
+{
+ shared_ptr<Data> data = make_shared<Data>(name);
+
+ return signData(data);
+}
+
+
} // namespace tests
} // namespace nfd