Skip to content

Commit

Permalink
add tests with generic type F
Browse files Browse the repository at this point in the history
  • Loading branch information
mmagician committed Jan 26, 2024
1 parent 009e18c commit 1cf103a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crypto-primitives/src/sponge/absorb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ mod tests {
b: u16,
}

#[derive(Absorb)]
struct StructWithGeneric<F: PrimeField + Absorb>(F);

#[derive(Absorb)]
struct StructWithNoNamedFields(u16);

Expand All @@ -407,6 +410,7 @@ mod tests {
f: Fr,
g: SubStruct,
h: StructWithNoNamedFields,
i: StructWithGeneric<Fr>,
}

#[test]
Expand All @@ -420,6 +424,7 @@ mod tests {
f: Fr::from(6),
g: SubStruct { a: 7, b: 8 },
h: StructWithNoNamedFields(9),
i: StructWithGeneric(Fr::from(10)),
};

let sponge_param = poseidon_parameters_for_test();
Expand Down Expand Up @@ -447,6 +452,7 @@ mod tests {
sponge.absorb(&a.f);
sponge.absorb(&a.g);
sponge.absorb(&a.h);
sponge.absorb(&a.i);
let out_manual = sponge.squeeze_bytes(32);
assert_eq!(out_derived, out_manual);
}
Expand Down

0 comments on commit 1cf103a

Please sign in to comment.