Skip to content

Commit

Permalink
add unit test for import alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mfachal committed Apr 26, 2023
1 parent 927b9da commit 4cf1757
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/hint_processor/builtin_hint_processor/secp/ec_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ mod tests {
};
use assert_matches::assert_matches;

use num_bigint::BigUint;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;

Expand Down Expand Up @@ -1164,4 +1165,26 @@ mod tests {
// Check hint memory inserts
check_memory![vm.segments.memory, ((1, 3), 2)];
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn run_import_secp256r1_alpha() {
let hint_code = "from starkware.cairo.common.cairo_secp.secp256r1_utils import SECP256R1_ALPHA as ALPHA";
let mut vm = vm_with_range_check!();

//Initialize fp
vm.run_context.fp = 1;
//Create hint_data
let ids_data = ids_data!["point"];
let mut exec_scopes = ExecutionScopes::new();
//Execute the hint
assert_matches!(run_hint!(vm, ids_data, hint_code, &mut exec_scopes), Ok(()));
//Check 'ALPHA' is defined in the vm scope
assert_matches!(
exec_scopes.get::<BigUint>("ALPHA"),
Ok(x) if x == biguint_str!(
"115792089210356248762697446949407573530086143415290314195533631308867097853948"
)
);
}
}

0 comments on commit 4cf1757

Please sign in to comment.