From 321539ef50389221ffb9de04e13868082b0cacfb Mon Sep 17 00:00:00 2001 From: AnieeG Date: Thu, 21 Nov 2024 11:53:57 -0800 Subject: [PATCH] fix ApplyChangesets --- deployment/common/changeset/test_helpers.go | 30 +++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/deployment/common/changeset/test_helpers.go b/deployment/common/changeset/test_helpers.go index ae20ba61abf..913b4544f30 100644 --- a/deployment/common/changeset/test_helpers.go +++ b/deployment/common/changeset/test_helpers.go @@ -8,7 +8,6 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers" jobv1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/job" "github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext" - "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/deployment" ) @@ -35,26 +34,21 @@ func WrapChangeSet[C any](fn deployment.ChangeSet[C]) func(e deployment.Environm // ApplyChangesets applies the changeset applications to the environment and returns the updated environment. func ApplyChangesets(t *testing.T, e deployment.Environment, timelocksPerChain map[uint64]*gethwrappers.RBACTimelock, changesetApplications []ChangesetApplication) (deployment.Environment, error) { - addrBook := deployment.NewMemoryAddressBook() - require.NoError(t, addrBook.Merge(e.ExistingAddresses)) - currentEnv := deployment.NewEnvironment( - e.Name, - e.Logger, - addrBook, - e.Chains, - e.NodeIDs, - e.Offchain, - ) + currentEnv := e for i, csa := range changesetApplications { - out, err := csa.Changeset(*currentEnv, csa.Config) + out, err := csa.Changeset(currentEnv, csa.Config) if err != nil { return e, fmt.Errorf("failed to apply changeset at index %d: %w", i, err) } + var addresses deployment.AddressBook if out.AddressBook != nil { - err := currentEnv.ExistingAddresses.Merge(out.AddressBook) + addresses = out.AddressBook + err := addresses.Merge(currentEnv.ExistingAddresses) if err != nil { return e, fmt.Errorf("failed to merge address book: %w", err) } + } else { + addresses = currentEnv.ExistingAddresses } if out.JobSpecs != nil { ctx := testcontext.Get(t) @@ -89,6 +83,14 @@ func ApplyChangesets(t *testing.T, e deployment.Environment, timelocksPerChain m } } } + currentEnv = deployment.Environment{ + Name: e.Name, + Logger: e.Logger, + ExistingAddresses: addresses, + Chains: e.Chains, + NodeIDs: e.NodeIDs, + Offchain: e.Offchain, + } } - return *currentEnv, nil + return currentEnv, nil }