@@ -3,8 +3,6 @@ package bind
33import (
44 _ "embed"
55 "fmt"
6- "os"
7- "strings"
86 "testing"
97
108 "github.com/ethereum/go-ethereum/accounts/abi"
@@ -331,8 +329,9 @@ var bindTests2 = []bindV2Test{
331329 },
332330}
333331
332+ // TestBindingV2ConvertedV1Tests regenerates contracts from the v1 binding test cases (using v2 binding mode) and ensures
333+ // that no mutations occurred compared to the expected output included under internal/convertedv1bindtests.
334334func TestBindingV2ConvertedV1Tests (t * testing.T ) {
335- os .Mkdir ("convertedv1bindtests" , 0777 )
336335 for _ , tc := range bindTests2 {
337336 t .Run (tc .name , func (t * testing.T ) {
338337 if tc .types == nil {
@@ -344,21 +343,9 @@ func TestBindingV2ConvertedV1Tests(t *testing.T) {
344343 t .Fatalf ("got error from bind: %v" , err )
345344 }
346345
347- // TODO: remove these before merging abigen2 PR. these are for convenience if I need to regenerate the converted bindings or add a new one.
348- if err := os .WriteFile (fmt .Sprintf ("convertedv1bindtests/%s.go" , strings .ToLower (tc .name )), []byte (code ), 0666 ); err != nil {
349- t .Fatalf ("err writing expected output to file: %v\n " , err )
346+ if code != tc .expectedBindings {
347+ t .Fatalf ("regenerating binding %s resulted in a mutation." , tc .name )
350348 }
351- /*
352- fmt.Printf("//go:embed v2/internal/convertedv1bindtests/%s.go\n", strings.ToLower(tc.name))
353- fmt.Printf("var v1TestBinding%s string\n", tc.name)
354- fmt.Println()
355- */
356- /*
357- if code != tc.expectedBindings {
358- //t.Fatalf("name mismatch for %s", tc.name)
359- t.Fatalf("'%s'\n!=\n'%s'\n", code, tc.expectedBindings)
360- }
361- */
362349 })
363350 }
364351}
0 commit comments