From 4cf17572e29ec704ac1dda3f688afb726503e986 Mon Sep 17 00:00:00 2001 From: mfachal <647731+mfachal@users.noreply.github.com> Date: Wed, 26 Apr 2023 15:45:49 -0300 Subject: [PATCH] add unit test for import alpha --- .../builtin_hint_processor/secp/ec_utils.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/hint_processor/builtin_hint_processor/secp/ec_utils.rs b/src/hint_processor/builtin_hint_processor/secp/ec_utils.rs index d0205a5343..f80fe6caf1 100644 --- a/src/hint_processor/builtin_hint_processor/secp/ec_utils.rs +++ b/src/hint_processor/builtin_hint_processor/secp/ec_utils.rs @@ -457,6 +457,7 @@ mod tests { }; use assert_matches::assert_matches; + use num_bigint::BigUint; #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::*; @@ -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::("ALPHA"), + Ok(x) if x == biguint_str!( + "115792089210356248762697446949407573530086143415290314195533631308867097853948" + ) + ); + } }