Skip to content

Commit

Permalink
Ccip-4333 Handle all test setups with unified interface for memory an…
Browse files Browse the repository at this point in the history
…d docker tests (#15581)

* updates

* use common ones

* update test

* go mod

* fix rmn test

* fix test

* fix again

* fix test

* more fix

* comment override

* review comments

* fix

* updates
  • Loading branch information
AnieeG authored Dec 10, 2024
1 parent 06943ff commit 9d8d9f4
Show file tree
Hide file tree
Showing 29 changed files with 681 additions and 666 deletions.
11 changes: 11 additions & 0 deletions .github/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ runner-test-matrix:
test_env_vars:
E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2
E2E_JD_VERSION: 0.6.0
CCIP_V16_TEST_ENV: docker

- id: smoke/ccip/ccip_token_price_updates_test.go:*
path: integration-tests/smoke/ccip/ccip_token_price_updates_test.go
Expand All @@ -960,6 +961,7 @@ runner-test-matrix:
test_env_vars:
E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2
E2E_JD_VERSION: 0.6.0
CCIP_V16_TEST_ENV: docker

- id: smoke/ccip/ccip_gas_price_updates_test.go:*
path: integration-tests/smoke/ccip/ccip_gas_price_updates_test.go
Expand All @@ -973,6 +975,7 @@ runner-test-matrix:
test_env_vars:
E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2
E2E_JD_VERSION: 0.6.0
CCIP_V16_TEST_ENV: docker

- id: smoke/ccip/ccip_rmn_test.go:^TestRMN_TwoMessagesOnTwoLanesIncludingBatching$
path: integration-tests/smoke/ccip/ccip_rmn_test.go
Expand All @@ -988,6 +991,7 @@ runner-test-matrix:
E2E_JD_VERSION: 0.6.0
E2E_RMN_RAGEPROXY_VERSION: master-f461a9e
E2E_RMN_AFN2PROXY_VERSION: master-f461a9e
CCIP_V16_TEST_ENV: docker

- id: smoke/ccip/ccip_rmn_test.go:^TestRMN_MultipleMessagesOnOneLaneNoWaitForExec$
path: integration-tests/smoke/ccip/ccip_rmn_test.go
Expand All @@ -1003,6 +1007,7 @@ runner-test-matrix:
E2E_JD_VERSION: 0.6.0
E2E_RMN_RAGEPROXY_VERSION: master-f461a9e
E2E_RMN_AFN2PROXY_VERSION: master-f461a9e
CCIP_V16_TEST_ENV: docker

- id: smoke/ccip/ccip_rmn_test.go:^TestRMN_NotEnoughObservers$
path: integration-tests/smoke/ccip/ccip_rmn_test.go
Expand All @@ -1018,6 +1023,7 @@ runner-test-matrix:
E2E_JD_VERSION: 0.6.0
E2E_RMN_RAGEPROXY_VERSION: master-f461a9e
E2E_RMN_AFN2PROXY_VERSION: master-f461a9e
CCIP_V16_TEST_ENV: docker

- id: smoke/ccip/ccip_rmn_test.go:^TestRMN_DifferentSigners$
path: integration-tests/smoke/ccip/ccip_rmn_test.go
Expand All @@ -1033,6 +1039,7 @@ runner-test-matrix:
E2E_JD_VERSION: 0.6.0
E2E_RMN_RAGEPROXY_VERSION: master-f461a9e
E2E_RMN_AFN2PROXY_VERSION: master-f461a9e
CCIP_V16_TEST_ENV: docker

- id: smoke/ccip/ccip_rmn_test.go:^TestRMN_NotEnoughSigners$
path: integration-tests/smoke/ccip/ccip_rmn_test.go
Expand All @@ -1048,6 +1055,7 @@ runner-test-matrix:
E2E_JD_VERSION: 0.6.0
E2E_RMN_RAGEPROXY_VERSION: master-f461a9e
E2E_RMN_AFN2PROXY_VERSION: master-f461a9e
CCIP_V16_TEST_ENV: docker

- id: smoke/ccip/ccip_rmn_test.go:^TestRMN_DifferentRmnNodesForDifferentChains$
path: integration-tests/smoke/ccip/ccip_rmn_test.go
Expand All @@ -1063,6 +1071,7 @@ runner-test-matrix:
E2E_JD_VERSION: 0.6.0
E2E_RMN_RAGEPROXY_VERSION: master-f461a9e
E2E_RMN_AFN2PROXY_VERSION: master-f461a9e
CCIP_V16_TEST_ENV: docker

- id: smoke/ccip/ccip_rmn_test.go:^TestRMN_TwoMessagesOneSourceChainCursed$
path: integration-tests/smoke/ccip/ccip_rmn_test.go
Expand All @@ -1078,6 +1087,7 @@ runner-test-matrix:
E2E_JD_VERSION: 0.6.0
E2E_RMN_RAGEPROXY_VERSION: master-f461a9e
E2E_RMN_AFN2PROXY_VERSION: master-f461a9e
CCIP_V16_TEST_ENV: docker

- id: smoke/ccip/ccip_rmn_test.go:^TestRMN_GlobalCurseTwoMessagesOnTwoLanes$
path: integration-tests/smoke/ccip/ccip_rmn_test.go
Expand All @@ -1093,6 +1103,7 @@ runner-test-matrix:
E2E_JD_VERSION: 0.6.0
E2E_RMN_RAGEPROXY_VERSION: master-f461a9e
E2E_RMN_AFN2PROXY_VERSION: master-f461a9e
CCIP_V16_TEST_ENV: docker

# END: CCIPv1.6 tests

Expand Down
12 changes: 2 additions & 10 deletions deployment/ccip/changeset/accept_ownership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,14 @@ import (

"github.com/ethereum/go-ethereum/common"

commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"

"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"

"github.com/smartcontractkit/chainlink/v2/core/logger"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
)

func Test_NewAcceptOwnershipChangeset(t *testing.T) {
e := NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 2,
NumOfUsersPerChain: 1,
Nodes: 4,
Bootstraps: 1,
}, &TestConfigs{})
e := NewMemoryEnvironment(t)
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)

