Skip to content

Commit

Permalink
test: add DammSum known-answer test (tari-project#6638)
Browse files Browse the repository at this point in the history
Description
---
Adds a known-answer test for the DammSum checksum implementation.

Motivation and Context
---
The DammSum checksum implementation already had extensive randomized
testing, but did not have any known-answer tests. This PR adds one.

How Has This Been Tested?
---
The new test passes!

What process can a PR reviewer use to test or verify this change?
---
Ensure the test passes. If you're feeling bored, examine the checksum
algorithm to convince yourself of the validity of the test.

Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify
  • Loading branch information
AaronFeickert authored Oct 18, 2024
1 parent c51ba7a commit eb00fb2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions base_layer/common_types/src/dammsum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,12 @@ mod test {
assert_eq!(validate_checksum(&data_), Err(ChecksumError::InvalidChecksum));
}
}

#[test]
fn known_checksum() {
const SIZE: usize = 33;

// We know what the checksum for all-zero data must be
assert_eq!(compute_checksum(&[0u8; SIZE]), 0u8);
}
}

0 comments on commit eb00fb2

Please sign in to comment.