Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test for apply_ap_tracking_correction with invalid offset #1661

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use crate::{
},
ec_utils::{chained_ec_op_random_ec_point_hint, random_ec_point_hint, recover_y_hint},
find_element_hint::{find_element, search_sorted_lower},
garaga::get_felt_bitlenght,
garaga::get_felt_bitlength,
hint_code,
keccak_utils::{
split_input, split_n_bytes, split_output, split_output_mid_low_high, unsafe_keccak,
Expand Down Expand Up @@ -470,7 +470,7 @@ impl HintProcessorLogic for BuiltinHintProcessor {
&hint_data.ap_tracking,
),
hint_code::GET_FELT_BIT_LENGTH => {
get_felt_bitlenght(vm, &hint_data.ids_data, &hint_data.ap_tracking)
get_felt_bitlength(vm, &hint_data.ids_data, &hint_data.ap_tracking)
}
hint_code::BIGINT_PACK_DIV_MOD => bigint_pack_div_mod_hint(
vm,
Expand Down
2 changes: 1 addition & 1 deletion vm/src/hint_processor/builtin_hint_processor/garaga.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::hint_utils::{get_integer_from_var_name, insert_value_from_var_name};
/// x = ids.x,
/// ids.bit_length = x.bit_length()
/// ```
pub fn get_felt_bitlenght(
pub fn get_felt_bitlength(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tcoratger. Because this method is public, you'll need to update the changelog, as the rename is a breaking change.

vm: &mut VirtualMachine,
ids_data: &HashMap<String, HintReference>,
ap_tracking: &ApTracking,
Expand Down
18 changes: 18 additions & 0 deletions vm/src/hint_processor/hint_processor_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,24 @@ mod tests {
.is_none());
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn tracking_correction_invalid_offset() {
let mut ref_ap_tracking = ApTracking::new();
ref_ap_tracking.group = 1;
ref_ap_tracking.offset = 5;
let mut hint_ap_tracking = ApTracking::new();
hint_ap_tracking.group = 2;
hint_ap_tracking.offset = 10;

assert!(apply_ap_tracking_correction(
relocatable!(1, 0),
&ref_ap_tracking,
&hint_ap_tracking
)
.is_none());
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn get_maybe_relocatable_from_reference_valid() {
Expand Down
Loading