Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: net/cert/ct_log_verifier_unittest.cc

Issue 2187043004: Makes an expensive CTLogVerifier test into a value-parameterized test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improves documentation and adds missing #includes Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/ct_log_verifier_unittest.cc
diff --git a/net/cert/ct_log_verifier_unittest.cc b/net/cert/ct_log_verifier_unittest.cc
index 754d3e39073c50f89c3c83b1d3d623a7ef782659..982134e52e69e47ff3586c2a420d7dcd41de2148 100644
--- a/net/cert/ct_log_verifier_unittest.cc
+++ b/net/cert/ct_log_verifier_unittest.cc
@@ -8,6 +8,9 @@
#include <memory>
#include <string>
+#include <tuple>
+#include <utility>
+#include <vector>
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
@@ -485,35 +488,49 @@ std::vector<std::string> ReferenceSnapshotConsistency(std::string* inputs,
return proof;
}
-// Times out on Win7 test bot. http://crbug.com/598406
-#if defined(OS_WIN)
-#define MAYBE_VerifiesValidConsistencyProofsFromReferenceGenerator \
- DISABLED_VerifiesValidConsistencyProofsFromReferenceGenerator
-#else
-#define MAYBE_VerifiesValidConsistencyProofsFromReferenceGenerator \
- VerifiesValidConsistencyProofsFromReferenceGenerator
-#endif
-TEST_F(CTLogVerifierTest,
- MAYBE_VerifiesValidConsistencyProofsFromReferenceGenerator) {
+// Generates all valid combinations of tree size and snapshot size / leaf index
+// (assuming the leaf index is 1-based). Combinations will be generated for all
+// tree sizes from 1 to |max_tree_size|.
+// This is useful for exhaustive testing of consistency proof and audit proof
+// verification.
+std::vector<std::pair<uint64_t, uint64_t>> GenerateTestParams(
+ size_t max_tree_size) {
+ std::vector<std::pair<uint64_t, uint64_t>> params;
+ params.reserve(max_tree_size * (max_tree_size + 1) / 2);
+ for (uint64_t tree_size = 1; tree_size <= max_tree_size; ++tree_size) {
+ for (uint64_t x = 1; x <= tree_size; ++x) {
+ // |x| could be a tree snapshot size (for consistency proof tests) or a
+ // leaf index (for inclusion proofs tests).
+ params.emplace_back(tree_size, x);
+ }
+ }
+ return params;
+}
+
+class CTLogVerifierTestUsingReferenceGenerator
+ : public CTLogVerifierTest,
+ public ::testing::WithParamInterface<std::pair<uint64_t, uint64_t>> {};
+
+TEST_P(CTLogVerifierTestUsingReferenceGenerator,
+ VerifiesValidConsistencyProof) {
std::vector<std::string> data;
for (int i = 0; i < 256; ++i)
data.push_back(std::string(1, i));
- std::vector<std::string> proof;
- std::string root1, root2;
- // More tests with reference proof generator.
- for (size_t tree_size = 1; tree_size <= data.size() / 2; ++tree_size) {
- root2 = ReferenceMerkleTreeHash(data.data(), tree_size);
- // Repeat for each snapshot in range.
- for (size_t snapshot = 1; snapshot <= tree_size; ++snapshot) {
- proof =
- ReferenceSnapshotConsistency(data.data(), tree_size, snapshot, true);
- root1 = ReferenceMerkleTreeHash(data.data(), snapshot);
- VerifierConsistencyCheck(snapshot, tree_size, root1, root2, proof);
- }
- }
+ uint64_t tree_size, snapshot;
+ std::tie(tree_size, snapshot) = GetParam();
+ std::string root1 = ReferenceMerkleTreeHash(data.data(), snapshot);
+ std::string root2 = ReferenceMerkleTreeHash(data.data(), tree_size);
+ std::vector<std::string> proof =
+ ReferenceSnapshotConsistency(data.data(), tree_size, snapshot, true);
+ VerifierConsistencyCheck(snapshot, tree_size, root1, root2, proof);
}
+// Test verification of consistency proofs between all tree sizes from 1 to 128.
+INSTANTIATE_TEST_CASE_P(RangeOfTreeSizesAndSnapshots,
+ CTLogVerifierTestUsingReferenceGenerator,
+ testing::ValuesIn(GenerateTestParams(128)));
Ryan Sleevi 2016/07/28 16:46:50 Doesn't this 128 magic value tightly couple with t
Rob Percival 2016/07/28 17:39:24 Indeed it does - I've created a constant to link t
+
} // namespace
} // namespace net
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698