Skip to content

Commit

Permalink
bump ctf (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG authored Oct 18, 2023
1 parent 055056e commit 1e3efdf
Show file tree
Hide file tree
Showing 70 changed files with 2,390 additions and 1,293 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/integration-tests-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Integration Tests Publish
# Publish the compiled integration tests
on:
push:
tags:
- "v*"
branches:
- ccip-develop
workflow_dispatch:

env:
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,4 @@ run_test_with_local_image: build_docker_image
SELECTED_NETWORKS="SIMULATED,SIMULATED_1,SIMULATED_2" \
ARGS="$(args)" \
PRODUCT=$(product) \
./scripts/run_product_tests
./scripts/run_product_tests
17 changes: 13 additions & 4 deletions integration-tests/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ func FundChainlinkNodesAddress(
if err != nil {
return err
}
gasEstimates, err := client.EstimateGas(ethereum.CallMsg{})
toAddr := common.HexToAddress(toAddress[keyIndex])
gasEstimates, err := client.EstimateGas(ethereum.CallMsg{
To: &toAddr,
})
if err != nil {
return err
}
Expand All @@ -96,7 +99,10 @@ func FundChainlinkNodesAddresses(
return err
}
for _, addr := range toAddress {
gasEstimates, err := client.EstimateGas(ethereum.CallMsg{})
toAddr := common.HexToAddress(addr)
gasEstimates, err := client.EstimateGas(ethereum.CallMsg{
To: &toAddr,
})
if err != nil {
return err
}
Expand Down Expand Up @@ -369,7 +375,7 @@ func ReturnFunds(chainlinkNodes []*client.ChainlinkK8sClient, blockchainClient b
}
err = blockchainClient.ReturnFunds(decryptedKey.PrivateKey)
if err != nil {
return err
log.Error().Err(err).Str("Address", fundedKeys[0].Address).Msg("Error returning funds from Chainlink node")
}
}
}
Expand All @@ -379,7 +385,10 @@ func ReturnFunds(chainlinkNodes []*client.ChainlinkK8sClient, blockchainClient b
// FundAddresses will fund a list of addresses with an amount of native currency
func FundAddresses(blockchain blockchain.EVMClient, amount *big.Float, addresses ...string) error {
for _, address := range addresses {
gasEstimates, err := blockchain.EstimateGas(ethereum.CallMsg{})
toAddr := common.HexToAddress(address)
gasEstimates, err := blockchain.EstimateGas(ethereum.CallMsg{
To: &toAddr,
})
if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion integration-tests/actions/actions_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package actions

import (
"github.com/pkg/errors"

"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
)

Expand Down
23 changes: 13 additions & 10 deletions integration-tests/actions/automation_ocr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/lib/pq"
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
ocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
ocr3 "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
ocr2keepers20config "github.com/smartcontractkit/ocr2keepers/pkg/v2/config"
ocr2keepers30config "github.com/smartcontractkit/ocr2keepers/pkg/v3/config"
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/store/models"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
Expand All @@ -37,7 +38,7 @@ func BuildAutoOCR2ConfigVars(
registrar string,
deltaStage time.Duration,
) (contracts.OCRv2Config, error) {
return BuildAutoOCR2ConfigVarsWithKeyIndex(t, chainlinkNodes, registryConfig, registrar, deltaStage, 0)
return BuildAutoOCR2ConfigVarsWithKeyIndex(t, chainlinkNodes, registryConfig, registrar, deltaStage, 0, common.Address{})
}

func BuildAutoOCR2ConfigVarsWithKeyIndex(
Expand All @@ -47,6 +48,7 @@ func BuildAutoOCR2ConfigVarsWithKeyIndex(
registrar string,
deltaStage time.Duration,
keyIndex int,
registryOwnerAddress common.Address,
) (contracts.OCRv2Config, error) {
l := logging.GetTestLogger(t)
S, oracleIdentities, err := GetOracleIdentitiesWithKeyIndex(chainlinkNodes, keyIndex)
Expand Down Expand Up @@ -147,7 +149,7 @@ func BuildAutoOCR2ConfigVarsWithKeyIndex(
transmitters = append(transmitters, common.HexToAddress(string(transmitter)))
}

onchainConfig, err := registryConfig.EncodeOnChainConfig(registrar)
onchainConfig, err := registryConfig.EncodeOnChainConfig(registrar, registryOwnerAddress)
if err != nil {
return contracts.OCRv2Config{}, err
}
Expand Down Expand Up @@ -201,7 +203,8 @@ func CreateOCRKeeperJobs(
}
_, err = bootstrapNode.MustCreateJob(bootstrapSpec)
require.NoError(t, err, "Shouldn't fail creating bootstrap job on bootstrap node")
P2Pv2Bootstrapper := fmt.Sprintf("%s@%s:%d", bootstrapP2PId, bootstrapNode.Name(), 6690)
// TODO: Use service name returned by chainlink-env once that is available
P2Pv2Bootstrapper := fmt.Sprintf("%s@%s-node-1:%d", bootstrapP2PId, bootstrapNode.Name(), 6690)

for nodeIndex := 1; nodeIndex < len(chainlinkNodes); nodeIndex++ {
nodeTransmitterAddress, err := chainlinkNodes[nodeIndex].EthAddresses()
Expand Down Expand Up @@ -258,8 +261,8 @@ func DeployAutoOCRRegistryAndRegistrar(
return registry, registrar
}

func DeployConsumers(t *testing.T, registry contracts.KeeperRegistry, registrar contracts.KeeperRegistrar, linkToken contracts.LinkToken, contractDeployer contracts.ContractDeployer, client blockchain.EVMClient, numberOfUpkeeps int, linkFundsForEachUpkeep *big.Int, upkeepGasLimit uint32, isLogTrigger bool) ([]contracts.KeeperConsumer, []*big.Int) {
upkeeps := DeployKeeperConsumers(t, contractDeployer, client, numberOfUpkeeps, isLogTrigger)
func DeployConsumers(t *testing.T, registry contracts.KeeperRegistry, registrar contracts.KeeperRegistrar, linkToken contracts.LinkToken, contractDeployer contracts.ContractDeployer, client blockchain.EVMClient, numberOfUpkeeps int, linkFundsForEachUpkeep *big.Int, upkeepGasLimit uint32, isLogTrigger bool, isMercury bool) ([]contracts.KeeperConsumer, []*big.Int) {
upkeeps := DeployKeeperConsumers(t, contractDeployer, client, numberOfUpkeeps, isLogTrigger, isMercury)
var upkeepsAddresses []string
for _, upkeep := range upkeeps {
upkeepsAddresses = append(upkeepsAddresses, upkeep.Address())
Expand Down
16 changes: 9 additions & 7 deletions integration-tests/actions/automation_ocr_helpers_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import (
"github.com/lib/pq"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum"
ocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
ocr3 "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
ocr2keepers20config "github.com/smartcontractkit/ocr2keepers/pkg/v2/config"
ocr2keepers30config "github.com/smartcontractkit/ocr2keepers/pkg/v3/config"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/store/models"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum"
)

func BuildAutoOCR2ConfigVarsLocal(
Expand All @@ -32,8 +32,9 @@ func BuildAutoOCR2ConfigVarsLocal(
registryConfig contracts.KeeperRegistrySettings,
registrar string,
deltaStage time.Duration,
registryOwnerAddress common.Address,
) (contracts.OCRv2Config, error) {
return BuildAutoOCR2ConfigVarsWithKeyIndexLocal(l, chainlinkNodes, registryConfig, registrar, deltaStage, 0)
return BuildAutoOCR2ConfigVarsWithKeyIndexLocal(l, chainlinkNodes, registryConfig, registrar, deltaStage, 0, registryOwnerAddress)
}

func BuildAutoOCR2ConfigVarsWithKeyIndexLocal(
Expand All @@ -43,6 +44,7 @@ func BuildAutoOCR2ConfigVarsWithKeyIndexLocal(
registrar string,
deltaStage time.Duration,
keyIndex int,
registryOwnerAddress common.Address,
) (contracts.OCRv2Config, error) {
S, oracleIdentities, err := GetOracleIdentitiesWithKeyIndexLocal(chainlinkNodes, keyIndex)
if err != nil {
Expand Down Expand Up @@ -146,7 +148,7 @@ func BuildAutoOCR2ConfigVarsWithKeyIndexLocal(
transmitters = append(transmitters, common.HexToAddress(string(transmitter)))
}

onchainConfig, err := registryConfig.EncodeOnChainConfig(registrar)
onchainConfig, err := registryConfig.EncodeOnChainConfig(registrar, registryOwnerAddress)
if err != nil {
return contracts.OCRv2Config{}, err
}
Expand Down
10 changes: 6 additions & 4 deletions integration-tests/actions/keeper_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func DeployKeeperContracts(
}
registrar := DeployKeeperRegistrar(t, registryVersion, linkToken, registrarSettings, contractDeployer, client, registry)

upkeeps := DeployKeeperConsumers(t, contractDeployer, client, numberOfUpkeeps, false)
upkeeps := DeployKeeperConsumers(t, contractDeployer, client, numberOfUpkeeps, false, false)
var upkeepsAddresses []string
for _, upkeep := range upkeeps {
upkeepsAddresses = append(upkeepsAddresses, upkeep.Address())
Expand Down Expand Up @@ -397,7 +397,7 @@ func RegisterUpkeepContractsWithCheckData(t *testing.T, linkToken contracts.Link
return upkeepIds
}

func DeployKeeperConsumers(t *testing.T, contractDeployer contracts.ContractDeployer, client blockchain.EVMClient, numberOfContracts int, isLogTrigger bool) []contracts.KeeperConsumer {
func DeployKeeperConsumers(t *testing.T, contractDeployer contracts.ContractDeployer, client blockchain.EVMClient, numberOfContracts int, isLogTrigger bool, isMercury bool) []contracts.KeeperConsumer {
l := logging.GetTestLogger(t)
keeperConsumerContracts := make([]contracts.KeeperConsumer, 0)

Expand All @@ -406,7 +406,9 @@ func DeployKeeperConsumers(t *testing.T, contractDeployer contracts.ContractDepl
var keeperConsumerInstance contracts.KeeperConsumer
var err error

if isLogTrigger {
if isMercury {
keeperConsumerInstance, err = contractDeployer.DeployAutomationStreamsLookupUpkeepConsumer(big.NewInt(1000), big.NewInt(5), false, true, false) // 1000 block test range
} else if isLogTrigger {
keeperConsumerInstance, err = contractDeployer.DeployAutomationLogTriggerConsumer(big.NewInt(1000)) // 1000 block test range
} else {
keeperConsumerInstance, err = contractDeployer.DeployKeeperConsumer(big.NewInt(5))
Expand Down Expand Up @@ -581,7 +583,7 @@ func RegisterNewUpkeeps(
upkeepGasLimit uint32,
numberOfNewUpkeeps int,
) ([]contracts.KeeperConsumer, []*big.Int) {
newlyDeployedUpkeeps := DeployKeeperConsumers(t, contractDeployer, client, numberOfNewUpkeeps, false)
newlyDeployedUpkeeps := DeployKeeperConsumers(t, contractDeployer, client, numberOfNewUpkeeps, false, false)

var addressesOfNewUpkeeps []string
for _, upkeep := range newlyDeployedUpkeeps {
Expand Down
21 changes: 11 additions & 10 deletions integration-tests/actions/ocr2_helpers_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"crypto/ed25519"
"encoding/hex"
"fmt"
"net/http"
"strings"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/google/uuid"
"github.com/lib/pq"
"github.com/rs/zerolog/log"
ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client"
"github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
Expand All @@ -29,9 +30,9 @@ func CreateOCRv2JobsLocal(
ocrInstances []contracts.OffchainAggregatorV2,
bootstrapNode *client.ChainlinkClient,
workerChainlinkNodes []*client.ChainlinkClient,
mockserver *ctfClient.MockserverClient,
mockServerPath string, // Path on the mock server for the Chainlink nodes to query
mockServerValue int, // Value to get from the mock server when querying the path
mockAdapter *test_env.Killgrave,
mockAdapterPath string, // Path on the mock server for the Chainlink nodes to query
mockAdapterValue int, // Value to get from the mock server when querying the path
chainId uint64, // EVM chain ID
forwardingAllowed bool,
) error {
Expand All @@ -42,12 +43,12 @@ func CreateOCRv2JobsLocal(
}
p2pV2Bootstrapper := fmt.Sprintf("%s@%s:%d", bootstrapP2PIds.Data[0].Attributes.PeerID, bootstrapNode.InternalIP(), 6690)
// Set the value for the jobs to report on
err = mockserver.SetValuePath(mockServerPath, mockServerValue)
err = mockAdapter.SetAdapterBasedIntValuePath(mockAdapterPath, []string{http.MethodGet, http.MethodPost}, mockAdapterValue)
if err != nil {
return err
}
// Set the juelsPerFeeCoinSource config value
err = mockserver.SetValuePath(fmt.Sprintf("%s/juelsPerFeeCoinSource", mockServerPath), mockServerValue)
err = mockAdapter.SetAdapterBasedIntValuePath(fmt.Sprintf("%s/juelsPerFeeCoinSource", mockAdapterPath), []string{http.MethodGet, http.MethodPost}, mockAdapterValue)
if err != nil {
return err
}
Expand All @@ -62,7 +63,7 @@ func CreateOCRv2JobsLocal(
RelayConfig: map[string]interface{}{
"chainID": chainId,
},
MonitoringEndpoint: null.StringFrom(fmt.Sprintf("%s/%s", mockserver.Config.ClusterURL, mockServerPath)),
MonitoringEndpoint: null.StringFrom(fmt.Sprintf("%s/%s", mockAdapter.InternalEndpoint, mockAdapterPath)),
ContractConfigTrackerPollInterval: *models.NewInterval(15 * time.Second),
},
}
Expand All @@ -83,12 +84,12 @@ func CreateOCRv2JobsLocal(
nodeOCRKeyId := nodeOCRKeys.Data[0].ID

bta := &client.BridgeTypeAttributes{
Name: fmt.Sprintf("%s-%s", mockServerPath, uuid.NewString()),
URL: fmt.Sprintf("%s/%s", mockserver.Config.ClusterURL, mockServerPath),
Name: fmt.Sprintf("%s-%s", mockAdapterPath, uuid.NewString()),
URL: fmt.Sprintf("%s/%s", mockAdapter.InternalEndpoint, mockAdapterPath),
}
juelsBridge := &client.BridgeTypeAttributes{
Name: fmt.Sprintf("juels-%s", uuid.NewString()),
URL: fmt.Sprintf("%s/%s/juelsPerFeeCoinSource", mockserver.Config.ClusterURL, mockServerPath),
URL: fmt.Sprintf("%s/%s/juelsPerFeeCoinSource", mockAdapter.InternalEndpoint, mockAdapterPath),
}
err = chainlinkNode.MustCreateBridge(bta)
if err != nil {
Expand Down
Loading

0 comments on commit 1e3efdf

Please sign in to comment.