Skip to content

Commit 949411b

Browse files
committed
Merge remote-tracking branch 'origin/master' into alarso16/add-usetesting-linter
2 parents 26f7a3a + 53b9eb4 commit 949411b

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

accounts/abi/bind/bind_test.go

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,20 +2157,10 @@ func golangBindings(t *testing.T, overload bool) {
21572157
import (
21582158
"testing"
21592159
2160-
"github.com/ava-labs/coreth/params"
2161-
"github.com/ava-labs/coreth/plugin/evm/customtypes"
2162-
libevmparams "github.com/ava-labs/libevm/params"
2163-
libevmtypes "github.com/ava-labs/libevm/core/types"
2164-
21652160
%s
21662161
)
21672162
21682163
func Test%s(t *testing.T) {
2169-
customtypes.Register()
2170-
t.Cleanup(libevmtypes.TestOnlyClearRegisteredExtras)
2171-
params.RegisterExtras()
2172-
t.Cleanup(libevmparams.TestOnlyClearRegisteredExtras)
2173-
21742164
%s
21752165
}
21762166
`, tt.imports, tt.name, tt.tester)
@@ -2179,6 +2169,30 @@ func golangBindings(t *testing.T, overload bool) {
21792169
}
21802170
})
21812171
}
2172+
2173+
// We must also write a main_test.go file for libevm registrations.
2174+
mainTest := `
2175+
package bindtest
2176+
2177+
import (
2178+
"os"
2179+
"testing"
2180+
2181+
"github.com/ava-labs/coreth/params"
2182+
"github.com/ava-labs/coreth/plugin/evm/customtypes"
2183+
)
2184+
2185+
func TestMain(m *testing.M) {
2186+
customtypes.Register()
2187+
params.RegisterExtras()
2188+
os.Exit(m.Run())
2189+
}
2190+
`
2191+
mainPath := filepath.Join(pkg, "main_test.go")
2192+
if err := os.WriteFile(mainPath, []byte(mainTest), 0600); err != nil {
2193+
t.Fatalf("os.WriteFile(%q, 0600): %v", mainPath, err)
2194+
}
2195+
21822196
// Convert the package to go modules and use the current source for go-ethereum
21832197
moder := exec.Command(gocmd, "mod", "init", "bindtest")
21842198
moder.Dir = pkg
@@ -2197,7 +2211,7 @@ func golangBindings(t *testing.T, overload bool) {
21972211
t.Fatalf("failed to tidy Go module file: %v\n%s", err, out)
21982212
}
21992213
// Test the entire package and report any failures
2200-
cmd := exec.Command(gocmd, "test", "-v", "-count", "1")
2214+
cmd := exec.Command(gocmd, "test", "-v", "-count", "1", "-race")
22012215
cmd.Dir = pkg
22022216
if out, err := cmd.CombinedOutput(); err != nil {
22032217
t.Fatalf("failed to run binding test: %v\n%s", err, out)

scripts/known_flakes.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
TestClientCancelWebsocket
22
TestClientWebsocketLargeMessage
3-
TestGolangBindings
43
TestMempoolAtmTxsAppGossipHandlingDiscardedTx
54
TestMempoolEthTxsAppGossipHandling
65
TestResumeSyncAccountsTrieInterrupted

0 commit comments

Comments
 (0)