mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 19:30:44 +00:00
ethclient: include data in call arguments
This commit is contained in:
parent
2919267b64
commit
43349eb950
4 changed files with 38 additions and 2 deletions
|
|
@ -786,7 +786,9 @@ func toCallArg(msg ethereum.CallMsg) interface{} {
|
|||
"to": msg.To,
|
||||
}
|
||||
if len(msg.Data) > 0 {
|
||||
arg["input"] = hexutil.Bytes(msg.Data)
|
||||
input := hexutil.Bytes(msg.Data)
|
||||
arg["input"] = input
|
||||
arg["data"] = input
|
||||
}
|
||||
if msg.Value != nil {
|
||||
arg["value"] = (*hexutil.Big)(msg.Value)
|
||||
|
|
|
|||
|
|
@ -370,7 +370,9 @@ func toCallArg(msg ethereum.CallMsg) interface{} {
|
|||
"to": msg.To,
|
||||
}
|
||||
if len(msg.Data) > 0 {
|
||||
arg["input"] = hexutil.Bytes(msg.Data)
|
||||
input := hexutil.Bytes(msg.Data)
|
||||
arg["input"] = input
|
||||
arg["data"] = input
|
||||
}
|
||||
if msg.Value != nil {
|
||||
arg["value"] = (*hexutil.Big)(msg.Value)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
|
@ -275,6 +276,21 @@ func testAccessList(t *testing.T, client *rpc.Client) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestToCallArgIncludesDataAndInput(t *testing.T) {
|
||||
input := common.FromHex("0x01020304")
|
||||
arg := toCallArg(ethereum.CallMsg{Data: input}).(map[string]interface{})
|
||||
|
||||
for _, key := range []string{"input", "data"} {
|
||||
have, ok := arg[key].(hexutil.Bytes)
|
||||
if !ok {
|
||||
t.Fatalf("missing call arg %q", key)
|
||||
}
|
||||
if !bytes.Equal(have, input) {
|
||||
t.Fatalf("call arg %q = %x, want %x", key, have, input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testGetProof(t *testing.T, client *rpc.Client, addr common.Address) {
|
||||
ec := New(client)
|
||||
ethcl := ethclient.NewClient(client)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
)
|
||||
|
||||
func TestToFilterArg(t *testing.T) {
|
||||
|
|
@ -179,3 +180,18 @@ func TestToFilterArg(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestToCallArgIncludesDataAndInput(t *testing.T) {
|
||||
input := common.FromHex("0x01020304")
|
||||
arg := toCallArg(ethereum.CallMsg{Data: input}).(map[string]interface{})
|
||||
|
||||
for _, key := range []string{"input", "data"} {
|
||||
have, ok := arg[key].(hexutil.Bytes)
|
||||
if !ok {
|
||||
t.Fatalf("missing call arg %q", key)
|
||||
}
|
||||
if !reflect.DeepEqual(have, hexutil.Bytes(input)) {
|
||||
t.Fatalf("call arg %q = %x, want %x", key, have, input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue