diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/rust_cascade/test_data | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/rust_cascade/test_data')
-rw-r--r-- | third_party/rust/rust_cascade/test_data/make-sample-data.py | 106 | ||||
-rw-r--r-- | third_party/rust/rust_cascade/test_data/requirements.txt | 1 | ||||
-rw-r--r-- | third_party/rust/rust_cascade/test_data/test_v1_murmur_mlbf | bin | 0 -> 15244 bytes | |||
-rw-r--r-- | third_party/rust/rust_cascade/test_data/test_v1_murmur_short_mlbf | bin | 0 -> 1024 bytes | |||
-rw-r--r-- | third_party/rust/rust_cascade/test_data/test_v2_murmur_inverted_mlbf | bin | 0 -> 830 bytes | |||
-rw-r--r-- | third_party/rust/rust_cascade/test_data/test_v2_murmur_mlbf | bin | 0 -> 786 bytes | |||
-rw-r--r-- | third_party/rust/rust_cascade/test_data/test_v2_sha256ctr_salt_mlbf | bin | 0 -> 842 bytes | |||
-rw-r--r-- | third_party/rust/rust_cascade/test_data/test_v2_sha256l32_inverted_mlbf | bin | 0 -> 833 bytes | |||
-rw-r--r-- | third_party/rust/rust_cascade/test_data/test_v2_sha256l32_mlbf | bin | 0 -> 795 bytes | |||
-rw-r--r-- | third_party/rust/rust_cascade/test_data/test_v2_sha256l32_salt_mlbf | bin | 0 -> 795 bytes |
10 files changed, 107 insertions, 0 deletions
diff --git a/third_party/rust/rust_cascade/test_data/make-sample-data.py b/third_party/rust/rust_cascade/test_data/make-sample-data.py new file mode 100644 index 0000000000..c9f117da5f --- /dev/null +++ b/third_party/rust/rust_cascade/test_data/make-sample-data.py @@ -0,0 +1,106 @@ +import filtercascade +import hashlib +from pathlib import Path + +import sys +import logging + +logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) + + +def predictable_serial_gen(start, end): + counter = start + while counter < end: + counter += 1 + m = hashlib.sha256() + m.update(counter.to_bytes(4, byteorder="big")) + yield m.hexdigest() + + +def store(fc, path): + if path.exists(): + path.unlink() + with open(path, "wb") as f: + fc.tofile(f) + + +small_set = list(set(predictable_serial_gen(0, 500))) +large_set = set(predictable_serial_gen(500, 10_000)) + +# filter parameters +growth_factor = 1.0 +min_filter_length = 177 # 177 * 1.44 ~ 256, so smallest filter will have 256 bits + +print("--- v2_sha256l32_with_salt ---") +v2_sha256l32_with_salt = filtercascade.FilterCascade( + [], + defaultHashAlg=filtercascade.fileformats.HashAlgorithm.SHA256, + salt=b"nacl", + growth_factor=growth_factor, + min_filter_length=min_filter_length, +) +v2_sha256l32_with_salt.initialize( + include=[b"this", b"that"] + small_set, exclude=large_set | set([b"other"]) +) +store(v2_sha256l32_with_salt, Path("test_v2_sha256l32_salt_mlbf")) + +print("--- v2_sha256l32 ---") +v2_sha256l32 = filtercascade.FilterCascade( + [], + defaultHashAlg=filtercascade.fileformats.HashAlgorithm.SHA256, + growth_factor=growth_factor, + min_filter_length=min_filter_length, +) +v2_sha256l32.initialize( + include=[b"this", b"that"] + small_set, exclude=large_set | set([b"other"]) +) +store(v2_sha256l32, Path("test_v2_sha256l32_mlbf")) + +print("--- v2_murmur ---") +v2_murmur = filtercascade.FilterCascade( + [], + defaultHashAlg=filtercascade.fileformats.HashAlgorithm.MURMUR3, + growth_factor=growth_factor, + min_filter_length=min_filter_length, +) +v2_murmur.initialize( + include=[b"this", b"that"] + small_set, exclude=large_set | set([b"other"]) +) +store(v2_murmur, Path("test_v2_murmur_mlbf")) + +print("--- v2_murmur_inverted ---") +v2_murmur_inverted = filtercascade.FilterCascade( + [], + defaultHashAlg=filtercascade.fileformats.HashAlgorithm.MURMUR3, + growth_factor=growth_factor, + min_filter_length=min_filter_length, +) +v2_murmur_inverted.initialize( + include=large_set | set([b"this", b"that"]), exclude=[b"other"] + small_set +) +store(v2_murmur_inverted, Path("test_v2_murmur_inverted_mlbf")) + +print("--- v2_sha256l32_inverted ---") +v2_sha256l32_inverted = filtercascade.FilterCascade( + [], + defaultHashAlg=filtercascade.fileformats.HashAlgorithm.SHA256, + growth_factor=growth_factor, + min_filter_length=min_filter_length, +) +v2_sha256l32_inverted.initialize( + include=large_set | set([b"this", b"that"]), exclude=[b"other"] + small_set +) +store(v2_sha256l32_inverted, Path("test_v2_sha256l32_inverted_mlbf")) + +print("--- v2_sha256ctr_with_salt ---") +v2_sha256ctr_with_salt = filtercascade.FilterCascade( + [], + defaultHashAlg=filtercascade.fileformats.HashAlgorithm.SHA256CTR, + salt=b"nacl", + growth_factor=growth_factor, + min_filter_length=min_filter_length, +) +v2_sha256ctr_with_salt.initialize( + include=[b"this", b"that"] + small_set, exclude=large_set | set([b"other"]) +) +store(v2_sha256ctr_with_salt, Path("test_v2_sha256ctr_salt_mlbf")) diff --git a/third_party/rust/rust_cascade/test_data/requirements.txt b/third_party/rust/rust_cascade/test_data/requirements.txt new file mode 100644 index 0000000000..f97bd4328f --- /dev/null +++ b/third_party/rust/rust_cascade/test_data/requirements.txt @@ -0,0 +1 @@ +filtercascade >= 0.3.0 diff --git a/third_party/rust/rust_cascade/test_data/test_v1_murmur_mlbf b/third_party/rust/rust_cascade/test_data/test_v1_murmur_mlbf Binary files differnew file mode 100644 index 0000000000..34ced4b840 --- /dev/null +++ b/third_party/rust/rust_cascade/test_data/test_v1_murmur_mlbf diff --git a/third_party/rust/rust_cascade/test_data/test_v1_murmur_short_mlbf b/third_party/rust/rust_cascade/test_data/test_v1_murmur_short_mlbf Binary files differnew file mode 100644 index 0000000000..d0bb7071ab --- /dev/null +++ b/third_party/rust/rust_cascade/test_data/test_v1_murmur_short_mlbf diff --git a/third_party/rust/rust_cascade/test_data/test_v2_murmur_inverted_mlbf b/third_party/rust/rust_cascade/test_data/test_v2_murmur_inverted_mlbf Binary files differnew file mode 100644 index 0000000000..19acee150e --- /dev/null +++ b/third_party/rust/rust_cascade/test_data/test_v2_murmur_inverted_mlbf diff --git a/third_party/rust/rust_cascade/test_data/test_v2_murmur_mlbf b/third_party/rust/rust_cascade/test_data/test_v2_murmur_mlbf Binary files differnew file mode 100644 index 0000000000..78f527ebf3 --- /dev/null +++ b/third_party/rust/rust_cascade/test_data/test_v2_murmur_mlbf diff --git a/third_party/rust/rust_cascade/test_data/test_v2_sha256ctr_salt_mlbf b/third_party/rust/rust_cascade/test_data/test_v2_sha256ctr_salt_mlbf Binary files differnew file mode 100644 index 0000000000..fca48498d6 --- /dev/null +++ b/third_party/rust/rust_cascade/test_data/test_v2_sha256ctr_salt_mlbf diff --git a/third_party/rust/rust_cascade/test_data/test_v2_sha256l32_inverted_mlbf b/third_party/rust/rust_cascade/test_data/test_v2_sha256l32_inverted_mlbf Binary files differnew file mode 100644 index 0000000000..f9e892ac70 --- /dev/null +++ b/third_party/rust/rust_cascade/test_data/test_v2_sha256l32_inverted_mlbf diff --git a/third_party/rust/rust_cascade/test_data/test_v2_sha256l32_mlbf b/third_party/rust/rust_cascade/test_data/test_v2_sha256l32_mlbf Binary files differnew file mode 100644 index 0000000000..c0d7266fc4 --- /dev/null +++ b/third_party/rust/rust_cascade/test_data/test_v2_sha256l32_mlbf diff --git a/third_party/rust/rust_cascade/test_data/test_v2_sha256l32_salt_mlbf b/third_party/rust/rust_cascade/test_data/test_v2_sha256l32_salt_mlbf Binary files differnew file mode 100644 index 0000000000..4f9c2fff16 --- /dev/null +++ b/third_party/rust/rust_cascade/test_data/test_v2_sha256l32_salt_mlbf |