Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing stRandom/randomStatetest649.json test #103

Merged
merged 4 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions state/runtime/evm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,10 @@ func opCodeCopy(c *state) {
dataOffset := c.pop()
length := c.pop()

if length.Uint64() <= 0 {
return
}

if !c.allocateMemory(memOffset, length) {
return
}
Expand Down
17 changes: 17 additions & 0 deletions state/runtime/evm/instructions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,23 @@ func TestCallDataCopy(t *testing.T) {
assert.Equal(t, big.NewInt(1).FillBytes(make([]byte, 32)), s.memory)
}

func TestCodeCopyLenZero(t *testing.T) {
s, cancelFn := getState(&chain.ForksInTime{})
defer cancelFn()

var expectedGas = s.gas

s.push(big.NewInt(0)) //length
s.push(big.NewInt(0)) //dataOffset
s.push(big.NewInt(0)) //memOffset

opCodeCopy(s)

// We check that no gas was spent and there was no error
assert.Equal(t, expectedGas, s.gas)
assert.NoError(t, s.err)
}

func TestCodeCopy(t *testing.T) {
s, cancelFn := getState(&chain.ForksInTime{})
defer cancelFn()
Expand Down
Loading