Skip to content

Commit

Permalink
enable test
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Oct 8, 2024
1 parent 71dc2a3 commit a6c5074
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions integration-tests/deployment/ccip/add_lane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,82 @@ package ccipdeployment

import (
"testing"
"time"

"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
"github.com/stretchr/testify/require"

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

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

// TestAddLane covers the workflow of adding a lane
// between existing supported chains in CCIP.
func TestAddLane(t *testing.T) {
// TODO: The offchain code doesn't yet support partial lane
// enablement, need to address then re-enable this test.
t.Skip()
e := NewMemoryEnvironmentWithJobs(t, logger.TestLogger(t), 3)
// Here we have CR + nodes set up, but no CCIP contracts deployed.
state, err := LoadOnchainState(e.Env, e.Ab)
require.NoError(t, err)
from, to := e.Env.AllChainSelectors()[0], e.Env.AllChainSelectors()[1]

// Set up CCIP contracts and a DON per chain.
err = DeployCCIPContracts(e.Env, e.Ab, DeployCCIPContractConfig{
HomeChainSel: e.HomeChainSel,
FeedChainSel: e.FeedChainSel,
TokenConfig: NewTokenConfig(),
MCMSConfig: NewTestMCMSConfig(t, e.Env),
FeeTokenContracts: e.FeeTokenContracts,
ChainsToDeploy: []uint64{from, to},
CapabilityRegistry: state.Chains[e.HomeChainSel].CapabilityRegistry.Address(),
})
require.NoError(t, err)

// We expect no lanes available on any chain.
state, err = LoadOnchainState(e.Env, e.Ab)
require.NoError(t, err)
for _, chain := range state.Chains {
for sel, chain := range state.Chains {
if sel != from && sel != to {
continue
}
offRamps, err := chain.Router.GetOffRamps(nil)
require.NoError(t, err)
require.Len(t, offRamps, 0)
}

replayBlocks, err := LatestBlocksByChain(testcontext.Get(t), e.Env.Chains)
require.NoError(t, err)
// Add one lane and send traffic.
from, to := e.Env.AllChainSelectors()[0], e.Env.AllChainSelectors()[1]
require.NoError(t, AddLane(e.Env, state, from, to))

require.NoError(t, AddLane(e.Env, state, to, from))
for sel, chain := range state.Chains {
if sel != from && sel != to {
continue
}
offRamps, err := chain.Router.GetOffRamps(nil)
require.NoError(t, err)
if sel == to {
require.Len(t, offRamps, 1)
} else {
require.Len(t, offRamps, 0)
// require.Len(t, offRamps, 0)
}
}
time.Sleep(30 * time.Second)
ReplayLogs(t, e.Env.Offchain, replayBlocks)

latesthdr, err := e.Env.Chains[to].Client.HeaderByNumber(testcontext.Get(t), nil)
require.NoError(t, err)
startBlock := latesthdr.Number.Uint64()
seqNum := SendRequest(t, e.Env, state, from, to, false)
require.Equal(t, uint64(1), seqNum)
require.NoError(t,
ConfirmCommitWithExpectedSeqNumRange(
t, e.Env.Chains[from], e.Env.Chains[to],
state.Chains[to].OffRamp, &startBlock,
ccipocr3.SeqNumRange{
ccipocr3.SeqNum(seqNum),
ccipocr3.SeqNum(seqNum),
}))
require.NoError(t, ConfirmExecWithSeqNr(t, e.Env.Chains[from], e.Env.Chains[to], state.Chains[to].OffRamp, &startBlock, seqNum))

// TODO: Add a second lane, then disable the first and
Expand Down

0 comments on commit a6c5074

Please sign in to comment.