mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
fix test 'BindingV2ConvertedV1Tests'. add more comprehensive output checking to solc errors test.
This commit is contained in:
parent
8d3fc41c9a
commit
bda5e4c496
2 changed files with 23 additions and 20 deletions
|
|
@ -3,8 +3,6 @@ package bind
|
|||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
|
|
@ -331,8 +329,9 @@ var bindTests2 = []bindV2Test{
|
|||
},
|
||||
}
|
||||
|
||||
// TestBindingV2ConvertedV1Tests regenerates contracts from the v1 binding test cases (using v2 binding mode) and ensures
|
||||
// that no mutations occurred compared to the expected output included under internal/convertedv1bindtests.
|
||||
func TestBindingV2ConvertedV1Tests(t *testing.T) {
|
||||
os.Mkdir("convertedv1bindtests", 0777)
|
||||
for _, tc := range bindTests2 {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if tc.types == nil {
|
||||
|
|
@ -344,21 +343,9 @@ func TestBindingV2ConvertedV1Tests(t *testing.T) {
|
|||
t.Fatalf("got error from bind: %v", err)
|
||||
}
|
||||
|
||||
// TODO: remove these before merging abigen2 PR. these are for convenience if I need to regenerate the converted bindings or add a new one.
|
||||
if err := os.WriteFile(fmt.Sprintf("convertedv1bindtests/%s.go", strings.ToLower(tc.name)), []byte(code), 0666); err != nil {
|
||||
t.Fatalf("err writing expected output to file: %v\n", err)
|
||||
if code != tc.expectedBindings {
|
||||
t.Fatalf("regenerating binding %s resulted in a mutation.", tc.name)
|
||||
}
|
||||
/*
|
||||
fmt.Printf("//go:embed v2/internal/convertedv1bindtests/%s.go\n", strings.ToLower(tc.name))
|
||||
fmt.Printf("var v1TestBinding%s string\n", tc.name)
|
||||
fmt.Println()
|
||||
*/
|
||||
/*
|
||||
if code != tc.expectedBindings {
|
||||
//t.Fatalf("name mismatch for %s", tc.name)
|
||||
t.Fatalf("'%s'\n!=\n'%s'\n", code, tc.expectedBindings)
|
||||
}
|
||||
*/
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -402,11 +402,27 @@ func TestErrors(t *testing.T) {
|
|||
if !hasRevertErrorData {
|
||||
t.Fatalf("expected call error to contain revert error data.")
|
||||
}
|
||||
unpackedErr := ctrct.UnpackError(raw)
|
||||
if unpackedErr == nil {
|
||||
rawUnpackedErr := ctrct.UnpackError(raw)
|
||||
if rawUnpackedErr == nil {
|
||||
t.Fatalf("expected to unpack error")
|
||||
}
|
||||
// TODO: check anything about the error?
|
||||
|
||||
unpackedErr, ok := rawUnpackedErr.(*solc_errors.CBadThing)
|
||||
if !ok {
|
||||
t.Fatalf("unexpected type for error")
|
||||
}
|
||||
if unpackedErr.Arg1.Cmp(big.NewInt(0)) != 0 {
|
||||
t.Fatalf("bad unpacked error result: expected Arg1 field to be 0. got %s", unpackedErr.Arg1.String())
|
||||
}
|
||||
if unpackedErr.Arg2.Cmp(big.NewInt(1)) != 0 {
|
||||
t.Fatalf("bad unpacked error result: expected Arg2 field to be 1. got %s", unpackedErr.Arg2.String())
|
||||
}
|
||||
if unpackedErr.Arg3.Cmp(big.NewInt(2)) != 0 {
|
||||
t.Fatalf("bad unpacked error result: expected Arg3 to be 2. got %s", unpackedErr.Arg3.String())
|
||||
}
|
||||
if unpackedErr.Arg4 != false {
|
||||
t.Fatalf("bad unpacked error result: expected Arg4 to be false. got true")
|
||||
}
|
||||
}
|
||||
|
||||
// TestBindingGeneration tests that re-running generation of bindings does not result in mutations to the binding code
|
||||
|
|
|
|||
Loading…
Reference in a new issue