Skip to content

Commit

Permalink
Memorize longer tests (#15566)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-sekara authored Dec 9, 2024
1 parent a4b0c19 commit 077971e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 120 deletions.
39 changes: 0 additions & 39 deletions .github/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -948,45 +948,6 @@ runner-test-matrix:
E2E_TEST_SELECTED_NETWORK: SIMULATED_1,SIMULATED_2
E2E_JD_VERSION: 0.6.0

- id: smoke/ccip/ccip_token_transfer_test.go:*
path: integration-tests/smoke/ccip/ccip_token_transfer_test.go
test_env_type: docker
runs_on: ubuntu-latest
triggers:
- PR E2E Core Tests
- Nightly E2E Tests
test_cmd: cd integration-tests/ && go test smoke/ccip/ccip_token_transfer_test.go -timeout 16m -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.6.0

- id: smoke/ccip/ccip_ooo_execution_test.go:*
path: integration-tests/smoke/ccip/ccip_ooo_execution_test.go
test_env_type: docker
runs_on: ubuntu-latest
triggers:
- PR E2E Core Tests
- Nightly E2E Tests
test_cmd: cd integration-tests/ && go test smoke/ccip/ccip_ooo_execution_test.go -timeout 16m -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.6.0

- id: smoke/ccip/ccip_usdc_test.go:*
path: integration-tests/smoke/ccip/ccip_usdc_test.go
test_env_type: docker
runs_on: ubuntu-latest
triggers:
- PR E2E Core Tests
- Nightly E2E Tests
test_cmd: cd integration-tests/smoke/ccip && go test ccip_usdc_test.go -timeout 18m -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,SIMULATED_3
E2E_JD_VERSION: 0.6.0

- id: smoke/ccip/ccip_message_limitations_test.go:*
path: integration-tests/smoke/ccip/ccip_message_limitations_test.go
test_env_type: docker
Expand Down
24 changes: 24 additions & 0 deletions .github/integration-in-memory-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,28 @@ runner-test-matrix:
- PR Integration CCIP Tests
test_cmd: cd integration-tests/contracts && go test ccipreader_test.go -timeout 5m -test.parallel=1 -count=1 -json

- id: smoke/ccip/ccip_usdc_test.go:*
path: integration-tests/smoke/ccip/ccip_usdc_test.go
test_env_type: in-memory
runs_on: ubuntu-latest
triggers:
- PR Integration CCIP Tests
test_cmd: cd integration-tests/smoke/ccip && go test ccip_usdc_test.go -timeout 18m -test.parallel=1 -count=1 -json

- id: smoke/ccip/ccip_ooo_execution_test.go:*
path: integration-tests/smoke/ccip/ccip_ooo_execution_test.go
test_env_type: in-memory
runs_on: ubuntu-latest
triggers:
- PR Integration CCIP Tests
test_cmd: cd integration-tests/ && go test smoke/ccip/ccip_ooo_execution_test.go -timeout 16m -test.parallel=1 -count=1 -json

- id: smoke/ccip/ccip_token_transfer_test.go:*
path: integration-tests/smoke/ccip/ccip_token_transfer_test.go
test_env_type: in-memory
runs_on: ubuntu-latest
triggers:
- PR Integration CCIP Tests
test_cmd: cd integration-tests/ && go test smoke/ccip/ccip_token_transfer_test.go -timeout 16m -test.parallel=1 -count=1 -json

# END: CCIP tests
11 changes: 7 additions & 4 deletions integration-tests/smoke/ccip/ccip_ooo_execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand All @@ -36,9 +36,12 @@ func Test_OutOfOrderExecution(t *testing.T) {
IsUSDC: true,
IsUSDCAttestationMissing: true,
}
tenv, _, _ := testsetups.NewLocalDevEnvironmentWithDefaultPrice(t, lggr, config)
// Inmemory setup used for debugging and development, use instead of docker when needed
//tenv := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, lggr, 2, 4, config)
tenv := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 2,
Nodes: 4,
Bootstraps: 1,
NumOfUsersPerChain: 2,
}, config)

e := tenv.Env
state, err := changeset.LoadOnchainState(e)
Expand Down
82 changes: 13 additions & 69 deletions integration-tests/smoke/ccip/ccip_token_transfer_test.go
Original file line number Diff line number Diff line change
@@ -1,56 +1,50 @@
package smoke

import (
"context"
"math/big"
"testing"

"golang.org/x/exp/maps"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"

sel "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)

func TestTokenTransfer(t *testing.T) {
t.Skip("need to deflake and optimize")
lggr := logger.TestLogger(t)
ctx := tests.Context(t)
config := &changeset.TestConfigs{}
tenv, _, _ := testsetups.NewLocalDevEnvironmentWithDefaultPrice(t, lggr, config)
inMemoryEnv := false

// use this if you are testing locally in memory
// tenv := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, lggr, 2, 4, config)
// inMemoryEnv := true
tenv := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 2,
Nodes: 4,
Bootstraps: 1,
NumOfUsersPerChain: 3,
}, config)

e := tenv.Env
state, err := changeset.LoadOnchainState(e)
require.NoError(t, err)
require.GreaterOrEqual(t, len(e.Chains), 2)

allChainSelectors := maps.Keys(e.Chains)
sourceChain, destChain := allChainSelectors[0], allChainSelectors[1]
ownerSourceChain := e.Chains[sourceChain].DeployerKey
ownerDestChain := e.Chains[destChain].DeployerKey

oneE18 := new(big.Int).SetUint64(1e18)
funds := new(big.Int).Mul(oneE18, new(big.Int).SetUint64(10))
require.GreaterOrEqual(t, len(tenv.Users[sourceChain]), 2)
require.GreaterOrEqual(t, len(tenv.Users[destChain]), 2)
selfServeSrcTokenPoolDeployer := tenv.Users[sourceChain][1]
selfServeDestTokenPoolDeployer := tenv.Users[destChain][1]

// Deploy and fund self-serve actors
selfServeSrcTokenPoolDeployer := createAndFundSelfServeActor(ctx, t, ownerSourceChain, e.Chains[sourceChain], funds, inMemoryEnv)
selfServeDestTokenPoolDeployer := createAndFundSelfServeActor(ctx, t, ownerDestChain, e.Chains[destChain], funds, inMemoryEnv)
oneE18 := new(big.Int).SetUint64(1e18)

// Deploy tokens and pool by CCIP Owner
srcToken, _, destToken, _, err := changeset.DeployTransferableToken(
Expand Down Expand Up @@ -227,53 +221,3 @@ func TestTokenTransfer(t *testing.T) {

changeset.WaitForTokenBalances(ctx, t, e.Chains, expectedTokenBalances)
}

func createAndFundSelfServeActor(
ctx context.Context,
t *testing.T,
deployer *bind.TransactOpts,
chain deployment.Chain,
amountToFund *big.Int,
isInMemory bool,
) *bind.TransactOpts {
key, err := crypto.GenerateKey()
require.NoError(t, err)

// Simulated backend sets chainID to 1337 always
chainID := big.NewInt(1337)
if !isInMemory {
// Docker environment runs real geth so chainID has to be set accordingly
stringChainID, err1 := sel.GetChainIDFromSelector(chain.Selector)
require.NoError(t, err1)
chainID, _ = new(big.Int).SetString(stringChainID, 10)
}

actor, err := bind.NewKeyedTransactorWithChainID(key, chainID)
require.NoError(t, err)

nonce, err := chain.Client.PendingNonceAt(ctx, deployer.From)
require.NoError(t, err)

gasPrice, err := chain.Client.SuggestGasPrice(ctx)
require.NoError(t, err)

tx := types.NewTx(&types.LegacyTx{
Nonce: nonce,
To: &actor.From,
Value: amountToFund,
Gas: uint64(21000),
GasPrice: gasPrice,
Data: nil,
})

signedTx, err := deployer.Signer(deployer.From, tx)
require.NoError(t, err)

err = chain.Client.SendTransaction(ctx, signedTx)
require.NoError(t, err)

_, err = chain.Confirm(signedTx)
require.NoError(t, err)

return actor
}
15 changes: 7 additions & 8 deletions integration-tests/smoke/ccip/ccip_usdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/burn_mint_erc677"
Expand All @@ -34,13 +34,12 @@ func TestUSDCTokenTransfer(t *testing.T) {
config := &changeset.TestConfigs{
IsUSDC: true,
}
tenv, _, _ := testsetups.NewLocalDevEnvironmentWithDefaultPrice(t, lggr, config)
//tenv := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, lggr, memory.MemoryEnvironmentConfig{
// Chains: 3,
// NumOfUsersPerChain: 3,
// Nodes: 5,
// Bootstraps: 1,
//}, config)
tenv := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, lggr, memory.MemoryEnvironmentConfig{
Chains: 3,
NumOfUsersPerChain: 3,
Nodes: 4,
Bootstraps: 1,
}, config)

e := tenv.Env
state, err := changeset.LoadOnchainState(e)
Expand Down

0 comments on commit 077971e

Please sign in to comment.