Expand Down
13 changes: 3 additions & 10 deletions deployment/ccip/changeset/cs_active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"

Expand All @@ -22,20 +21,14 @@ import (

commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
"github.com/smartcontractkit/chainlink/deployment/common/proposalutils"

"github.com/smartcontractkit/chainlink/v2/core/logger"
)

func TestActiveCandidate(t *testing.T) {
t.Skipf("to be enabled after latest cl-ccip is compatible")

lggr := logger.TestLogger(t)
tenv := NewMemoryEnvironmentWithJobsAndContracts(t, lggr, memory.MemoryEnvironmentConfig{
Chains: 3,
NumOfUsersPerChain: 1,
Nodes: 5,
Bootstraps: 1,
}, nil)
tenv := NewMemoryEnvironment(t,
WithChains(3),
WithNodes(5))
e := tenv.Env
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)
Expand Down
11 changes: 4 additions & 7 deletions deployment/ccip/changeset/cs_add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
commontypes "github.com/smartcontractkit/chainlink/deployment/common/types"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -32,12 +31,10 @@ import (

func TestAddChainInbound(t *testing.T) {
// 4 chains where the 4th is added after initial deployment.
e := NewMemoryEnvironmentWithJobs(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 4,
NumOfUsersPerChain: 1,
Nodes: 4,
Bootstraps: 1,
})
e := NewMemoryEnvironment(t,
WithChains(4),
WithJobsOnly(),
)
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
// Take first non-home chain as the new chain.
Expand Down
14 changes: 2 additions & 12 deletions deployment/ccip/changeset/cs_add_lane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)

func TestAddLanesWithTestRouter(t *testing.T) {
e := NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 2,
Nodes: 4,
Bootstraps: 1,
}, nil)
e := NewMemoryEnvironment(t)
// Here we have CR + nodes set up, but no CCIP contracts deployed.
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
Expand Down Expand Up @@ -72,11 +66,7 @@ func TestAddLane(t *testing.T) {

t.Parallel()
// We add more chains to the chainlink nodes than the number of chains where CCIP is deployed.
e := NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 2,
Nodes: 4,
Bootstraps: 1,
}, nil)
e := NewMemoryEnvironment(t)
// Here we have CR + nodes set up, but no CCIP contracts deployed.
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
Expand Down
7 changes: 1 addition & 6 deletions deployment/ccip/changeset/cs_deploy_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,7 @@ func TestDeployChainContractsChangeset(t *testing.T) {
}

