From 33f604701e7189d5b5b31883769e56590bdbaf3e Mon Sep 17 00:00:00 2001 From: Mateusz Sekara Date: Mon, 18 Nov 2024 13:22:46 +0100 Subject: [PATCH] Post review fixes --- deployment/environment.go | 2 ++ .../ccip-tests/testsetups/test_helpers.go | 3 ++- integration-tests/smoke/ccip_usdc_test.go | 23 ++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/deployment/environment.go b/deployment/environment.go index 104db4c5c37..5d4e782b0fe 100644 --- a/deployment/environment.go +++ b/deployment/environment.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" chain_selectors "github.com/smartcontractkit/chain-selectors" + "github.com/smartcontractkit/chainlink-testing-framework/lib/docker/test_env" types2 "github.com/smartcontractkit/libocr/offchainreporting2/types" types3 "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "google.golang.org/grpc" @@ -75,6 +76,7 @@ type Environment struct { Chains map[uint64]Chain NodeIDs []string Offchain OffchainClient + MockAdapter *test_env.Killgrave } func NewEnvironment( diff --git a/integration-tests/ccip-tests/testsetups/test_helpers.go b/integration-tests/ccip-tests/testsetups/test_helpers.go index f1ce9742ff6..246584be7d5 100644 --- a/integration-tests/ccip-tests/testsetups/test_helpers.go +++ b/integration-tests/ccip-tests/testsetups/test_helpers.go @@ -105,10 +105,10 @@ func NewLocalDevEnvironment( testEnv, cfg) require.NoError(t, err) e, don, err := devenv.NewEnvironment(ctx, lggr, *envConfig) - require.NoError(t, err) require.NotNil(t, e) e.ExistingAddresses = ab + e.MockAdapter = testEnv.MockAdapter envNodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) require.NoError(t, err) @@ -301,6 +301,7 @@ func CreateDockerEnv(t *testing.T) ( builder := test_env.NewCLTestEnvBuilder(). WithTestConfig(&cfg). WithTestInstance(t). + WithMockAdapter(). WithJobDistributor(cfg.CCIP.JobDistributorConfig). WithStandardCleanup() diff --git a/integration-tests/smoke/ccip_usdc_test.go b/integration-tests/smoke/ccip_usdc_test.go index c6d831acc88..6c862b0c026 100644 --- a/integration-tests/smoke/ccip_usdc_test.go +++ b/integration-tests/smoke/ccip_usdc_test.go @@ -1,6 +1,8 @@ package smoke import ( + "github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/actions" + "github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/testsetups" "golang.org/x/exp/maps" "math/big" "net/http" @@ -30,7 +32,19 @@ import ( func TestUSDCTokenTransfer(t *testing.T) { lggr := logger.TestLogger(t) ctx := ccdeploy.Context(t) - tenv := ccdeploy.NewMemoryEnvironment(t, lggr, 2, 4, ccdeploy.MockLinkPrice, ccdeploy.MockWethPrice) + tenv, cluster, _ := testsetups.NewLocalDevEnvironmentWithDefaultPrice(t, lggr) + + var endpoint string + // When inmemory env then spin up in memory mock server + if cluster == nil { + server := mockAttestationResponse() + defer server.Close() + endpoint = server.URL + } else { + err := actions.SetMockServerWithUSDCAttestation(tenv.Env.MockAdapter, nil) + require.NoError(t, err) + endpoint = tenv.Env.MockAdapter.InternalEndpoint + } e := tenv.Env state, err := ccdeploy.LoadOnchainState(e) @@ -40,9 +54,6 @@ func TestUSDCTokenTransfer(t *testing.T) { sourceChain := allChainSelectors[0] destChain := allChainSelectors[1] - server := mockAttestationResponse() - defer server.Close() - feeds := state.Chains[tenv.FeedChainSel].USDFeeds tokenConfig := ccdeploy.NewTokenConfig() tokenConfig.UpsertTokenInfo(ccdeploy.LinkSymbol, @@ -70,7 +81,7 @@ func TestUSDCTokenTransfer(t *testing.T) { USDCConfig: ccdeploy.USDCConfig{ Enabled: true, USDCAttestationConfig: ccdeploy.USDCAttestationConfig{ - API: server.URL, + API: endpoint, APITimeout: commonconfig.MustNewDuration(time.Second), APIInterval: commonconfig.MustNewDuration(500 * time.Millisecond), }, @@ -216,7 +227,7 @@ func mintAndAllow( } } -// transferAndWaitForSuccess sends a message from sourceChain to destChain and waits for it to be executed (commited + executed) +// transferAndWaitForSuccess sends a message from sourceChain to destChain and waits for it to be executed func transferAndWaitForSuccess( t *testing.T, env deployment.Environment,