Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
test: split out a time-consuming test to a separated one
Browse files Browse the repository at this point in the history
  • Loading branch information
KimiWu123 committed Jan 30, 2024
1 parent 4f09a7d commit bbdf449
Showing 1 changed file with 36 additions and 26 deletions.
62 changes: 36 additions & 26 deletions zkevm-circuits/src/sig_circuit/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,37 +179,47 @@ fn sign_verify_nonzero_msg_hash() {
}

#[test]
fn sign_verify() {
fn test_sign_verify() {
let max_sigs = [1, 4];
for max_sig in max_sigs {
sign_verify(max_sig as usize);
}
}

#[test]
#[ignore]
fn test_sign_verify_MAX_NUM_SIG() {

Check failure on line 191 in zkevm-circuits/src/sig_circuit/test.rs

View workflow job for this annotation

GitHub Actions / Various lints

function `test_sign_verify_MAX_NUM_SIG` should have a snake case name
sign_verify(MAX_NUM_SIG);
}

fn sign_verify(max_sig: usize) {
let mut rng = XorShiftRng::seed_from_u64(1);

// random msg_hash
let max_sigs = [1, 16, MAX_NUM_SIG];
for max_sig in max_sigs.iter() {
log::debug!("testing for {} signatures", max_sig);
let mut signatures = Vec::new();
for _ in 0..*max_sig {
let (sk, pk) = gen_key_pair(&mut rng);
let msg = gen_msg(&mut rng);
let msg_hash: [u8; 32] = Keccak256::digest(&msg)
.as_slice()
.to_vec()
.try_into()
.expect("hash length isn't 32 bytes");
let msg_hash = secp256k1::Fq::from_bytes(&msg_hash).unwrap();
let (r, s, v) = sign_with_rng(&mut rng, sk, msg_hash);
signatures.push(SignData {
signature: (r, s, v),
pk,
msg: msg.into(),
msg_hash,
});
}
log::debug!("testing for {} signatures", max_sig);
let mut signatures = Vec::new();
for _ in 0..max_sig {
let (sk, pk) = gen_key_pair(&mut rng);
let msg = gen_msg(&mut rng);
let msg_hash: [u8; 32] = Keccak256::digest(&msg)
.as_slice()
.to_vec()
.try_into()
.expect("hash length isn't 32 bytes");
let msg_hash = secp256k1::Fq::from_bytes(&msg_hash).unwrap();
let (r, s, v) = sign_with_rng(&mut rng, sk, msg_hash);
signatures.push(SignData {
signature: (r, s, v),
pk,
msg: msg.into(),
msg_hash,
});
}

let k = LOG_TOTAL_NUM_ROWS as u32;
run(k, *max_sig, signatures);
let k = LOG_TOTAL_NUM_ROWS as u32;
run(k, max_sig, signatures);

log::debug!("end of testing for {} signatures", max_sig);
}
log::debug!("end of testing for {} signatures", max_sig);
}

// Generate a test key pair
Expand Down

0 comments on commit bbdf449

Please sign in to comment.