accounts/abi: fix panic in MethodById lookup. Fixes #17797 (#17798)

This commit is contained in:
Martin Holst Swende
2018-10-01 14:17:37 +02:00
committed by Guillaume Ballet
parent dc5d643bb5
commit 96fd50be10
2 changed files with 13 additions and 1 deletions

View File

@ -711,5 +711,14 @@ func TestABI_MethodById(t *testing.T) {
t.Errorf("Method %v (id %v) not 'findable' by id in ABI", name, common.ToHex(m.Id()))
}
}
// Also test empty
if _, err := abi.MethodById([]byte{0x00}); err == nil {
t.Errorf("Expected error, too short to decode data")
}
if _, err := abi.MethodById([]byte{}); err == nil {
t.Errorf("Expected error, too short to decode data")
}
if _, err := abi.MethodById(nil); err == nil {
t.Errorf("Expected error, nil is short to decode data")
}
}