ARK-Builders / ARK-Builders/ark-core

`fs-index`: Split unit tests by two categories of hash functions

Open
#83 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
10
Forks
6
PR merge metrics
No merged PRs in 30d

Description

In #79 we've entroduced `for_each_type!` macro allowing us to iterate through different types of `ResourceId` implementations and use the corresponding hash function.

Now, we could define two broad categories of "cryptographic" and "fast" hash functions another macro wrappers, so we can simply add new functions into one of the two categories, and the test cases will work with new functions automatically without necessity to update them manually.

This will allow us to describe invariants in generic terms, not specific functions:
```
fn test_no_collisions_with_cryptographic_hashing() {
for_cryptographic_hashing! {
// setup a folder without duplicates
// index it
assert_eq!(index.collisions, 0);
}
}
```

On the other hand, we are still free to create custom test cases for one or two specific functions, these test cases will not be run excessively for functions that are not involved
```
fn test_no_collisions_with_cryptographic_hashing() {
for_each_hashing!(take_first_byte, take_last_byte) {
// setup a folder without duplicates
// index it
assert_eq!(index.keys.size(), 8); //synthetic example
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start by locating the existing `for_each_type!` macro from #79, the `ResourceId` implementations, and the hash-function test cases. Define the proposed cryptographic and fast categories, plus a way to select specific functions, then update the tests so category invariants run automatically while targeted cases remain limited to their listed functions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.