accounts/abi: add basic support for error types (#23161)

This is the initial step for support of Solidity errors in contract bindings.
As of this change, errors can be decoded, but are not supported in
bindings yet.

Closes #23157
This commit is contained in:
Marius van der Wijden
2021-10-14 13:33:28 +02:00
committed by GitHub
parent 011fe3eb5e
commit 08e782c61f
5 changed files with 232 additions and 81 deletions

View File

@ -295,6 +295,20 @@ func TestOverloadedMethodSignature(t *testing.T) {
check("bar0", "bar(uint256,uint256)", false)
}
func TestCustomErrors(t *testing.T) {
json := `[{ "inputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ],"name": "MyError", "type": "error"} ]`
abi, err := JSON(strings.NewReader(json))
if err != nil {
t.Fatal(err)
}
check := func(name string, expect string) {
if abi.Errors[name].Sig != expect {
t.Fatalf("The signature of overloaded method mismatch, want %s, have %s", expect, abi.Methods[name].Sig)
}
}
check("MyError", "MyError(uint256)")
}
func TestMultiPack(t *testing.T) {
abi, err := JSON(strings.NewReader(jsondata))
if err != nil {