mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
feat:unified naming
This commit is contained in:
parent
0a2f33946b
commit
01c16b2659
5 changed files with 10 additions and 10 deletions
|
|
@ -198,9 +198,9 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MethodById looks up a method by the 4-byte id,
|
||||
// MethodByID looks up a method by the 4-byte id,
|
||||
// returns nil if none found.
|
||||
func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
|
||||
func (abi *ABI) MethodByID(sigdata []byte) (*Method, error) {
|
||||
if len(sigdata) < 4 {
|
||||
return nil, fmt.Errorf("data too short (%d bytes) for abi method lookup", len(sigdata))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -983,7 +983,7 @@ func TestABI_MethodById(t *testing.T) {
|
|||
}
|
||||
for name, m := range abi.Methods {
|
||||
a := fmt.Sprintf("%v", m)
|
||||
m2, err := abi.MethodById(m.ID)
|
||||
m2, err := abi.MethodByID(m.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to look up ABI method: %v", err)
|
||||
}
|
||||
|
|
@ -993,17 +993,17 @@ func TestABI_MethodById(t *testing.T) {
|
|||
}
|
||||
}
|
||||
// test unsuccessful lookups
|
||||
if _, err = abi.MethodById(crypto.Keccak256()); err == nil {
|
||||
if _, err = abi.MethodByID(crypto.Keccak256()); err == nil {
|
||||
t.Error("Expected error: no method with this id")
|
||||
}
|
||||
// Also test empty
|
||||
if _, err := abi.MethodById([]byte{0x00}); err == nil {
|
||||
if _, err := abi.MethodByID([]byte{0x00}); err == nil {
|
||||
t.Errorf("Expected error, too short to decode data")
|
||||
}
|
||||
if _, err := abi.MethodById([]byte{}); err == nil {
|
||||
if _, err := abi.MethodByID([]byte{}); err == nil {
|
||||
t.Errorf("Expected error, too short to decode data")
|
||||
}
|
||||
if _, err := abi.MethodById(nil); err == nil {
|
||||
if _, err := abi.MethodByID(nil); err == nil {
|
||||
t.Errorf("Expected error, nil is short to decode data")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ func parseCallData(calldata []byte, unescapedAbidata string) (*decodedCallData,
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid method signature (%q): %v", unescapedAbidata, err)
|
||||
}
|
||||
method, err := abispec.MethodById(sigdata)
|
||||
method, err := abispec.MethodByID(sigdata)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ func verify(t *testing.T, jsondata, calldata string, exp []interface{}) {
|
|||
}
|
||||
cd := common.Hex2Bytes(calldata)
|
||||
sigdata, argdata := cd[:4], cd[4:]
|
||||
method, err := abispec.MethodById(sigdata)
|
||||
method, err := abispec.MethodByID(sigdata)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ func TestEmbeddedDatabase(t *testing.T) {
|
|||
t.Errorf("Failed to parse ABI: %v", err)
|
||||
continue
|
||||
}
|
||||
m, err := abistruct.MethodById(common.Hex2Bytes(id))
|
||||
m, err := abistruct.MethodByID(common.Hex2Bytes(id))
|
||||
if err != nil {
|
||||
t.Errorf("Failed to get method by id (%s): %v", id, err)
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in a new issue