Skip to content

Commit aa60844

Browse files
authored
test only relevant packages for subnet-evm (#4345)
Signed-off-by: Ceyhun Onur <[email protected]>
1 parent 68b2de3 commit aa60844

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tests/imports_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,25 @@ import (
1212
"github.com/ava-labs/avalanchego/utils/packages"
1313
)
1414

15+
// TestMustNotImport tests that we do not import certain packages (like coreth's customtypes package) that would configure libevm globals.
16+
// Libevm panics if a package tries to register a custom type or extra after the globals have been configured (re-registration).
17+
// E2E test packages are used both from Subnet-EVM and Coreth.
18+
// Registering the libevm globals here in these packages does not necessarily break avalanchego e2e testing, but Subnet-EVM (or Coreth) E2E testing.
19+
// So any illegal use here will only be a problem once Subnet-EVM or Coreth bumps the avalanchego version, breaking the release cycles of
20+
// AvalancheGo and other repositories.
21+
// Transitory imports are also checked with packages.GetDependencies.
1522
func TestMustNotImport(t *testing.T) {
1623
require := require.New(t)
1724

25+
// These packages configure libevm globally by registering custom types and extras.
26+
illegalPaths := []string{
27+
"github.com/ava-labs/coreth/params",
28+
"github.com/ava-labs/coreth/plugin/evm/customtypes",
29+
}
1830
mustNotImport := map[string][]string{
19-
// Importing these packages configures libevm globally. This must not be
20-
// done to support both coreth and subnet-evm.
21-
"tests/...": {
22-
"github.com/ava-labs/coreth/params",
23-
"github.com/ava-labs/coreth/plugin/evm/customtypes",
24-
},
31+
"tests/": illegalPaths,
32+
"tests/antithesis/": illegalPaths,
33+
"tests/fixture/...": illegalPaths,
2534
}
2635
for packageName, forbiddenImports := range mustNotImport {
2736
packagePath := path.Join("github.com/ava-labs/avalanchego", packageName)

0 commit comments

Comments
 (0)