From d067a466d14d2170074255c9a5637eb27f8874aa Mon Sep 17 00:00:00 2001 From: Khaeljy Date: Sat, 2 Sep 2023 17:29:08 +0200 Subject: [PATCH 1/9] MLOAD test suite --- crates/evm/src/instructions.cairo | 1 + .../src/instructions/memory_operations.cairo | 103 +++++++++--------- crates/evm/src/interpreter.cairo | 26 ++--- crates/evm/src/tests/test_instructions.cairo | 1 + .../test_memory_operations.cairo | 63 +++++++++++ 5 files changed, 132 insertions(+), 62 deletions(-) create mode 100644 crates/evm/src/tests/test_instructions/test_memory_operations.cairo diff --git a/crates/evm/src/instructions.cairo b/crates/evm/src/instructions.cairo index 1c92b2be3..077cf05e5 100644 --- a/crates/evm/src/instructions.cairo +++ b/crates/evm/src/instructions.cairo @@ -16,6 +16,7 @@ mod exchange_operations; mod logging_operations; mod memory_operations; +use memory_operations::MemoryOperationsTrait; mod push_operations; use push_operations::PushOperationsTrait; diff --git a/crates/evm/src/instructions/memory_operations.cairo b/crates/evm/src/instructions/memory_operations.cairo index dc509325f..fc4963376 100644 --- a/crates/evm/src/instructions/memory_operations.cairo +++ b/crates/evm/src/instructions/memory_operations.cairo @@ -4,63 +4,68 @@ use evm::context::ExecutionContext; use evm::context::ExecutionContextTrait; -/// MLOAD operation. -/// Load word from memory and push to stack. -fn exec_mload(ref context: ExecutionContext) {} +#[generate_trait] +impl MemoryOperationsImpl of MemoryOperationsTrait { + /// 0x51 - MLOAD operation. + /// Load word from memory and push to stack. + fn exec_mload(ref self: ExecutionContext) { + panic_with_felt252('MLOAD not implement yet') + } -/// 0x52 - MSTORE operation. -/// Save word to memory. -/// # Specification: https://www.evm.codes/#52?fork=shanghai -fn exec_mstore(ref context: ExecutionContext) {} + /// 0x52 - MSTORE operation. + /// Save word to memory. + /// # Specification: https://www.evm.codes/#52?fork=shanghai + fn exec_mstore(ref self: ExecutionContext) {} -/// 0x58 - PC operation -/// Get the value of the program counter prior to the increment. -/// # Specification: https://www.evm.codes/#58?fork=shanghai -fn exec_pc(ref context: ExecutionContext) {} + /// 0x58 - PC operation + /// Get the value of the program counter prior to the increment. + /// # Specification: https://www.evm.codes/#58?fork=shanghai + fn exec_pc(ref self: ExecutionContext) {} -/// 0x59 - MSIZE operation. -/// Get the value of memory size. -/// # Specification: https://www.evm.codes/#59?fork=shanghai -fn exec_msize(ref context: ExecutionContext) {} + /// 0x59 - MSIZE operation. + /// Get the value of memory size. + /// # Specification: https://www.evm.codes/#59?fork=shanghai + fn exec_msize(ref self: ExecutionContext) {} -/// 0x56 - JUMP operation -/// The JUMP instruction changes the pc counter. -/// The new pc target has to be a JUMPDEST opcode. -/// # Specification: https://www.evm.codes/#56?fork=shanghai -fn exec_jump(ref context: ExecutionContext) {} + /// 0x56 - JUMP operation + /// The JUMP instruction changes the pc counter. + /// The new pc target has to be a JUMPDEST opcode. + /// # Specification: https://www.evm.codes/#56?fork=shanghai + fn exec_jump(ref self: ExecutionContext) {} -/// 0x57 - JUMPI operation. -/// Change the pc counter under a provided certain condition. -/// The new pc target has to be a JUMPDEST opcode. -/// # Specification: https://www.evm.codes/#57?fork=shanghai -fn exec_jumpi(ref context: ExecutionContext) {} + /// 0x57 - JUMPI operation. + /// Change the pc counter under a provided certain condition. + /// The new pc target has to be a JUMPDEST opcode. + /// # Specification: https://www.evm.codes/#57?fork=shanghai + fn exec_jumpi(ref self: ExecutionContext) {} -/// 0x5b - JUMPDEST operation -/// Serves as a check that JUMP or JUMPI was executed correctly. -/// # Specification: https://www.evm.codes/#5b?fork=shanghai -fn exec_jumpdest(ref context: ExecutionContext) {} + /// 0x5b - JUMPDEST operation + /// Serves as a check that JUMP or JUMPI was executed correctly. + /// # Specification: https://www.evm.codes/#5b?fork=shanghai + fn exec_jumpdest(ref self: ExecutionContext) {} -/// 0x50 - POP operation. -/// Pops the first item on the stack (top of the stack). -/// # Specification: https://www.evm.codes/#50?fork=shanghai -fn exec_pop(ref context: ExecutionContext) {} + /// 0x50 - POP operation. + /// Pops the first item on the stack (top of the stack). + /// # Specification: https://www.evm.codes/#50?fork=shanghai + fn exec_pop(ref self: ExecutionContext) {} -/// 0x53 - MSTORE8 operation. -/// Save single byte to memory -/// # Specification: https://www.evm.codes/#53?fork=shanghai -fn exec_mstore8(ref context: ExecutionContext) {} + /// 0x53 - MSTORE8 operation. + /// Save single byte to memory + /// # Specification: https://www.evm.codes/#53?fork=shanghai + fn exec_mstore8(ref self: ExecutionContext) {} -/// 0x55 - SSTORE operation -/// Save 32-byte word to storage. -/// # Specification: https://www.evm.codes/#55?fork=shanghai -fn exec_sstore(ref context: ExecutionContext) {} + /// 0x55 - SSTORE operation + /// Save 32-byte word to storage. + /// # Specification: https://www.evm.codes/#55?fork=shanghai + fn exec_sstore(ref self: ExecutionContext) {} -/// 0x54 - SLOAD operation -/// Load from storage. -/// # Specification: https://www.evm.codes/#54?fork=shanghai -fn exec_sload(ref context: ExecutionContext) {} + /// 0x54 - SLOAD operation + /// Load from storage. + /// # Specification: https://www.evm.codes/#54?fork=shanghai + fn exec_sload(ref self: ExecutionContext) {} -/// 0x5A - GAS operation -/// Get the amount of available gas, including the corresponding reduction for the cost of this instruction. -/// # Specification: https://www.evm.codes/#5a?fork=shanghai -fn exec_gas(ref context: ExecutionContext) {} + /// 0x5A - GAS operation + /// Get the amount of available gas, including the corresponding reduction for the cost of this instruction. + /// # Specification: https://www.evm.codes/#5a?fork=shanghai + fn exec_gas(ref self: ExecutionContext) {} +} diff --git a/crates/evm/src/interpreter.cairo b/crates/evm/src/interpreter.cairo index 439dc4030..ac3695796 100644 --- a/crates/evm/src/interpreter.cairo +++ b/crates/evm/src/interpreter.cairo @@ -15,7 +15,7 @@ use evm::instructions::{ duplication_operations, environmental_information, exchange_operations, logging_operations, memory_operations, sha3, StopAndArithmeticOperationsTrait, ComparisonAndBitwiseOperationsTrait, system_operations, BlockInformationTrait, DuplicationOperationsTrait, - EnvironmentInformationTrait, PushOperationsTrait + EnvironmentInformationTrait, PushOperationsTrait, MemoryOperationsTrait }; use result::ResultTrait; @@ -295,51 +295,51 @@ impl EVMInterpreterImpl of EVMInterpreterTrait { } if opcode == 80 { // POP - memory_operations::exec_pop(ref context); + context.exec_pop(); } if opcode == 81 { // MLOAD - memory_operations::exec_mload(ref context); + context.exec_mload(); } if opcode == 82 { // MSTORE - memory_operations::exec_mstore(ref context); + context.exec_mstore(); } if opcode == 83 { // MSTORE8 - memory_operations::exec_mstore8(ref context); + context.exec_mstore8(); } if opcode == 84 { // SLOAD - memory_operations::exec_sload(ref context); + context.exec_sload(); } if opcode == 85 { // SSTORE - memory_operations::exec_sstore(ref context); + context.exec_sstore(); } if opcode == 86 { // JUMP - memory_operations::exec_jump(ref context); + context.exec_jump(); } if opcode == 87 { // JUMPI - memory_operations::exec_jumpi(ref context); + context.exec_jumpi(); } if opcode == 88 { // PC - memory_operations::exec_pc(ref context); + context.exec_pc(); } if opcode == 89 { // MSIZE - memory_operations::exec_msize(ref context); + context.exec_msize(); } if opcode == 90 { // GAS - memory_operations::exec_gas(ref context); + context.exec_gas(); } if opcode == 91 { // JUMPDEST - memory_operations::exec_jumpdest(ref context); + context.exec_jumpdest(); } if opcode == 95 { // PUSH0 diff --git a/crates/evm/src/tests/test_instructions.cairo b/crates/evm/src/tests/test_instructions.cairo index 1a1048b11..cefcd4b22 100644 --- a/crates/evm/src/tests/test_instructions.cairo +++ b/crates/evm/src/tests/test_instructions.cairo @@ -4,3 +4,4 @@ mod test_duplication_operations; mod test_block_information; mod test_environment_information; mod test_push_operations; +mod test_memory_operations; diff --git a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo new file mode 100644 index 000000000..b01543882 --- /dev/null +++ b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo @@ -0,0 +1,63 @@ +use evm::instructions::MemoryOperationsTrait; +use evm::tests::test_utils::setup_execution_context; +use evm::stack::StackTrait; +use evm::memory::{MemoryTrait}; +use evm::context::{ExecutionContext, ExecutionContextTrait, BoxDynamicExecutionContextDestruct}; + +// 0x51 - MLOAD + +#[test] +#[available_gas(20000000000)] +#[should_panic(expected: ('MLOAD not implement yet',))] +fn test_exec_mload() { + let data: Array<(u256, u256, u256, u32)> = array![ + // (memory_value, input, expected_value, expected_memory_size) + + // Geth: no test ?! + + // Kakarot cairo0 + (0x0000000000000000000000000000000000000000000000000000000000000001, 0, 0x1, 32), + // This is the test case in kakarot cairo0, but playground say, the memory size should be 64 ??? + ( + 0x0000000000000000000000000000000000000000000000000000000000000001, + 16, + 0x100000000000000000000000000000000, + 16 + 32 + ), + // This is the test case in kakarot cairo0, but playground say, the memory size should be 736 ??? + (0x0000000000000000000000000000000000000000000000000000000000000001, 684, 0x0, 684 + 32), + // evm.codes + (0x00000000000000000000000000000000000000000000000000000000000000FF, 0, 0xFF, 32), + (0x00000000000000000000000000000000000000000000000000000000000000FF, 1, 0xFF00, 64) + ]; + + let mut i = 0; + loop { + if (i == data.len()) { + break; + } + + let test_case: (u256, u256, u256, u32) = *data[i]; + let (memory_value, input, expected_value, expected_memory_size) = test_case; + + assert_mload(memory_value, input, expected_value, expected_memory_size); + + i += 1; + } +} + +fn assert_mload(memory_value: u256, input: u256, expected_value: u256, expected_memory_size: u32) { + // Given + let mut ctx = setup_execution_context(); + ctx.memory.store(memory_value, 0); + + ctx.stack.push(input); + + // When + ctx.exec_mload(); + + // Then + assert(ctx.stack.len() == 1, 'stack should have one element'); + assert(ctx.stack.pop().unwrap() == expected_value, 'mload failed'); + assert(ctx.memory.bytes_len == expected_memory_size, 'memory size error'); +} From 05cf375e0a160f19d9e401ad427104578c416579 Mon Sep 17 00:00:00 2001 From: Khaeljy Date: Sat, 2 Sep 2023 19:22:39 +0200 Subject: [PATCH 2/9] Add returns --- .../src/instructions/memory_operations.cairo | 46 ++++++++++++++----- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/crates/evm/src/instructions/memory_operations.cairo b/crates/evm/src/instructions/memory_operations.cairo index fc4963376..927aeb10f 100644 --- a/crates/evm/src/instructions/memory_operations.cairo +++ b/crates/evm/src/instructions/memory_operations.cairo @@ -8,64 +8,86 @@ use evm::context::ExecutionContextTrait; impl MemoryOperationsImpl of MemoryOperationsTrait { /// 0x51 - MLOAD operation. /// Load word from memory and push to stack. - fn exec_mload(ref self: ExecutionContext) { + fn exec_mload(ref self: ExecutionContext) -> Result<(), EVMError> { panic_with_felt252('MLOAD not implement yet') } /// 0x52 - MSTORE operation. /// Save word to memory. /// # Specification: https://www.evm.codes/#52?fork=shanghai - fn exec_mstore(ref self: ExecutionContext) {} + fn exec_mstore(ref self: ExecutionContext) -> Result<(), EVMError> { + Result::Ok(()) + } /// 0x58 - PC operation /// Get the value of the program counter prior to the increment. /// # Specification: https://www.evm.codes/#58?fork=shanghai - fn exec_pc(ref self: ExecutionContext) {} + fn exec_pc(ref self: ExecutionContext) -> Result<(), EVMError> { + Result::Ok(()) + } /// 0x59 - MSIZE operation. /// Get the value of memory size. /// # Specification: https://www.evm.codes/#59?fork=shanghai - fn exec_msize(ref self: ExecutionContext) {} + fn exec_msize(ref self: ExecutionContext) -> Result<(), EVMError> { + Result::Ok(()) + } /// 0x56 - JUMP operation /// The JUMP instruction changes the pc counter. /// The new pc target has to be a JUMPDEST opcode. /// # Specification: https://www.evm.codes/#56?fork=shanghai - fn exec_jump(ref self: ExecutionContext) {} + fn exec_jump(ref self: ExecutionContext) -> Result<(), EVMError> { + Result::Ok(()) + } /// 0x57 - JUMPI operation. /// Change the pc counter under a provided certain condition. /// The new pc target has to be a JUMPDEST opcode. /// # Specification: https://www.evm.codes/#57?fork=shanghai - fn exec_jumpi(ref self: ExecutionContext) {} + fn exec_jumpi(ref self: ExecutionContext) -> Result<(), EVMError> { + Result::Ok(()) + } /// 0x5b - JUMPDEST operation /// Serves as a check that JUMP or JUMPI was executed correctly. /// # Specification: https://www.evm.codes/#5b?fork=shanghai - fn exec_jumpdest(ref self: ExecutionContext) {} + fn exec_jumpdest(ref self: ExecutionContext) -> Result<(), EVMError> { + Result::Ok(()) + } /// 0x50 - POP operation. /// Pops the first item on the stack (top of the stack). /// # Specification: https://www.evm.codes/#50?fork=shanghai - fn exec_pop(ref self: ExecutionContext) {} + fn exec_pop(ref self: ExecutionContext) -> Result<(), EVMError> { + Result::Ok(()) + } /// 0x53 - MSTORE8 operation. /// Save single byte to memory /// # Specification: https://www.evm.codes/#53?fork=shanghai - fn exec_mstore8(ref self: ExecutionContext) {} + fn exec_mstore8(ref self: ExecutionContext) -> Result<(), EVMError> { + Result::Ok(()) + } /// 0x55 - SSTORE operation /// Save 32-byte word to storage. /// # Specification: https://www.evm.codes/#55?fork=shanghai - fn exec_sstore(ref self: ExecutionContext) {} + fn exec_sstore(ref self: ExecutionContext) -> Result<(), EVMError> { + Result::Ok(()) + } /// 0x54 - SLOAD operation /// Load from storage. /// # Specification: https://www.evm.codes/#54?fork=shanghai - fn exec_sload(ref self: ExecutionContext) {} + fn exec_sload(ref self: ExecutionContext) -> Result<(), EVMError> { + Result::Ok(()) + } /// 0x5A - GAS operation /// Get the amount of available gas, including the corresponding reduction for the cost of this instruction. /// # Specification: https://www.evm.codes/#5a?fork=shanghai - fn exec_gas(ref self: ExecutionContext) {} + fn exec_gas(ref self: ExecutionContext) -> Result<(), EVMError> { + Result::Ok(()) + } } From 5825cc67f649a83eea247279f467451ca8b8e3c4 Mon Sep 17 00:00:00 2001 From: Khaeljy Date: Sat, 2 Sep 2023 19:26:15 +0200 Subject: [PATCH 3/9] Add missing use --- crates/evm/src/instructions/memory_operations.cairo | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/evm/src/instructions/memory_operations.cairo b/crates/evm/src/instructions/memory_operations.cairo index 927aeb10f..e8d9cfc77 100644 --- a/crates/evm/src/instructions/memory_operations.cairo +++ b/crates/evm/src/instructions/memory_operations.cairo @@ -3,6 +3,7 @@ // Internal imports use evm::context::ExecutionContext; use evm::context::ExecutionContextTrait; +use evm::errors::EVMError; #[generate_trait] impl MemoryOperationsImpl of MemoryOperationsTrait { From e17ee104f301adae39aa755221c3de0ca80cf79a Mon Sep 17 00:00:00 2001 From: Khaeljy Date: Mon, 4 Sep 2023 23:14:36 +0200 Subject: [PATCH 4/9] Minor changes --- .../test_memory_operations.cairo | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo index b01543882..8d9e33b1e 100644 --- a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo +++ b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo @@ -16,19 +16,12 @@ fn test_exec_mload() { // Geth: no test ?! // Kakarot cairo0 - (0x0000000000000000000000000000000000000000000000000000000000000001, 0, 0x1, 32), - // This is the test case in kakarot cairo0, but playground say, the memory size should be 64 ??? - ( - 0x0000000000000000000000000000000000000000000000000000000000000001, - 16, - 0x100000000000000000000000000000000, - 16 + 32 - ), - // This is the test case in kakarot cairo0, but playground say, the memory size should be 736 ??? - (0x0000000000000000000000000000000000000000000000000000000000000001, 684, 0x0, 684 + 32), + (0x1, 0, 0x1, 32), + (0x1, 16, 0x100000000000000000000000000000000, 64), + (0x1, 684, 0x0, 736), // evm.codes - (0x00000000000000000000000000000000000000000000000000000000000000FF, 0, 0xFF, 32), - (0x00000000000000000000000000000000000000000000000000000000000000FF, 1, 0xFF00, 64) + (0xFF, 0, 0xFF, 32), + (0xFF, 1, 0xFF00, 64) ]; let mut i = 0; From 93c0ee7e43760f9c432959b8deb05fffe762b8b1 Mon Sep 17 00:00:00 2001 From: Khaeljy Date: Mon, 4 Sep 2023 23:24:05 +0200 Subject: [PATCH 5/9] Removal of 2 redundant tests --- .../test_memory_operations.cairo | 44 +++++++------------ 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo index 8d9e33b1e..24dd6bb40 100644 --- a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo +++ b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo @@ -9,34 +9,22 @@ use evm::context::{ExecutionContext, ExecutionContextTrait, BoxDynamicExecutionC #[test] #[available_gas(20000000000)] #[should_panic(expected: ('MLOAD not implement yet',))] -fn test_exec_mload() { - let data: Array<(u256, u256, u256, u32)> = array![ - // (memory_value, input, expected_value, expected_memory_size) - - // Geth: no test ?! - - // Kakarot cairo0 - (0x1, 0, 0x1, 32), - (0x1, 16, 0x100000000000000000000000000000000, 64), - (0x1, 684, 0x0, 736), - // evm.codes - (0xFF, 0, 0xFF, 32), - (0xFF, 1, 0xFF00, 64) - ]; - - let mut i = 0; - loop { - if (i == data.len()) { - break; - } - - let test_case: (u256, u256, u256, u32) = *data[i]; - let (memory_value, input, expected_value, expected_memory_size) = test_case; - - assert_mload(memory_value, input, expected_value, expected_memory_size); - - i += 1; - } +fn test_exec_mload_should_load_a_value_from_memory() { + assert_mload(0x1, 0, 0x1, 32); +} + +#[test] +#[available_gas(20000000000)] +#[should_panic(expected: ('MLOAD not implement yet',))] +fn test_exec_mload_should_load_a_value_from_memory_with_memory_expansion() { + assert_mload(0x1, 16, 0x100000000000000000000000000000000, 64); +} + +#[test] +#[available_gas(20000000000)] +#[should_panic(expected: ('MLOAD not implement yet',))] +fn test_exec_mload_should_load_a_value_from_memory_with_offset_larger_than_msize() { + assert_mload(0x1, 684, 0x0, 736); } fn assert_mload(memory_value: u256, input: u256, expected_value: u256, expected_memory_size: u32) { From 5a03041a5512d60aa96eebc0a379a356e2f3ac6a Mon Sep 17 00:00:00 2001 From: Khaeljy Date: Tue, 5 Sep 2023 10:34:23 +0200 Subject: [PATCH 6/9] Minor changes --- .../tests/test_instructions/test_memory_operations.cairo | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo index 24dd6bb40..42d6ac7f9 100644 --- a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo +++ b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo @@ -27,12 +27,12 @@ fn test_exec_mload_should_load_a_value_from_memory_with_offset_larger_than_msize assert_mload(0x1, 684, 0x0, 736); } -fn assert_mload(memory_value: u256, input: u256, expected_value: u256, expected_memory_size: u32) { +fn assert_mload(value: u256, output: u256, expected_value: u256, expected_memory_size: u32) { // Given let mut ctx = setup_execution_context(); - ctx.memory.store(memory_value, 0); + ctx.memory.store(value, 0); - ctx.stack.push(input); + ctx.stack.push(output); // When ctx.exec_mload(); From 06946b052286a0b6936e3cddbdb4e3261cda9d35 Mon Sep 17 00:00:00 2001 From: Khaeljy Date: Tue, 5 Sep 2023 12:15:00 +0200 Subject: [PATCH 7/9] scarb fmt --- .../src/tests/test_instructions/test_memory_operations.cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo index f13a4901e..6d46882e9 100644 --- a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo +++ b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo @@ -80,4 +80,4 @@ fn assert_mload(value: u256, output: u256, expected_value: u256, expected_memory assert(ctx.stack.len() == 1, 'stack should have one element'); assert(ctx.stack.pop().unwrap() == expected_value, 'mload failed'); assert(ctx.memory.bytes_len == expected_memory_size, 'memory size error'); -} \ No newline at end of file +} From 9336d7590f0c90cbceebc4213d5767392b66da35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LE=20JONCOUR=20K=C3=A9vin?= Date: Wed, 6 Sep 2023 13:46:55 +0200 Subject: [PATCH 8/9] Add missing } --- .../evm/src/tests/test_instructions/test_memory_operations.cairo | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo index 05c23ad5d..b79b56f3d 100644 --- a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo +++ b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo @@ -80,6 +80,7 @@ fn assert_mload(value: u256, output: u256, expected_value: u256, expected_memory assert(ctx.stack.len() == 1, 'stack should have one element'); assert(ctx.stack.pop().unwrap() == expected_value, 'mload failed'); assert(ctx.memory.bytes_len == expected_memory_size, 'memory size error'); +} #[test] #[available_gas(20000000)] From f0cf399a007a23ceeab08e4b62b5e366677444a3 Mon Sep 17 00:00:00 2001 From: Khaeljy Date: Wed, 6 Sep 2023 17:30:23 +0200 Subject: [PATCH 9/9] fix typo --- .../src/tests/test_instructions/test_memory_operations.cairo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo index b79b56f3d..21afabdd2 100644 --- a/crates/evm/src/tests/test_instructions/test_memory_operations.cairo +++ b/crates/evm/src/tests/test_instructions/test_memory_operations.cairo @@ -66,12 +66,12 @@ fn test_exec_mload_should_load_a_value_from_memory_with_offset_larger_than_msize assert_mload(0x1, 684, 0x0, 736); } -fn assert_mload(value: u256, output: u256, expected_value: u256, expected_memory_size: u32) { +fn assert_mload(value: u256, offset: u256, expected_value: u256, expected_memory_size: u32) { // Given let mut ctx = setup_execution_context(); ctx.memory.store(value, 0); - ctx.stack.push(output); + ctx.stack.push(offset); // When ctx.exec_mload();