Skip to content
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/v1_6_0/onramp"
)

// Use this when testhelpers.DeployedEnv is available (usually in ephemeral test environments).
func NewTestSetupWithDeployedEnv(
// Expects WithDeployedEnv for ephemeral test environments or WithEnv for long-running test environments like staging.
func NewTestSetup(
t *testing.T,
depEnv testhelpers.DeployedEnv,
onchainState changeset.CCIPOnChainState,
sourceChain,
destChain uint64,
srctoken common.Address,
srcFeeQuoterDestChainConfig fee_quoter.FeeQuoterDestChainConfig,
testRouter,
validateResp bool,
opts ...TestSetupOpts,
) TestSetup {
return TestSetup{
ts := TestSetup{
T: t,
Env: depEnv.Env,
DeployedEnv: &depEnv,
OnchainState: onchainState,
SrcChain: sourceChain,
DestChain: destChain,
Expand All @@ -38,31 +36,26 @@ func NewTestSetupWithDeployedEnv(
TestRouter: testRouter,
ValidateResp: validateResp,
}

for _, opt := range opts {
opt(&ts)
}

return ts
}

// Use this when testhelpers.DeployedEnv is not available (usually in long-running test environments like staging).
func NewTestSetup(
t *testing.T,
env deployment.Environment,
onchainState changeset.CCIPOnChainState,
sourceChain,
destChain uint64,
srctoken common.Address,
srcFeeQuoterDestChainConfig fee_quoter.FeeQuoterDestChainConfig,
testRouter,
validateResp bool,
) TestSetup {
return TestSetup{
T: t,
Env: env,
// no DeployedEnv
OnchainState: onchainState,
SrcChain: sourceChain,
DestChain: destChain,
SrcToken: srctoken,
SrcFeeQuoterDestChainConfig: srcFeeQuoterDestChainConfig,
TestRouter: testRouter,
ValidateResp: validateResp,
type TestSetupOpts func(*TestSetup)

func WithDeployedEnv(de testhelpers.DeployedEnv) TestSetupOpts {
return func(ts *TestSetup) {
ts.DeployedEnv = &de
ts.Env = de.Env
}
}

func WithEnv(env deployment.Environment) TestSetupOpts {
return func(ts *TestSetup) {
ts.Env = env
}
}

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/smoke/ccip/ccip_message_limitations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ func Test_CCIPMessageLimitations(t *testing.T) {
require.NoError(t, err)
t.Logf("0->1 destination config: %+v", chain0DestConfig)

testSetup := mlt.NewTestSetupWithDeployedEnv(
testSetup := mlt.NewTestSetup(
t,
testEnv,
onChainState,
chains[0],
chains[1],
srcToken.Address(),
chain0DestConfig,
false, // testRouter
true, // validateResp
mlt.WithDeployedEnv(testEnv),
)

tcs := []mlt.TestCase{
Expand Down

0 comments on commit 78dc296

Please sign in to comment.