Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
moved both assertions back to wrapping shl test, added test case for …
Browse files Browse the repository at this point in the history
…shift > 255
  • Loading branch information
trbutler4 committed Sep 3, 2023
1 parent 6f91953 commit b43ab1e
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ fn test_exec_gt_true() {

#[test]
#[available_gas(20000000)]
fn test_exec_shl_stack() {
fn test_exec_shl_wrapping() {
// Given
let mut ctx = setup_execution_context();
ctx.stack.push(0xff00000000000000000000000000000000000000000000000000000000000000).unwrap();
Expand All @@ -226,30 +226,37 @@ fn test_exec_shl_stack() {

// Then
assert(ctx.stack.len() == 1, 'stack should have one element');
assert(
ctx
.stack
.peek()
.unwrap() == 0xf000000000000000000000000000000000000000000000000000000000000000,
'stack top should be 0xf00000...'
);
}

#[test]
#[available_gas(20000000)]
fn test_exec_shl_result() {
fn test_exec_shl_shift_too_large() {
// Given
let mut ctx = setup_execution_context();
ctx.stack.push(0xff00000000000000000000000000000000000000000000000000000000000000).unwrap();
ctx.stack.push(4_u256).unwrap();
ctx.stack.push(256_u256).unwrap();

// When
ctx.exec_shl();

// Then
assert(ctx.stack.len() == 1, 'stack should have one element');
assert(
ctx
.stack
.peek()
.unwrap() == 0xf000000000000000000000000000000000000000000000000000000000000000,
'stack top should be 0xf00000...'
.unwrap() == 0,
'if shift > 255 should return 0'
);
}


#[test]
#[available_gas(20000000)]
fn test_exec_gt_false() {
Expand Down

0 comments on commit b43ab1e

Please sign in to comment.