func TestDeployCCIPContracts(t *testing.T) {
lggr := logger.TestLogger(t)
e := NewMemoryEnvironmentWithJobsAndContracts(t, lggr, memory.MemoryEnvironmentConfig{
Chains: 2,
Nodes: 4,
Bootstraps: 1,
}, nil)
e := NewMemoryEnvironment(t)
// Deploy all the CCIP contracts.
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
Expand Down
11 changes: 11 additions & 0 deletions deployment/ccip/changeset/cs_initial_add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/imdario/mergo"
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock"

"github.com/smartcontractkit/chainlink-ccip/chainconfig"
Expand Down Expand Up @@ -59,6 +60,16 @@ type CCIPOCRParams struct {
ExecuteOffChainConfig pluginconfig.ExecuteOffchainConfig
}

// Override overrides non-empty dst CCIPOCRParams attributes with non-empty src CCIPOCRParams attributes values
// and returns the updated CCIPOCRParams.
func (c CCIPOCRParams) Override(overrides CCIPOCRParams) (CCIPOCRParams, error) {
err := mergo.Merge(&c, &overrides, mergo.WithOverride)
if err != nil {
return CCIPOCRParams{}, err
}
return c, nil
}

func (c CCIPOCRParams) Validate() error {
if err := c.OCRParameters.Validate(); err != nil {
return fmt.Errorf("invalid OCR parameters: %w", err)
Expand Down
30 changes: 30 additions & 0 deletions deployment/ccip/changeset/cs_initial_add_chain_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package changeset

import (
"testing"
"time"

chainselectors "github.com/smartcontractkit/chain-selectors"
"github.com/smartcontractkit/chainlink-ccip/pluginconfig"
"github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/stretchr/testify/require"
)

func TestOverrideCCIPParams(t *testing.T) {
params := DefaultOCRParams(chainselectors.ETHEREUM_TESTNET_SEPOLIA.Selector, nil, nil)
overrides := CCIPOCRParams{
ExecuteOffChainConfig: pluginconfig.ExecuteOffchainConfig{
RelativeBoostPerWaitHour: 10,
},
CommitOffChainConfig: pluginconfig.CommitOffchainConfig{
TokenPriceBatchWriteFrequency: *config.MustNewDuration(1_000_000 * time.Hour),
RemoteGasPriceBatchWriteFrequency: *config.MustNewDuration(1_000_000 * time.Hour),
},
}
newParams, err := params.Override(overrides)
require.NoError(t, err)
require.Equal(t, overrides.ExecuteOffChainConfig.RelativeBoostPerWaitHour, newParams.ExecuteOffChainConfig.RelativeBoostPerWaitHour)
require.Equal(t, overrides.CommitOffChainConfig.TokenPriceBatchWriteFrequency, newParams.CommitOffChainConfig.TokenPriceBatchWriteFrequency)
require.Equal(t, overrides.CommitOffChainConfig.RemoteGasPriceBatchWriteFrequency, newParams.CommitOffChainConfig.RemoteGasPriceBatchWriteFrequency)
require.Equal(t, params.OCRParameters, newParams.OCRParameters)
}
8 changes: 1 addition & 7 deletions deployment/ccip/changeset/cs_update_rmn_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import (

"github.com/smartcontractkit/chainlink/deployment"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_home"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_remote"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)

type updateRMNConfigTestCase struct {
Expand Down Expand Up @@ -40,11 +38,7 @@ func TestUpdateRMNConfig(t *testing.T) {
}

func updateRMNConfig(t *testing.T, tc updateRMNConfigTestCase) {
e := NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 2,
Nodes: 4,
Bootstraps: 1,
}, nil)
e := NewMemoryEnvironment(t)

state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
Expand Down
11 changes: 1 addition & 10 deletions deployment/ccip/changeset/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,10 @@ import (
"testing"

"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)

func TestSmokeState(t *testing.T) {
lggr := logger.TestLogger(t)
tenv := NewMemoryEnvironmentWithJobsAndContracts(t, lggr, memory.MemoryEnvironmentConfig{
Chains: 3,
Nodes: 4,
Bootstraps: 1,
NumOfUsersPerChain: 1,
}, nil)
tenv := NewMemoryEnvironment(t, WithChains(3))
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)
_, err = state.View(tenv.Env.AllChainSelectors())
Expand Down
3 changes: 2 additions & 1 deletion deployment/ccip/changeset/test_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
commonutils "github.com/smartcontractkit/chainlink-common/pkg/utils"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"

"github.com/smartcontractkit/chainlink/deployment/environment/memory"

"github.com/smartcontractkit/chainlink/deployment"
Expand Down Expand Up @@ -598,7 +599,7 @@ func RequireConsistently(t *testing.T, condition func() bool, duration time.Dura
}
}

func SeqNumberRageToSlice(seqRanges map[SourceDestPair]ccipocr3.SeqNumRange) map[SourceDestPair][]uint64 {
func SeqNumberRangeToSlice(seqRanges map[SourceDestPair]ccipocr3.SeqNumRange) map[SourceDestPair][]uint64 {
flatten := make(map[SourceDestPair][]uint64)

for srcDst, seqRange := range seqRanges {
Expand Down
Loading

0 comments on commit 9d8d9f4

Please sign in to comment.