Skip to content

Commit

Permalink
integration-tests/smoke: move ccip msging test (#15217)
Browse files Browse the repository at this point in the history
* integration-tests/smoke: move ccip msging test

* fix imports

* add messaging test to matrix

* transform into docker based test
  • Loading branch information
makramkd authored Nov 13, 2024
1 parent 1a9f8cc commit bb04525
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 42 deletions.
16 changes: 15 additions & 1 deletion .github/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,20 @@ runner-test-matrix:
test_env_vars:
E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2
E2E_JD_VERSION: 0.4.0

- id: smoke/ccip_messaging_test.go:*
path: integration-tests/smoke/ccip_messaging_test.go
test_env_type: docker
runs_on: ubuntu-latest
triggers:
- PR E2E Core Tests
- Merge Queue E2E Core Tests
- Nightly E2E Tests
test_cmd: cd integration-tests/ && go test smoke/ccip_messaging_test.go -timeout 12m -test.parallel=1 -count=1 -json
pyroscope_env: ci-smoke-ccipv1_6-evm-simulated
test_env_vars:
E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2
E2E_JD_VERSION: 0.4.0

# END: CCIPv1.6 tests

Expand Down Expand Up @@ -1178,4 +1192,4 @@ runner-test-matrix:
TEST_LOG_LEVEL: debug
E2E_TEST_GRAFANA_DASHBOARD_URL: /d/6vjVx-1V8/ccip-long-running-tests

# END: CCIP tests
# END: CCIP tests
5 changes: 3 additions & 2 deletions deployment/ccip/add_lane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"

commonutils "github.com/smartcontractkit/chainlink-common/pkg/utils"
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

"github.com/smartcontractkit/chainlink/deployment"
Expand Down Expand Up @@ -119,7 +120,7 @@ func TestAddLane(t *testing.T) {
ExtraArgs: nil,
})
require.Equal(t, uint64(1), seqNum2)
require.NoError(t, ConfirmExecWithSeqNr(t, e.Env.Chains[chain2], e.Env.Chains[chain1], state.Chains[chain1].OffRamp, &startBlock2, seqNum2))
require.NoError(t, commonutils.JustError(ConfirmExecWithSeqNr(t, e.Env.Chains[chain2], e.Env.Chains[chain1], state.Chains[chain1].OffRamp, &startBlock2, seqNum2)))

// now check for the previous message from chain 1 to chain 2 that it has not been executed till now as the onRamp was disabled
ConfirmNoExecConsistentlyWithSeqNr(t, e.Env.Chains[chain1], e.Env.Chains[chain2], state.Chains[chain2].OffRamp, seqNum1, 30*time.Second)
Expand All @@ -145,5 +146,5 @@ func TestAddLane(t *testing.T) {
ReplayLogs(t, e.Env.Offchain, replayBlocks)
time.Sleep(30 * time.Second)
// Now that the onRamp is enabled, the request should be processed
require.NoError(t, ConfirmExecWithSeqNr(t, e.Env.Chains[chain1], e.Env.Chains[chain2], state.Chains[chain2].OffRamp, &startBlock, seqNum1))
require.NoError(t, commonutils.JustError(ConfirmExecWithSeqNr(t, e.Env.Chains[chain1], e.Env.Chains[chain2], state.Chains[chain2].OffRamp, &startBlock, seqNum1)))
}
3 changes: 2 additions & 1 deletion deployment/ccip/changeset/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/stretchr/testify/require"

cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
commonutils "github.com/smartcontractkit/chainlink-common/pkg/utils"

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

Expand Down Expand Up @@ -224,7 +225,7 @@ func TestAddChainInbound(t *testing.T) {
cciptypes.SeqNum(seqNr),
}))
require.NoError(t,
ccipdeployment.ConfirmExecWithSeqNr(t, e.Env.Chains[initialDeploy[0]], e.Env.Chains[newChain], state.Chains[newChain].OffRamp, &startBlock, seqNr))
commonutils.JustError(ccipdeployment.ConfirmExecWithSeqNr(t, e.Env.Chains[initialDeploy[0]], e.Env.Chains[newChain], state.Chains[newChain].OffRamp, &startBlock, seqNr)))

linkAddress := state.Chains[newChain].LinkToken.Address()
feeQuoter := state.Chains[newChain].FeeQuoter
Expand Down
55 changes: 46 additions & 9 deletions deployment/ccip/test_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math/big"
"sync"
"testing"
"time"

