Skip to content

Commit

Permalink
Add reorg test to the pipeline and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
b-gopalswami committed Sep 10, 2024
1 parent ff5a321 commit 6c0a5e1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
38 changes: 37 additions & 1 deletion .github/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,43 @@ runner-test-matrix:
- Nightly E2E Tests
test_cmd: cd integration-tests/ccip-tests/smoke && go test ccip_test.go -test.run ^TestSmokeCCIPOffRampAggRateLimit$ -timeout 30m -count=1 -test.parallel=1 -json
test_env_vars:
E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2
E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2

- id: ccip-tests/smoke/ccip_test.go:^TestSmokeCCIPReorgBelowFinality$
path: integration-tests/ccip-tests/smoke/ccip_test.go
test_env_type: docker
runs_on: ubuntu-latest
workflows:
- PR E2E CCIP Tests
- Nightly E2E Tests
test_cmd: cd integration-tests/ccip-tests/smoke && go test ccip_test.go -test.run ^TestSmokeCCIPReorgBelowFinality$ -timeout 30m -count=1 -test.parallel=1 -json
test_env_vars:
E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2
test_config_override_path: integration-tests/ccip-tests/testconfig/tomls/ccip-reorg.toml

- id: ccip-tests/smoke/ccip_test.go:^TestSmokeCCIPReorgAboveFinalityAtDestination$
path: integration-tests/ccip-tests/smoke/ccip_test.go
test_env_type: docker
runs_on: ubuntu-latest
workflows:
- PR E2E CCIP Tests
- Nightly E2E Tests
test_cmd: cd integration-tests/ccip-tests/smoke && go test ccip_test.go -test.run ^TestSmokeCCIPReorgAboveFinalityAtDestination$ -timeout 30m -count=1 -test.parallel=1 -json
test_env_vars:
E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2
test_config_override_path: integration-tests/ccip-tests/testconfig/tomls/ccip-reorg.toml

- id: ccip-tests/smoke/ccip_test.go:^TestSmokeCCIPReorgAboveFinalityAtSource$
path: integration-tests/ccip-tests/smoke/ccip_test.go
test_env_type: docker
runs_on: ubuntu-latest
workflows:
- PR E2E CCIP Tests
- Nightly E2E Tests
test_cmd: cd integration-tests/ccip-tests/smoke && go test ccip_test.go -test.run ^TestSmokeCCIPReorgAboveFinalityAtSource$ -timeout 30m -count=1 -test.parallel=1 -json
test_env_vars:
E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2
test_config_override_path: integration-tests/ccip-tests/testconfig/tomls/ccip-reorg.toml

- id: ccip-tests/chaos/ccip_test.go
path: integration-tests/ccip-tests/chaos/ccip_test.go
Expand Down
13 changes: 12 additions & 1 deletion core/services/ocr2/plugins/ccip/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip"
"math"
"math/big"
"sync"
"testing"
Expand Down Expand Up @@ -686,7 +687,10 @@ func TestReorg(t *testing.T) {
require.NoError(t, ccipTH.Dest.Chain.Fork(testutils.Context(t), forkBlock.Hash()),
"Error while forking the chain")
// Make sure that fork is longer than the canonical chain to enforce switch
noOfBlocks := int(currentBlock.NumberU64() - forkBlock.NumberU64())
noOfBlocks, err := safeIntConversion(currentBlock.NumberU64() - forkBlock.NumberU64())
if err != nil {
t.Fatalf("Error while finding number of blocks: %v", err)
}
for i := 0; i < noOfBlocks+1; i++ {
ccipTH.Dest.Chain.Commit()
}
Expand All @@ -707,3 +711,10 @@ func TestReorg(t *testing.T) {
executionLog = ccipTH.AllNodesHaveExecutedSeqNums(t, 1, 2)
ccipTH.AssertExecState(t, executionLog[0], testhelpers.ExecutionStateSuccess)
}

func safeIntConversion(n uint64) (int, error) {
if n > math.MaxInt {
return 0, fmt.Errorf("%d overflows int64", n)
}
return int(n), nil

Check failure on line 719 in core/services/ocr2/plugins/ccip/integration_test.go

View workflow job for this annotation

GitHub Actions / lint

G115: integer overflow conversion uint64 -> int (gosec)
}
Original file line number Diff line number Diff line change
Expand Up @@ -527,20 +527,20 @@ func setupNodeCCIP(
return app, peerID.Raw(), transmitter, kb
}

func createConfigV2Chain(chainId *big.Int, finalityDepth uint32) *v2.EVMConfig {
func createConfigV2Chain(chainID *big.Int, finalityDepth uint32) *v2.EVMConfig {
// NOTE: For the executor jobs, the default of 500k is insufficient for a 3 message batch
defaultGasLimit := uint64(5000000)
tr := true

sourceC := v2.Defaults((*evmUtils.Big)(chainId))
sourceC := v2.Defaults((*evmUtils.Big)(chainID))
sourceC.GasEstimator.LimitDefault = &defaultGasLimit
fixedPrice := "FixedPrice"
sourceC.GasEstimator.Mode = &fixedPrice
d, _ := config.NewDuration(100 * time.Millisecond)
sourceC.LogPollInterval = &d
sourceC.FinalityDepth = &finalityDepth
return &v2.EVMConfig{
ChainID: (*evmUtils.Big)(chainId),
ChainID: (*evmUtils.Big)(chainID),
Enabled: &tr,
Chain: sourceC,
Nodes: v2.EVMNodes{&v2.Node{}},
Expand All @@ -553,10 +553,10 @@ type CCIPIntegrationTestHarness struct {
Bootstrap Node
}

func SetupCCIPIntegrationTH(t *testing.T, sourceChainID, sourceChainSelector, destChainId, destChainSelector uint64,
func SetupCCIPIntegrationTH(t *testing.T, sourceChainID, sourceChainSelector, destChainID, destChainSelector uint64,
sourceFinalityDepth, destFinalityDepth uint32) CCIPIntegrationTestHarness {
return CCIPIntegrationTestHarness{
CCIPContracts: testhelpers.SetupCCIPContracts(t, sourceChainID, sourceChainSelector, destChainId,
CCIPContracts: testhelpers.SetupCCIPContracts(t, sourceChainID, sourceChainSelector, destChainID,
destChainSelector, sourceFinalityDepth, destFinalityDepth),
}
}
Expand Down

0 comments on commit 6c0a5e1

Please sign in to comment.