mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
parent
548adb56e6
commit
a5eab7eddb
3 changed files with 5 additions and 4 deletions
|
|
@ -88,7 +88,7 @@ func fromBuf(vm *goja.Runtime, bufType goja.Value, buf goja.Value, allowString b
|
||||||
b := obj.Get("buffer").Export().(goja.ArrayBuffer).Bytes()
|
b := obj.Get("buffer").Export().(goja.ArrayBuffer).Bytes()
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("invalid buffer type")
|
return nil, errors.New("invalid buffer type")
|
||||||
}
|
}
|
||||||
|
|
||||||
// jsTracer is an implementation of the Tracer interface which evaluates
|
// jsTracer is an implementation of the Tracer interface which evaluates
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ package logger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -84,7 +84,7 @@ func TestStructLogMarshalingOmitEmpty(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{"empty err and no fields", &StructLog{},
|
{"empty err and no fields", &StructLog{},
|
||||||
`{"pc":0,"op":0,"gas":"0x0","gasCost":"0x0","memSize":0,"stack":null,"depth":0,"refund":0,"opName":"STOP"}`},
|
`{"pc":0,"op":0,"gas":"0x0","gasCost":"0x0","memSize":0,"stack":null,"depth":0,"refund":0,"opName":"STOP"}`},
|
||||||
{"with err", &StructLog{Err: fmt.Errorf("this failed")},
|
{"with err", &StructLog{Err: errors.New("this failed")},
|
||||||
`{"pc":0,"op":0,"gas":"0x0","gasCost":"0x0","memSize":0,"stack":null,"depth":0,"refund":0,"opName":"STOP","error":"this failed"}`},
|
`{"pc":0,"op":0,"gas":"0x0","gasCost":"0x0","memSize":0,"stack":null,"depth":0,"refund":0,"opName":"STOP","error":"this failed"}`},
|
||||||
{"with mem", &StructLog{Memory: make([]byte, 2), MemorySize: 2},
|
{"with mem", &StructLog{Memory: make([]byte, 2), MemorySize: 2},
|
||||||
`{"pc":0,"op":0,"gas":"0x0","gasCost":"0x0","memory":"0x0000","memSize":2,"stack":null,"depth":0,"refund":0,"opName":"STOP"}`},
|
`{"pc":0,"op":0,"gas":"0x0","gasCost":"0x0","memory":"0x0000","memSize":2,"stack":null,"depth":0,"refund":0,"opName":"STOP"}`},
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package tracers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
|
@ -105,7 +106,7 @@ const (
|
||||||
// It zero-pads the slice if it extends beyond memory bounds.
|
// It zero-pads the slice if it extends beyond memory bounds.
|
||||||
func GetMemoryCopyPadded(m *vm.Memory, offset, size int64) ([]byte, error) {
|
func GetMemoryCopyPadded(m *vm.Memory, offset, size int64) ([]byte, error) {
|
||||||
if offset < 0 || size < 0 {
|
if offset < 0 || size < 0 {
|
||||||
return nil, fmt.Errorf("offset or size must not be negative")
|
return nil, errors.New("offset or size must not be negative")
|
||||||
}
|
}
|
||||||
if int(offset+size) < m.Len() { // slice fully inside memory
|
if int(offset+size) < m.Len() { // slice fully inside memory
|
||||||
return m.GetCopy(offset, size), nil
|
return m.GetCopy(offset, size), nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue