mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Finish renaming digestset_contains to digestset_probably_contains
Since bloom filters are probabilistic, it's nice to make it clear that the "contains" operation can have false positives.
This commit is contained in:
@@ -644,18 +644,18 @@ test_container_digestset(void *arg)
|
||||
}
|
||||
set = digestset_new(1000);
|
||||
SMARTLIST_FOREACH(included, const char *, cp,
|
||||
if (digestset_contains(set, cp))
|
||||
if (digestset_probably_contains(set, cp))
|
||||
ok = 0);
|
||||
tt_assert(ok);
|
||||
SMARTLIST_FOREACH(included, const char *, cp,
|
||||
digestset_add(set, cp));
|
||||
SMARTLIST_FOREACH(included, const char *, cp,
|
||||
if (!digestset_contains(set, cp))
|
||||
if (!digestset_probably_contains(set, cp))
|
||||
ok = 0);
|
||||
tt_assert(ok);
|
||||
for (i = 0; i < 1000; ++i) {
|
||||
crypto_rand(d, DIGEST_LEN);
|
||||
if (digestset_contains(set, d))
|
||||
if (digestset_probably_contains(set, d))
|
||||
++false_positives;
|
||||
}
|
||||
tt_int_op(50, OP_GT, false_positives); /* Should be far lower. */
|
||||
|
||||
Reference in New Issue
Block a user