tests: make sync tests more deterministic
This change makes the UpdateForOther{LS,HR} tests more deterministic by
removing the temporal ordering requirement of sent interests.
Change-Id: Iceab5735baa2ff2fb97b18babfcf2bb32110a3c2
refs: #4253
diff --git a/tests/test-sync-logic-handler.cpp b/tests/test-sync-logic-handler.cpp
index 24bd065..5ebe679 100644
--- a/tests/test-sync-logic-handler.cpp
+++ b/tests/test-sync-logic-handler.cpp
@@ -90,13 +90,11 @@
receiveUpdate(updateName, syncSeqNo, sync);
- std::vector<ndn::Interest>& interests = face->sentInterests;
-
- std::vector<ndn::Interest>::iterator it = interests.begin();
-
- BOOST_REQUIRE_EQUAL(interests.size(), 1);
-
- BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "/");
+ const auto& it = std::find_if(face->sentInterests.begin(), face->sentInterests.end(),
+ [updateName] (const ndn::Interest& interest) {
+ return interest.getName().getPrefix(-1) == updateName + "/";
+ });
+ BOOST_REQUIRE(it != face->sentInterests.end());
}
}
@@ -124,12 +122,12 @@
receiveUpdate(updateName, syncSeqNo, sync_hr);
- std::vector<ndn::Interest>& interests = face->sentInterests;
- std::vector<ndn::Interest>::iterator it = interests.begin();
+ const auto& it = std::find_if(face->sentInterests.begin(), face->sentInterests.end(),
+ [updateName] (const ndn::Interest& interest) {
+ return interest.getName().getPrefix(-1) == updateName + "/";
+ });
- BOOST_REQUIRE_EQUAL(interests.size(), 1);
-
- BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "/");
+ BOOST_REQUIRE(it != face->sentInterests.end());
}
}