Skip to content

Commit 51f125a

Browse files
committed
Add tests
1 parent f2d5ce1 commit 51f125a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

soroban-sdk/src/tests/crypto_bn254.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,30 @@ fn test_g1_msm() {
6363
assert_eq!(res, zero);
6464
}
6565

66+
#[test]
67+
#[should_panic(expected = "HostError: Error(Crypto, InvalidInput)")]
68+
fn test_g1_msm_mismatched_lengths() {
69+
let env = Env::default();
70+
let bn254 = Bn254::new(&env);
71+
let one = Bn254G1Affine::from_bytes(bytesn!(
72+
&env,
73+
0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002
74+
));
75+
let vp: Vec<Bn254G1Affine> = vec![&env, one.clone(), one.clone()];
76+
let vs: Vec<Fr> = vec![&env, U256::from_u32(&env, 1).into()];
77+
bn254.g1_msm(vp, vs);
78+
}
79+
80+
#[test]
81+
#[should_panic(expected = "HostError: Error(Crypto, InvalidInput)")]
82+
fn test_g1_msm_empty_vectors() {
83+
let env = Env::default();
84+
let bn254 = Bn254::new(&env);
85+
let vp: Vec<Bn254G1Affine> = vec![&env];
86+
let vs: Vec<Fr> = vec![&env];
87+
bn254.g1_msm(vp, vs);
88+
}
89+
6690
#[test]
6791
fn test_fr_arithmetic() {
6892
let env = Env::default();
@@ -118,6 +142,14 @@ fn test_fr_arithmetic() {
118142
);
119143
}
120144

145+
#[test]
146+
#[should_panic(expected = "HostError: Error(Crypto, InvalidInput)")]
147+
fn test_fr_inv_zero() {
148+
let env = Env::default();
149+
let bn254 = Bn254::new(&env);
150+
bn254.fr_inv(&U256::from_u32(&env, 0).into());
151+
}
152+
121153
#[test]
122154
fn test_fr_operator_traits() {
123155
let env = Env::default();

0 commit comments

Comments
 (0)