Skip to content

Commit 01660bf

Browse files
authored
fix(gpu_prover): fix blake2s tests (#193)
## What ❔ This PR fixes the blake2s unit tests. ## Why ❔ Wrong constant was used in the takes which made them fail. ## Is this a breaking change? - [ ] Yes - [x] No ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [x] Code has been formatted.
1 parent 4491c3a commit 01660bf

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

gpu_prover/src/blake2s.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ mod tests {
324324
use crate::ops_simple::set_to_zero;
325325
use crate::utils::GetChunksCount;
326326

327+
const USE_REDUCED_BLAKE2_ROUNDS: bool = true;
328+
327329
fn verify_leaves(values: &[BF], results: &[Digest], log_rows_per_hash: u32) {
328330
let count = results.len();
329331
let values_len = values.len();
@@ -351,9 +353,13 @@ mod tests {
351353
.collect_vec();
352354
block.copy_from_slice(&chunk);
353355
if i == blocks_count - 1 {
354-
state.absorb_final_block::<false>(&block, block_len, &mut expected);
356+
state.absorb_final_block::<USE_REDUCED_BLAKE2_ROUNDS>(
357+
&block,
358+
block_len,
359+
&mut expected,
360+
);
355361
} else {
356-
state.absorb::<false>(&block);
362+
state.absorb::<USE_REDUCED_BLAKE2_ROUNDS>(&block);
357363
}
358364
}
359365
let actual = results[i];
@@ -376,7 +382,10 @@ mod tests {
376382
.try_into()
377383
.unwrap();
378384
let mut expected = Digest::default();
379-
Blake2sState::compress_two_to_one::<false>(&state, &mut expected);
385+
Blake2sState::compress_two_to_one::<USE_REDUCED_BLAKE2_ROUNDS>(
386+
&state,
387+
&mut expected,
388+
);
380389
assert_eq!(expected, actual);
381390
});
382391
}
@@ -613,7 +622,7 @@ mod tests {
613622
block[STATE_SIZE] = h_result[0] as u32;
614623
block[STATE_SIZE + 1] = (h_result[0] >> 32) as u32;
615624
let mut digest = Digest::default();
616-
state.absorb_final_block::<true>(&block, STATE_SIZE + 2, &mut digest);
625+
state.absorb_final_block::<USE_REDUCED_BLAKE2_ROUNDS>(&block, STATE_SIZE + 2, &mut digest);
617626
assert!(digest[0].leading_zeros() >= BITS_COUNT);
618627
}
619628
}

0 commit comments

Comments
 (0)