diff --git a/internal/test/test.go b/internal/test/test.go index 3124fcad7..4e7121ca7 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -179,12 +179,9 @@ func testCode( contracts := make(map[string]common.Address, 0) for _, contract := range *state.Contracts() { alias := contract.Aliases.ByNetwork("testing") - if alias == nil { - return nil, fmt.Errorf( - "unable to find 'testing' alias for contract: %s", contract.Name, - ) + if alias != nil { + contracts[contract.Name] = common.Address(alias.Address) } - contracts[contract.Name] = common.Address(alias.Address) } testResults := make(map[string]cdcTests.Results, 0) diff --git a/internal/test/test_test.go b/internal/test/test_test.go index 7c9a33023..b9a2a59fa 100644 --- a/internal/test/test_test.go +++ b/internal/test/test_test.go @@ -209,10 +209,40 @@ func TestExecutingTests(t *testing.T) { assert.ErrorContains( t, err, - "unable to find 'testing' alias for contract: Hello", + "could not find the address of contract: Hello", ) }) + t.Run("without testing alias for common contracts", func(t *testing.T) { + t.Parallel() + + // Setup + _, state, _ := util.TestMocks(t) + + c := config.Contract{ + Name: tests.ContractHelloString.Name, + Location: tests.ContractHelloString.Filename, + Aliases: aliases, + } + state.Contracts().AddOrUpdate(c) + // fungibleToken has no `testing` alias, but it is not + // actually deployed/used, so there is no errror. + fungibleToken := config.Contract{ + Name: "FungibleToken", + Location: "cadence/contracts/FungibleToken.cdc", + } + state.Contracts().AddOrUpdate(fungibleToken) + + // Execute script + script := tests.TestScriptWithImport + testFiles := map[string][]byte{ + script.Filename: script.Source, + } + _, err := testCode(testFiles, state, flagsTests{}) + + assert.NoError(t, err) + }) + t.Run("with file read", func(t *testing.T) { t.Parallel()