@@ -2165,20 +2165,10 @@ func golangBindings(t *testing.T, overload bool) {
21652165 import (
21662166 "testing"
21672167
2168- "github.com/ava-labs/subnet-evm/params"
2169- "github.com/ava-labs/subnet-evm/plugin/evm/customtypes"
2170- libevmparams "github.com/ava-labs/libevm/params"
2171- libevmtypes "github.com/ava-labs/libevm/core/types"
2172-
21732168 %s
21742169 )
21752170
21762171 func Test%s(t *testing.T) {
2177- customtypes.Register()
2178- t.Cleanup(libevmtypes.TestOnlyClearRegisteredExtras)
2179- params.RegisterExtras()
2180- t.Cleanup(libevmparams.TestOnlyClearRegisteredExtras)
2181-
21822172 %s
21832173 }
21842174 ` , tt .imports , tt .name , tt .tester )
@@ -2187,6 +2177,30 @@ func golangBindings(t *testing.T, overload bool) {
21872177 }
21882178 })
21892179 }
2180+
2181+ // We must also write a main_test.go file for libevm registrations.
2182+ mainTest := `
2183+ package bindtest
2184+
2185+ import (
2186+ "os"
2187+ "testing"
2188+
2189+ "github.com/ava-labs/subnet-evm/params"
2190+ "github.com/ava-labs/subnet-evm/plugin/evm/customtypes"
2191+ )
2192+
2193+ func TestMain(m *testing.M) {
2194+ customtypes.Register()
2195+ params.RegisterExtras()
2196+ os.Exit(m.Run())
2197+ }
2198+ `
2199+ mainPath := filepath .Join (pkg , "main_test.go" )
2200+ if err := os .WriteFile (mainPath , []byte (mainTest ), 0600 ); err != nil {
2201+ t .Fatalf ("os.WriteFile(%q, 0600): %v" , mainPath , err )
2202+ }
2203+
21902204 // Convert the package to go modules and use the current source for go-ethereum
21912205 moder := exec .Command (gocmd , "mod" , "init" , "bindtest" )
21922206 moder .Dir = pkg
@@ -2205,7 +2219,7 @@ func golangBindings(t *testing.T, overload bool) {
22052219 t .Fatalf ("failed to tidy Go module file: %v\n %s" , err , out )
22062220 }
22072221 // Test the entire package and report any failures
2208- cmd := exec .Command (gocmd , "test" , "-v" , "-count" , "1" )
2222+ cmd := exec .Command (gocmd , "test" , "-v" , "-count" , "1" , "-race" )
22092223 cmd .Dir = pkg
22102224 if out , err := cmd .CombinedOutput (); err != nil {
22112225 t .Fatalf ("failed to run binding test: %v\n %s" , err , out )
0 commit comments