Skip to content

Commit 6d5256e

Browse files
authored
chore: add test for map_fp_to_g1 precompile (#1465)
1 parent a28a543 commit 6d5256e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crates/precompile/src/bls12_381/map_fp_to_g1.rs

+16
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,19 @@ pub(super) fn map_fp_to_g1(input: &Bytes, gas_limit: u64) -> PrecompileResult {
4646
let out = encode_g1_point(&p_aff);
4747
Ok((MAP_FP_TO_G1_BASE, out))
4848
}
49+
50+
#[cfg(test)]
51+
mod test {
52+
use super::*;
53+
use crate::primitives::hex;
54+
55+
#[test]
56+
fn sanity_test() {
57+
let input = Bytes::from(hex!("000000000000000000000000000000006900000000000000636f6e7472616374595a603f343061cd305a03f40239f5ffff31818185c136bc2595f2aa18e08f17"));
58+
let fail = map_fp_to_g1(&input, MAP_FP_TO_G1_BASE);
59+
assert_eq!(
60+
fail,
61+
Err(PrecompileError::Other("non-canonical fp value".to_string()))
62+
);
63+
}
64+
}

0 commit comments

Comments
 (0)