Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2157,20 +2157,10 @@ func golangBindings(t *testing.T, overload bool) {
import (
"testing"

"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/plugin/evm/customtypes"
libevmparams "github.com/ava-labs/libevm/params"
libevmtypes "github.com/ava-labs/libevm/core/types"

%s
)

func Test%s(t *testing.T) {
customtypes.Register()
t.Cleanup(libevmtypes.TestOnlyClearRegisteredExtras)
params.RegisterExtras()
t.Cleanup(libevmparams.TestOnlyClearRegisteredExtras)

%s
}
`, tt.imports, tt.name, tt.tester)
Expand All @@ -2179,6 +2169,29 @@ func golangBindings(t *testing.T, overload bool) {
}
})
}

// We must also write a main_test.go file for libevm registrations.
mainTest := `
package bindtest

import (
"os"
"testing"

"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/plugin/evm/customtypes"
)

func TestMain(m *testing.M) {
customtypes.Register()
params.RegisterExtras()
os.Exit(m.Run())
}
`
if err := os.WriteFile(filepath.Join(pkg, "main_test.go"), []byte(mainTest), 0600); err != nil {
t.Fatalf("failed to write main test: %v", err)
}

// Convert the package to go modules and use the current source for go-ethereum
moder := exec.Command(gocmd, "mod", "init", "bindtest")
moder.Dir = pkg
Expand All @@ -2197,7 +2210,7 @@ func golangBindings(t *testing.T, overload bool) {
t.Fatalf("failed to tidy Go module file: %v\n%s", err, out)
}
// Test the entire package and report any failures
cmd := exec.Command(gocmd, "test", "-v", "-count", "1")
cmd := exec.Command(gocmd, "test", "-v", "-count", "1", "-race")
cmd.Dir = pkg
if out, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("failed to run binding test: %v\n%s", err, out)
Expand Down
1 change: 0 additions & 1 deletion scripts/known_flakes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
TestClientCancelWebsocket
TestClientWebsocketLargeMessage
TestGolangBindings
TestMempoolAtmTxsAppGossipHandlingDiscardedTx
TestMempoolEthTxsAppGossipHandling
TestResumeSyncAccountsTrieInterrupted
Expand Down
Loading