Skip to content

Commit

Permalink
Add context.Context to deployment.Environment. Plumb this through in …
Browse files Browse the repository at this point in the history
…the test environment and devenv also. Mostly the ctx was already present for other reasons, but now we expose it through the environment for attaching to remote-calls that aren't already managed by a wrapper client.
  • Loading branch information
cgruber committed Nov 25, 2024
1 parent 73788c6 commit bb2a98e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion deployment/ccip/changeset/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/pkg/errors"
"github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers"

"github.com/smartcontractkit/chainlink-ccip/pluginconfig"

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
Expand Down Expand Up @@ -200,7 +201,7 @@ func NewMemoryEnvironment(
require.NoError(t, node.App.Stop())
})
}
e := memory.NewMemoryEnvironmentFromChainsNodes(t, lggr, chains, nodes)
e := memory.NewMemoryEnvironmentFromChainsNodes(lggr, ctx, chains, nodes)
envNodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain)
require.NoError(t, err)
e.ExistingAddresses = ab
Expand Down
3 changes: 3 additions & 0 deletions deployment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type Environment struct {
Chains map[uint64]Chain
NodeIDs []string
Offchain OffchainClient
Context context.Context
}

func NewEnvironment(
Expand All @@ -85,6 +86,7 @@ func NewEnvironment(
chains map[uint64]Chain,
nodeIDs []string,
offchain OffchainClient,
context context.Context,
) *Environment {
return &Environment{
Name: name,
Expand All @@ -93,6 +95,7 @@ func NewEnvironment(
Chains: chains,
NodeIDs: nodeIDs,
Offchain: offchain,
Context: context,
}
}

Expand Down
1 change: 1 addition & 0 deletions deployment/environment/devenv/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ func NewEnvironment(ctx context.Context, lggr logger.Logger, config EnvironmentC
chains,
nodeIDs,
offChain,
ctx,
), jd.don, nil
}
8 changes: 6 additions & 2 deletions deployment/environment/memory/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ func NewNodes(t *testing.T, logLevel zapcore.Level, chains map[uint64]deployment
return nodesByPeerID
}

func NewMemoryEnvironmentFromChainsNodes(t *testing.T,
func NewMemoryEnvironmentFromChainsNodes(
lggr logger.Logger,
ctx context.Context,
chains map[uint64]deployment.Chain,
nodes map[string]Node) deployment.Environment {
nodes map[string]Node,
) deployment.Environment {
var nodeIDs []string
for id := range nodes {
nodeIDs = append(nodeIDs, id)
Expand All @@ -125,6 +127,7 @@ func NewMemoryEnvironmentFromChainsNodes(t *testing.T,
chains,
nodeIDs, // Note these have the p2p_ prefix.
NewMemoryJobClient(nodes),
ctx,
)
}

Expand All @@ -143,5 +146,6 @@ func NewMemoryEnvironment(t *testing.T, lggr logger.Logger, logLevel zapcore.Lev
chains,
nodeIDs,
NewMemoryJobClient(nodes),
context.Background(),
)
}
6 changes: 4 additions & 2 deletions deployment/keystone/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
chainsel "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"
"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/environment/clo"
"github.com/smartcontractkit/chainlink/deployment/environment/clo/models"
Expand All @@ -26,6 +28,7 @@ import (

func TestDeploy(t *testing.T) {
lggr := logger.Test(t)
ctx := testcontext.Get(t)

// sepolia; all nodes are on the this chain
sepoliaChainId := uint64(11155111)
Expand Down Expand Up @@ -100,7 +103,7 @@ func TestDeploy(t *testing.T) {
maps.Copy(allNodes, wfNodes)
maps.Copy(allNodes, cwNodes)
maps.Copy(allNodes, assetNodes)
env := memory.NewMemoryEnvironmentFromChainsNodes(t, lggr, allChains, allNodes)
env := memory.NewMemoryEnvironmentFromChainsNodes(lggr, ctx, allChains, allNodes)

var ocr3Config = keystone.OracleConfigWithSecrets{
OracleConfig: keystone.OracleConfig{
Expand All @@ -109,7 +112,6 @@ func TestDeploy(t *testing.T) {
OCRSecrets: deployment.XXXGenerateTestOCRSecrets(),
}

ctx := tests.Context(t)
// explicitly deploy the contracts
cs, err := keystone.DeployContracts(lggr, &env, sepoliaChainSel)
require.NoError(t, err)
Expand Down

0 comments on commit bb2a98e

Please sign in to comment.