diff --git a/crates/evm/src/instructions/environmental_information.cairo b/crates/evm/src/instructions/environmental_information.cairo index be0f29044..0b3fb9ed2 100644 --- a/crates/evm/src/instructions/environmental_information.cairo +++ b/crates/evm/src/instructions/environmental_information.cairo @@ -35,7 +35,7 @@ impl EnvironmentInformationImpl of EnvironmentInformationTrait { /// Get caller address. /// # Specification: https://www.evm.codes/#33?fork=shanghai fn exec_caller(ref self: Machine) -> Result<(), EVMError> { - Result::Ok(()) + self.stack.push(self.caller().into()) } /// 0x34 - CALLVALUE diff --git a/crates/evm/src/tests/test_instructions/test_comparison_operations.cairo b/crates/evm/src/tests/test_instructions/test_comparison_operations.cairo index cafc5edd0..a245782b4 100644 --- a/crates/evm/src/tests/test_instructions/test_comparison_operations.cairo +++ b/crates/evm/src/tests/test_instructions/test_comparison_operations.cairo @@ -1687,7 +1687,7 @@ fn assert_sar(a: u256, b: u256, expected: u256) { #[test] #[available_gas(20000000)] -fn test__exec_or__should_pop_0_and_1_and_push_0xCD__when_0_is_0x89_and_1_is_0xC5() { +fn test_exec_or_should_pop_0_and_1_and_push_0xCD_when_0_is_0x89_and_1_is_0xC5() { //Given let mut machine = setup_machine(); machine.stack.push(0x89); diff --git a/crates/evm/src/tests/test_instructions/test_environment_information.cairo b/crates/evm/src/tests/test_instructions/test_environment_information.cairo index 44ebe8529..b1765bfd8 100644 --- a/crates/evm/src/tests/test_instructions/test_environment_information.cairo +++ b/crates/evm/src/tests/test_instructions/test_environment_information.cairo @@ -42,13 +42,32 @@ fn test_address_nested_call() { // A (EOA) -(calls)-> B (smart contract) -(calls // ref: https://github.com/kkrt-labs/kakarot-ssj/issues/183 } + +// ************************************************************************* +// 0x33: CALLER +// ************************************************************************* +#[test] +#[available_gas(5000000)] +fn test_caller() { + // Given + let mut machine = setup_machine(); + + // When + machine.exec_caller(); + + // Then + assert(machine.stack.len() == 1, 'stack should have one element'); + assert(machine.stack.peek().unwrap() == evm_address().into(), 'should be evm_address'); +} + + // ************************************************************************* // 0x34: CALLVALUE // ************************************************************************* #[test] #[available_gas(1200000)] -fn test__exec_callvalue() { +fn test_exec_callvalue() { // Given let mut machine = setup_machine(); diff --git a/crates/evm/src/tests/test_instructions/test_stop_and_arithmetic_operations.cairo b/crates/evm/src/tests/test_instructions/test_stop_and_arithmetic_operations.cairo index b85554b2e..fd8d25e2a 100644 --- a/crates/evm/src/tests/test_instructions/test_stop_and_arithmetic_operations.cairo +++ b/crates/evm/src/tests/test_instructions/test_stop_and_arithmetic_operations.cairo @@ -171,7 +171,7 @@ fn test_exec_sdiv_pos() { #[test] #[available_gas(20000000)] -fn test__exec_sdiv_neg() { +fn test_exec_sdiv_neg() { // Given let mut machine = setup_machine(); machine.stack.push(BoundedInt::max()).unwrap(); diff --git a/crates/evm/src/tests/test_stack.cairo b/crates/evm/src/tests/test_stack.cairo index 4473cd79c..74312b0bd 100644 --- a/crates/evm/src/tests/test_stack.cairo +++ b/crates/evm/src/tests/test_stack.cairo @@ -16,7 +16,7 @@ fn test_stack_new_should_return_empty_stack() { #[test] #[available_gas(400000)] -fn test__empty__should_return_if_stack_is_empty() { +fn test_empty_should_return_if_stack_is_empty() { // Given let mut stack = StackTrait::new(); @@ -31,7 +31,7 @@ fn test__empty__should_return_if_stack_is_empty() { #[test] #[available_gas(350000)] -fn test__len__should_return_the_length_of_the_stack() { +fn test_len_should_return_the_length_of_the_stack() { // Given let mut stack = StackTrait::new();