Skip to content

Commit

Permalink
Test shl and shr with eq flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbush committed Jun 21, 2024
1 parent cab2dcc commit becdb34
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
14 changes: 14 additions & 0 deletions programs/shl_conditional_eq.zasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.text
.file "shl_conditional_eq.zasm"
.globl __entry
__entry:
.func_begin0:
add 4, r0, r1
add 1, r0, r2
shl.eq r1, r2, r3
sstore r0, r3
ret
.func_end0:

.note.GNU-stack
.rodata
14 changes: 14 additions & 0 deletions programs/shr_conditional_eq.zasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.text
.file "shr_conditional_eq.zasm"
.globl __entry
__entry:
.func_begin0:
add 8, r0, r1
add 2, r0, r2
shr.eq r1, r2, r3
sstore r0, r3
ret
.func_end0:

.note.GNU-stack
.rodata
30 changes: 15 additions & 15 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,18 +516,18 @@ fn test_shr_stack() {
assert_eq!(result, U256::from(1)); // 4 >> 2 = 1
}

// #[test]
// fn test_shl_conditional() {
// let bin_path = make_bin_path_asm("shl_conditional");
// let vm_with_custom_flags = VMStateBuilder::new().eq_flag(true).build();
// let (result, _) = run_program_with_custom_state(&bin_path, vm_with_custom_flags);
// assert_eq!(result, U256::from(8)); // 4 << 1 = 8
// }

// #[test]
// fn test_shr_conditional() {
// let bin_path = make_bin_path_asm("shr_conditional");
// let vm_with_custom_flags = VMStateBuilder::new().gt_flag(true).build();
// let (result, _) = run_program_with_custom_state(&bin_path, vm_with_custom_flags);
// assert_eq!(result, U256::from(2)); // 8 >> 2 = 2
// }
#[test]
fn test_shl_conditional_eq_set() {
let bin_path = make_bin_path_asm("shl_conditional_eq");
let vm_with_custom_flags = VMStateBuilder::new().eq_flag(true).build();
let (result, _final_vm_state) = run_program_with_custom_state(&bin_path, vm_with_custom_flags);
assert_eq!(result, U256::from(8)); // 4 << 1 = 8
}

#[test]
fn test_shr_conditional_eq_set() {
let bin_path = make_bin_path_asm("shr_conditional_eq");
let vm_with_custom_flags = VMStateBuilder::new().eq_flag(true).build();
let (result, _) = run_program_with_custom_state(&bin_path, vm_with_custom_flags);
assert_eq!(result, U256::from(2)); // 8 >> 2 = 2
}

0 comments on commit becdb34

Please sign in to comment.