MCPcopy Create free account
hub / github.com/ElementsProject/elements / Check

Method Check

src/leveldb/db/corruption_test.cc:75–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73 }
74
75 void Check(int min_expected, int max_expected) {
76 int next_expected = 0;
77 int missed = 0;
78 int bad_keys = 0;
79 int bad_values = 0;
80 int correct = 0;
81 std::string value_space;
82 Iterator* iter = db_->NewIterator(ReadOptions());
83 for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
84 uint64_t key;
85 Slice in(iter->key());
86 if (in == "" || in == "~") {
87 // Ignore boundary keys.
88 continue;
89 }
90 if (!ConsumeDecimalNumber(&in, &key) || !in.empty() ||
91 key < next_expected) {
92 bad_keys++;
93 continue;
94 }
95 missed += (key - next_expected);
96 next_expected = key + 1;
97 if (iter->value() != Value(key, &value_space)) {
98 bad_values++;
99 } else {
100 correct++;
101 }
102 }
103 delete iter;
104
105 fprintf(stderr,
106 "expected=%d..%d; got=%d; bad_keys=%d; bad_values=%d; missed=%d\n",
107 min_expected, max_expected, correct, bad_keys, bad_values, missed);
108 ASSERT_LE(min_expected, correct);
109 ASSERT_GE(max_expected, correct);
110 }
111
112 void Corrupt(FileType filetype, int offset, int bytes_to_corrupt) {
113 // Pick file to corrupt

Callers

nothing calls this directly

Calls 10

ConsumeDecimalNumberFunction · 0.85
ValueFunction · 0.85
ReadOptionsClass · 0.50
NewIteratorMethod · 0.45
SeekToFirstMethod · 0.45
ValidMethod · 0.45
NextMethod · 0.45
keyMethod · 0.45
emptyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected