Skip to content

Commit 65f14ae

Browse files
test: add happy flow unit test for alias identifier resolving to pc
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4cf915a commit 65f14ae

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

vm/src/vm/runners/function_runner.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ mod tests {
158158
use crate::vm::runners::cairo_runner::CairoArg;
159159
use crate::vm::runners::function_runner::EntryPoint;
160160
use assert_matches::assert_matches;
161+
use std::sync::Arc;
161162

162163
fn load_program(program_bytes: &[u8]) -> Program {
163164
Program::from_bytes(program_bytes, None).unwrap()
@@ -416,6 +417,43 @@ mod tests {
416417
);
417418
}
418419

420+
#[test]
421+
fn get_pc_from_identifier_happy_flow_alias_resolves_to_pc() {
422+
let program = load_program(include_bytes!(
423+
"../../../../cairo_programs/example_program.json"
424+
));
425+
let mut runner = CairoRunner::new_for_testing(&program).unwrap();
426+
427+
let dest_identifier = Identifier {
428+
type_: Some("function".to_string()),
429+
pc: Some(50),
430+
full_name: Some("my_func".to_string()),
431+
value: None,
432+
members: None,
433+
cairo_type: None,
434+
size: None,
435+
destination: None,
436+
};
437+
Arc::make_mut(&mut runner.program.shared_program_data)
438+
.identifiers
439+
.insert("my_func".to_string(), dest_identifier);
440+
441+
let alias_identifier = Identifier {
442+
type_: Some("alias".to_string()),
443+
destination: Some("my_func".to_string()),
444+
full_name: Some("my_alias".to_string()),
445+
pc: None,
446+
value: None,
447+
members: None,
448+
cairo_type: None,
449+
size: None,
450+
};
451+
assert_eq!(
452+
runner.get_pc_from_identifier(&alias_identifier).unwrap(),
453+
50
454+
);
455+
}
456+
419457
#[test]
420458
fn get_pc_from_identifier_alias_without_destination_returns_error() {
421459
let program = load_program(include_bytes!(

0 commit comments

Comments
 (0)