State: reset wire after adding names; fix tests when zlib is disabled
refs: #5083, #5077
Change-Id: I48f24ad53d676036f6b03cc0472be9bb5026016e
diff --git a/tests/test-full-sync.cpp b/tests/test-full-sync.cpp
index 34bef0c..1f5c6bb 100644
--- a/tests/test-full-sync.cpp
+++ b/tests/test-full-sync.cpp
@@ -398,16 +398,26 @@
{
addNode(0);
- for (int i = 0; i < 2000; i++) {
- Name prefixToPublish("userNode0-" + to_string(i));
+ int i = 0;
+ State state;
+
+ std::shared_ptr<ndn::Buffer> compressed;
+ do {
+ Name prefixToPublish("userNode0-" + to_string(i++));
nodes[0]->addUserNode(prefixToPublish);
nodes[0]->publishName(prefixToPublish);
- }
+
+ state.addContent(ndn::Name(prefixToPublish).appendNumber(nodes[0]->m_prefixes[prefixToPublish]));
+
+ auto block = state.wireEncode();
+ compressed = compress(nodes[0]->m_contentCompression, block.wire(), block.size());
+
+ } while (compressed->size() < (ndn::MAX_NDN_PACKET_SIZE >> 1));
advanceClocks(ndn::time::milliseconds(10), 100);
Name syncInterestName(syncPrefix);
- IBLT iblt(40);
+ IBLT iblt(40, nodes[0]->m_ibltCompression);
iblt.appendToName(syncInterestName);
nodes[0]->onSyncInterest(syncPrefix, Interest(syncInterestName));
diff --git a/tests/test-iblt.cpp b/tests/test-iblt.cpp
index 5be1d80..e99bf6e 100644
--- a/tests/test-iblt.cpp
+++ b/tests/test-iblt.cpp
@@ -34,8 +34,8 @@
{
int size = 10;
- IBLT iblt1(size);
- IBLT iblt2(size);
+ IBLT iblt1(size, CompressionScheme::DEFAULT);
+ IBLT iblt2(size, CompressionScheme::DEFAULT);
BOOST_CHECK_EQUAL(iblt1, iblt2);
std::string prefix = Name("/test/memphis").appendNumber(1).toUri();
@@ -55,7 +55,7 @@
{
int size = 10;
- IBLT iblt(size);
+ IBLT iblt(size, CompressionScheme::DEFAULT);
std::string prefix = Name("/test/memphis").appendNumber(1).toUri();
uint32_t newHash = murmurHash3(11, prefix);
iblt.insert(newHash);
@@ -63,12 +63,12 @@
Name ibltName("sync");
iblt.appendToName(ibltName);
- IBLT rcvd(size);
+ IBLT rcvd(size, CompressionScheme::DEFAULT);
rcvd.initialize(ibltName.get(-1));
BOOST_CHECK_EQUAL(iblt, rcvd);
- IBLT rcvdDiffSize(20);
+ IBLT rcvdDiffSize(20, CompressionScheme::DEFAULT);
BOOST_CHECK_THROW(rcvdDiffSize.initialize(ibltName.get(-1)), std::runtime_error);
}
@@ -76,7 +76,7 @@
{
int size = 10;
- IBLT iblt1(size);
+ IBLT iblt1(size, CompressionScheme::DEFAULT);
std::string prefix = Name("/test/memphis").appendNumber(1).toUri();
uint32_t hash1 = murmurHash3(11, prefix);
@@ -105,8 +105,8 @@
// Relevant to full sync case
int size = 10;
- IBLT ownIBF(size);
- IBLT rcvdIBF(size);
+ IBLT ownIBF(size, CompressionScheme::DEFAULT);
+ IBLT rcvdIBF(size, CompressionScheme::DEFAULT);
std::string prefix = Name("/test/memphis").appendNumber(3).toUri();
uint32_t hash1 = murmurHash3(11, prefix);
@@ -129,7 +129,7 @@
{
int size = 10;
- IBLT ownIBF(size);
+ IBLT ownIBF(size, CompressionScheme::DEFAULT);
IBLT rcvdIBF = ownIBF;
@@ -169,7 +169,7 @@
int size = 10;
- IBLT ownIBF(size);
+ IBLT ownIBF(size, CompressionScheme::DEFAULT);
for (int i = 0; i < 50; i++) {
std::string prefix = Name("/test/memphis" + std::to_string(i)).appendNumber(1).toUri();
diff --git a/tests/test-state.cpp b/tests/test-state.cpp
index 25626c4..6d7239c 100644
--- a/tests/test-state.cpp
+++ b/tests/test-state.cpp
@@ -74,6 +74,20 @@
BOOST_CHECK_EQUAL(state2.getContent().size(), 0);
}
+BOOST_AUTO_TEST_CASE(ReEncode)
+{
+ State state;
+ state.addContent(ndn::Name("test1"));
+ state.addContent(ndn::Name("test2"));
+
+ state.wireEncode();
+
+ state.addContent(ndn::Name("test3"));
+
+ State state2(state.wireEncode());
+ BOOST_CHECK_EQUAL(state2.getContent().size(), 3);
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace psync
\ No newline at end of file