Skip to content

Commit

Permalink
docs: document mstore test
Browse files Browse the repository at this point in the history
  • Loading branch information
leovct committed Jul 25, 2024
1 parent 265acda commit 2971d14
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions stack_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,23 @@ func TestMStore(t *testing.T) {
op := func(evm IEVM) error { return evm.MStore() }

// Stack
// [32, 444, 2, 3]
offset := 32
initialStack := []uint64{3, 2, 444, uint64(offset)}

// Memory
// Each word is represented by 32 bytes.
// [111, 222, 333]
word1 := uint256.NewInt(111).Bytes32()
word2 := uint256.NewInt(222).Bytes32()
word3 := uint256.NewInt(333).Bytes32()
var memory []byte
memory = append(append(append(memory, word1[:]...), word2[:]...), word3[:]...)

// Expected
// - Stack: [2, 3]
// - Memory: [111, 444, 333]
expectedStack := []uint64{3, 2}
var expectedMemory []byte
newWord := uint256.NewInt(444).Bytes32()
expectedMemory = append(append(append(expectedMemory, word1[:]...), newWord[:]...), word3[:]...)

testStackOperationWithNewEVM(t, op, nil, initialStack, expectedStack, memory, nil)
}

Expand Down

0 comments on commit 2971d14

Please sign in to comment.