Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions engine/test/environment/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
type components struct {
mu sync.Mutex

Name string
Chains []fchain.BlockChain
AddressBook fdeployment.AddressBook
Datastore fdatastore.DataStore
Expand Down
9 changes: 7 additions & 2 deletions engine/test/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

const (
environmentName = "test_environment"
DefaultEnvironmentName = "test_environment"
)

// New creates a new environment for testing.
Expand Down Expand Up @@ -67,9 +67,14 @@ func (l *Loader) Load(ctx context.Context, opts ...LoadOpt) (*fdeployment.Enviro
oc = foffchain.NewMemoryJobDistributor()
}

name := cmps.Name
if name == "" {
name = DefaultEnvironmentName
}
Comment thread
jkongie marked this conversation as resolved.

// CRERunner may be nil; tests that need CRE use WithCRERunner(cre.NewRunner(cre.WithCLI(cremocks.NewMockCLIRunner(t)))).
return &fdeployment.Environment{
Name: environmentName,
Name: name,
Logger: cmps.Logger,
BlockChains: fchain.NewBlockChainsFromSlice(cmps.Chains),
ExistingAddresses: ab,
Expand Down
11 changes: 11 additions & 0 deletions engine/test/environment/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ func TestLoader_Load_NodeIDsOption(t *testing.T) {
require.Equal(t, nodeIDs, env.NodeIDs)
}

func TestLoader_Load_NameOption(t *testing.T) {
t.Parallel()

name := "test-name"
loader := NewLoader()
env, err := loader.Load(t.Context(), WithName(name))
require.NoError(t, err)
require.NotNil(t, env)
require.Equal(t, name, env.Name)
}

func TestLoader_Load_AddressBookOption(t *testing.T) {
t.Parallel()

Expand Down
8 changes: 8 additions & 0 deletions engine/test/environment/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ func WithNodeIDs(nodeIDs []string) LoadOpt {
}
}

// WithName sets the name for the environment.
func WithName(name string) LoadOpt {
return func(cmps *components) error {
cmps.Name = name
return nil
}
}

// withChainLoader creates a LoadOpt that loads chains using the provided loader and selectors.
func withChainLoader(t *testing.T, loader *onchain.ChainLoader, selectors []uint64) LoadOpt {
t.Helper()
Expand Down
Loading