Expand All @@ -13,6 +14,7 @@ import (
"golang.org/x/sync/errgroup"

"github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"

"github.com/smartcontractkit/chainlink/deployment"
Expand Down Expand Up @@ -248,6 +250,26 @@ func ConfirmCommitWithExpectedSeqNumRange(
}
t.Logf("Waiting for commit report on chain selector %d from source selector %d expected seq nr range %s",
dest.Selector, src.Selector, expectedSeqNumRange.String())

// Need to do this because the subscription sometimes fails to get the event.
iter, err := offRamp.FilterCommitReportAccepted(&bind.FilterOpts{
Context: tests.Context(t),
})
require.NoError(t, err)
for iter.Next() {
event := iter.Event
if len(event.MerkleRoots) > 0 {
for _, mr := range event.MerkleRoots {
if mr.SourceChainSelector == src.Selector &&
uint64(expectedSeqNumRange.Start()) >= mr.MinSeqNr &&
uint64(expectedSeqNumRange.End()) <= mr.MaxSeqNr {
t.Logf("Received commit report for [%d, %d] on selector %d from source selector %d expected seq nr range %s, token prices: %v",
mr.MinSeqNr, mr.MaxSeqNr, dest.Selector, src.Selector, expectedSeqNumRange.String(), event.PriceUpdates.TokenPriceUpdates)
return nil
}
}
}
}
case subErr := <-subscription.Err():
return fmt.Errorf("subscription error: %w", subErr)
case <-timer.C:
Expand All @@ -272,6 +294,7 @@ func ConfirmCommitWithExpectedSeqNumRange(
}

// ConfirmExecWithSeqNrForAll waits for all chains in the environment to execute the given expectedSeqNums.
// If successful, it returns a map that maps the expected sequence numbers to their respective execution state.
// expectedSeqNums is a map of destination chain selector to expected sequence number
// startBlocks is a map of destination chain selector to start block number to start watching from.
// If startBlocks is nil, it will start watching from the latest block.
Expand All @@ -281,8 +304,12 @@ func ConfirmExecWithSeqNrForAll(
state CCIPOnChainState,
expectedSeqNums map[uint64]uint64,
startBlocks map[uint64]*uint64,
) {
var wg errgroup.Group
) (executionStates map[uint64]int) {
var (
wg errgroup.Group
mx sync.Mutex
)
executionStates = make(map[uint64]int)
for src, srcChain := range e.Chains {
for dest, dstChain := range e.Chains {
if src == dest {
Expand All @@ -300,18 +327,28 @@ func ConfirmExecWithSeqNrForAll(
return nil
}

return ConfirmExecWithSeqNr(
executionState, err := ConfirmExecWithSeqNr(
t,
srcChain,
dstChain,
state.Chains[dstChain.Selector].OffRamp,
startBlock,
expectedSeqNums[dstChain.Selector],
)
if err != nil {
return err
}

mx.Lock()
executionStates[expectedSeqNums[dstChain.Selector]] = executionState
mx.Unlock()

return nil
})
}
}
require.NoError(t, wg.Wait())
return executionStates
}

// ConfirmExecWithSeqNr waits for an execution state change on the destination chain with the expected sequence number.
Expand All @@ -323,7 +360,7 @@ func ConfirmExecWithSeqNr(
offRamp *offramp.OffRamp,
startBlock *uint64,
expectedSeqNr uint64,
) error {
) (executionState int, err error) {
timer := time.NewTimer(5 * time.Minute)
defer timer.Stop()
tick := time.NewTicker(5 * time.Second)
Expand All @@ -334,7 +371,7 @@ func ConfirmExecWithSeqNr(
Start: startBlock,
}, sink, nil, nil, nil)
if err != nil {
return fmt.Errorf("error to subscribe ExecutionStateChanged : %w", err)
return -1, fmt.Errorf("error to subscribe ExecutionStateChanged : %w", err)
}
defer subscription.Unsubscribe()
for {
Expand All @@ -346,21 +383,21 @@ func ConfirmExecWithSeqNr(
if executionState == EXECUTION_STATE_SUCCESS || executionState == EXECUTION_STATE_FAILURE {
t.Logf("Observed %s execution state on chain %d (offramp %s) from chain %d with expected sequence number %d",
executionStateToString(executionState), dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr)
return nil
return int(executionState), nil
}
case execEvent := <-sink:
t.Logf("Received ExecutionStateChanged (state %s) for seqNum %d on chain %d (offramp %s) from chain %d",
executionStateToString(execEvent.State), execEvent.SequenceNumber, dest.Selector, offRamp.Address().String(), source.Selector)
if execEvent.SequenceNumber == expectedSeqNr && execEvent.SourceChainSelector == source.Selector {
t.Logf("Received ExecutionStateChanged (state %s) on chain %d (offramp %s) from chain %d with expected sequence number %d",
executionStateToString(execEvent.State), dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr)
return nil
return int(execEvent.State), nil
}
case <-timer.C:
return fmt.Errorf("timed out waiting for ExecutionStateChanged on chain %d (offramp %s) from chain %d with expected sequence number %d",
return -1, fmt.Errorf("timed out waiting for ExecutionStateChanged on chain %d (offramp %s) from chain %d with expected sequence number %d",
dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr)
case subErr := <-subscription.Err():
return fmt.Errorf("subscription error: %w", subErr)
return -1, fmt.Errorf("subscription error: %w", subErr)
}
}
}
Expand Down
20 changes: 17 additions & 3 deletions deployment/ccip/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"
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
commonutils "github.com/smartcontractkit/chainlink-common/pkg/utils"
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/burn_mint_erc677"
Expand Down Expand Up @@ -287,7 +288,9 @@ func TestSendRequest(
return seqNum
}

func MakeExtraArgsV2(gasLimit uint64, allowOOO bool) []byte {
// MakeEVMExtraArgsV2 creates the extra args for the EVM2Any message that is destined
// for an EVM chain. The extra args contain the gas limit and allow out of order flag.
func MakeEVMExtraArgsV2(gasLimit uint64, allowOOO bool) []byte {
// extra args is the tag followed by the gas limit and allowOOO abi-encoded.
var extraArgs []byte
extraArgs = append(extraArgs, evmExtraArgsV2Tag...)
Expand Down Expand Up @@ -454,8 +457,19 @@ func ConfirmRequestOnSourceAndDest(t *testing.T, env deployment.Environment, sta
}))

fmt.Printf("Commit confirmed for seqnr %d", seqNum)
require.NoError(t,
ConfirmExecWithSeqNr(t, env.Chains[sourceCS], env.Chains[destCS], state.Chains[destCS].OffRamp, &startBlock, seqNum))
require.NoError(
t,
commonutils.JustError(
ConfirmExecWithSeqNr(
t,
env.Chains[sourceCS],
env.Chains[destCS],
state.Chains[destCS].OffRamp,
&startBlock,
seqNum,
),
),
)

return nil
}
Expand Down
Loading

0 comments on commit bb04525

Please sign in to comment.