@@ -12,16 +12,25 @@ import (
12
12
"github.com/ava-labs/avalanchego/utils/packages"
13
13
)
14
14
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.
15
22
func TestMustNotImport (t * testing.T ) {
16
23
require := require .New (t )
17
24
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
+ }
18
30
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 ,
25
34
}
26
35
for packageName , forbiddenImports := range mustNotImport {
27
36
packagePath := path .Join ("github.com/ava-labs/avalanchego" , packageName )
0 commit comments