Skip to content

Commit

Permalink
Send request before disabling the lane
Browse files Browse the repository at this point in the history
  • Loading branch information
b-gopalswami committed Jan 24, 2025
1 parent bbc49ec commit 0824a15
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 64 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
GETH_VERSION: 1.14.11
workflow_registry_wrapper: ../../../contracts/solc/v0.8.24/WorkflowRegistry/WorkflowRegistry.abi ../../../contracts/solc/v0.8.24/WorkflowRegistry/WorkflowRegistry.bin 88356c4673d32f7d17b5e418d411a418a24ac972e6ec9cb740d8b731d6b9916a
workflow_registry_wrapper: ../../../contracts/solc/v0.8.24/WorkflowRegistry/WorkflowRegistry.abi ../../../contracts/solc/v0.8.24/WorkflowRegistry/WorkflowRegistry.bin bad48df0196c8a170a8e5486d0334183defd60e74bd89d3885989e00d6f13d23
3 changes: 1 addition & 2 deletions deployment/ccip/changeset/testhelpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,7 @@ func UpdateLane(
t *testing.T,
e *DeployedEnv,
from, to uint64,
isTestRouter bool,
isEnabled bool,
isTestRouter, isEnabled bool,
) {
var err error
var apps []commoncs.ChangesetApplication
Expand Down
136 changes: 77 additions & 59 deletions integration-tests/smoke/ccip/ccip_update_lane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ package ccip
import (
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"

"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers"
testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
)

// Intention of this test is to ensure that the lane can be disabled and enabled correctly without disrupting the other lanes.
func TestDisableLane(t *testing.T) {
tenv, _, _ := testsetups.NewIntegrationEnvironment(t,
testhelpers.WithNumOfChains(3),
testhelpers.WithNumOfUsersPerChain(2),
)

e := tenv.Env
Expand All @@ -26,72 +30,86 @@ func TestDisableLane(t *testing.T) {
// Add all lanes
testhelpers.AddLanesForAll(t, &tenv, state)

chains := e.AllChainSelectors()
chainA, chainB, chainC := chains[0], chains[1], chains[2]
var (
chains = e.AllChainSelectors()
chainA, chainB, chainC = chains[0], chains[1], chains[2]
expectedSeqNumExec = make(map[testhelpers.SourceDestPair][]uint64)
startBlocks = make(map[uint64]*uint64)
pairs = testsetups.GetSourceDestPairs([]uint64{chainA, chainB, chainC})

assertSendRequestReverted := func(src, dest uint64) {
_, err = testhelpers.DoSendRequest(
t,
e,
state,
testhelpers.WithSender(e.Chains[src].DeployerKey),
testhelpers.WithSourceChain(src),
testhelpers.WithDestChain(dest),
testhelpers.WithTestRouter(false),
testhelpers.WithEvm2AnyMessage(router.ClientEVM2AnyMessage{
Receiver: common.LeftPadBytes(state.Chains[chainB].Receiver.Address().Bytes(), 32),
Data: []byte("hello"),
TokenAmounts: nil,
FeeToken: common.HexToAddress("0x0"),
ExtraArgs: nil,
}))
require.Error(t, err)
require.Contains(t, err.Error(), "execution reverted")
}
sendmessage = func(src, dest uint64, deployer *bind.TransactOpts) (*onramp.OnRampCCIPMessageSent, error) {
return testhelpers.DoSendRequest(
t,
e,
state,
testhelpers.WithSender(deployer),
testhelpers.WithSourceChain(src),
testhelpers.WithDestChain(dest),
testhelpers.WithTestRouter(false),
testhelpers.WithEvm2AnyMessage(router.ClientEVM2AnyMessage{
Receiver: common.LeftPadBytes(state.Chains[chainB].Receiver.Address().Bytes(), 32),
Data: []byte("hello"),
TokenAmounts: nil,
FeeToken: common.HexToAddress("0x0"),
ExtraArgs: nil,
}))

expectedSeqNumExec := make(map[testhelpers.SourceDestPair][]uint64)
startBlocks := make(map[uint64]*uint64)
assertRequestSent := func(src, dest uint64) {
latestHeader, err := e.Chains[dest].Client.HeaderByNumber(testcontext.Get(t), nil)
require.NoError(t, err)
block := latestHeader.Number.Uint64()
msgSentEvent := testhelpers.TestSendRequest(t, e, state, src, dest, false, router.ClientEVM2AnyMessage{
Receiver: common.LeftPadBytes(state.Chains[dest].Receiver.Address().Bytes(), 32),
Data: []byte("hello"),
TokenAmounts: nil,
FeeToken: common.HexToAddress("0x0"),
ExtraArgs: nil,
})
expectedSeqNumExec[testhelpers.SourceDestPair{
SourceChainSelector: src,
DestChainSelector: dest,
}] = []uint64{msgSentEvent.SequenceNumber}
startBlocks[dest] = &block
}
}

Check failure on line 57 in integration-tests/smoke/ccip/ccip_update_lane_test.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (integration-tests)

unnecessary trailing newline (whitespace)

assertSendRequestReverted = func(src, dest uint64, deployer *bind.TransactOpts) {
_, err = sendmessage(src, dest, deployer)
require.Error(t, err)
require.Contains(t, err.Error(), "execution reverted")
}

assertRequestSent = func(src, dest uint64, deployer *bind.TransactOpts) {
latestHeader, err := e.Chains[dest].Client.HeaderByNumber(testcontext.Get(t), nil)
require.NoError(t, err)
block := latestHeader.Number.Uint64()
messageSentEvent, err := sendmessage(src, dest, e.Chains[src].DeployerKey)
require.NoError(t, err)
expectedSeqNumExec[testhelpers.SourceDestPair{
SourceChainSelector: src,
DestChainSelector: dest,
}] = []uint64{messageSentEvent.SequenceNumber}
startBlocks[dest] = &block
}
)

// Disable specific lane A -> B
// Disable lane A -> B
testhelpers.UpdateLane(t, &tenv, chainA, chainB, false, false)
// send a transaction to confirm it is reverted between chainA and chainB
assertSendRequestReverted(chainA, chainB)
assertRequestSent(chainB, chainA)
// Disable B -> A
// send a message to confirm it is reverted between chainA and chainB
assertSendRequestReverted(chainA, chainB, e.Chains[chainA].Users[0])
// send a message between chainB and chainA to confirm it is not reverted
assertRequestSent(chainB, chainA, e.Chains[chainB].Users[0])
// Disable lane B -> A
testhelpers.UpdateLane(t, &tenv, chainB, chainA, false, false)
assertSendRequestReverted(chainB, chainA)
assertSendRequestReverted(chainB, chainA, e.Chains[chainB].Users[0])

// send transactions in other lanes and ensure they are delivered
assertRequestSent(chainA, chainC)
assertRequestSent(chainC, chainA)
assertRequestSent(chainB, chainC)
assertRequestSent(chainC, chainB)

// re-enable the lanes A -> B and B -> A
testhelpers.UpdateLane(t, &tenv, chainA, chainB, false, true)
testhelpers.UpdateLane(t, &tenv, chainB, chainA, false, true)
// send a transaction in all the lane including re-enabled lanes
pairs := testsetups.GetSourceDestPairs([]uint64{chainA, chainB, chainC})
// send message in other lanes and ensure they are delivered
go func() {
assertRequestSent(chainA, chainC, e.Chains[chainA].Users[1])
assertRequestSent(chainC, chainA, e.Chains[chainC].Users[1])
assertRequestSent(chainB, chainC, e.Chains[chainB].Users[1])
assertRequestSent(chainC, chainB, e.Chains[chainC].Users[1])
}()
// Disable lanes between A & C and C & B while requests are getting sent
testhelpers.UpdateLane(t, &tenv, chainA, chainC, false, false)
testhelpers.UpdateLane(t, &tenv, chainC, chainA, false, false)
testhelpers.UpdateLane(t, &tenv, chainB, chainC, false, false)
testhelpers.UpdateLane(t, &tenv, chainC, chainB, false, false)
// Confirm that message sent in all lanes are reverted after disabling the lanes
for _, pair := range pairs {
assertSendRequestReverted(pair.SourceChainSelector, pair.DestChainSelector, e.Chains[pair.SourceChainSelector].Users[0])
}
// re-enable all the lanes
for _, pair := range pairs {
testhelpers.UpdateLane(t, &tenv, pair.SourceChainSelector, pair.DestChainSelector, false, true)
}
//send a message in all the lane including re-enabled lanes

Check failure on line 109 in integration-tests/smoke/ccip/ccip_update_lane_test.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (integration-tests)

commentFormatting: put a space between `//` and comment text (gocritic)
for _, pair := range pairs {
assertRequestSent(pair.SourceChainSelector, pair.DestChainSelector)
assertRequestSent(pair.SourceChainSelector, pair.DestChainSelector, e.Chains[pair.SourceChainSelector].Users[0])
}
// Confirm all exec reports
//Confirm all messages are delivered

Check failure on line 113 in integration-tests/smoke/ccip/ccip_update_lane_test.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (integration-tests)

commentFormatting: put a space between `//` and comment text (gocritic)
testhelpers.ConfirmExecWithSeqNrsForAll(t, e, state, expectedSeqNumExec, startBlocks)
}

0 comments on commit 0824a15

Please sign in to comment.