Skip to content

Commit

Permalink
Fix keepers and flux smoke tests to have evmChainID in the jobspec
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Sep 12, 2023
1 parent 792ffac commit d3d05da
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 19 deletions.
4 changes: 4 additions & 0 deletions integration-tests/actions/keeper_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func CreateKeeperJobs(
chainlinkNodes []*client.ChainlinkK8sClient,
keeperRegistry contracts.KeeperRegistry,
ocrConfig contracts.OCRv2Config,
evmChainID string,
) {
// Send keeper jobs to registry and chainlink nodes
primaryNode := chainlinkNodes[0]
Expand All @@ -49,6 +50,7 @@ func CreateKeeperJobs(
Name: fmt.Sprintf("keeper-test-%s", keeperRegistry.Address()),
ContractAddress: keeperRegistry.Address(),
FromAddress: chainlinkNodeAddress,
EVMChainID: evmChainID,
MinIncomingConfirmations: 1,
})
require.NoError(t, err, "Creating KeeperV2 Job shouldn't fail")
Expand All @@ -61,6 +63,7 @@ func CreateKeeperJobsWithKeyIndex(
keeperRegistry contracts.KeeperRegistry,
keyIndex int,
ocrConfig contracts.OCRv2Config,
evmChainID string,
) {
// Send keeper jobs to registry and chainlink nodes
primaryNode := chainlinkNodes[0]
Expand All @@ -83,6 +86,7 @@ func CreateKeeperJobsWithKeyIndex(
Name: fmt.Sprintf("keeper-test-%s", keeperRegistry.Address()),
ContractAddress: keeperRegistry.Address(),
FromAddress: chainlinkNodeAddress[keyIndex],
EVMChainID: evmChainID,
MinIncomingConfirmations: 1,
})
require.NoError(t, err, "Creating KeeperV2 Job shouldn't fail")
Expand Down
10 changes: 6 additions & 4 deletions integration-tests/actions/keeper_helpers_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/rs/zerolog/log"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
)
Expand All @@ -12,6 +13,7 @@ func CreateKeeperJobsLocal(
chainlinkNodes []*client.ChainlinkClient,
keeperRegistry contracts.KeeperRegistry,
ocrConfig contracts.OCRv2Config,
evmChainID string,
) ([]*client.Job, error) {
// Send keeper jobs to registry and chainlink nodes
primaryNode := chainlinkNodes[0]
Expand Down Expand Up @@ -43,10 +45,10 @@ func CreateKeeperJobsLocal(
return nil, err
}
job, err := chainlinkNode.MustCreateJob(&client.KeeperJobSpec{
Name: fmt.Sprintf("keeper-test-%s", keeperRegistry.Address()),
ContractAddress: keeperRegistry.Address(),
FromAddress: chainlinkNodeAddress,
MinIncomingConfirmations: 1,
Name: fmt.Sprintf("keeper-test-%s", keeperRegistry.Address()),
ContractAddress: keeperRegistry.Address(),
FromAddress: chainlinkNodeAddress,
EVMChainID: evmChainID,
})
if err != nil {
log.Error().Err(err).Msg("Creating KeeperV2 Job shouldn't fail")
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/client/chainlink_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ observationSource = """
type FluxMonitorJobSpec struct {
Name string `toml:"name"`
ContractAddress string `toml:"contractAddress"` // Address of the Flux Monitor script
EVMChainID string `toml:"evmChainID"` // Not optional
Precision int `toml:"precision"` // Optional
Threshold float32 `toml:"threshold"` // Optional
AbsoluteThreshold float32 `toml:"absoluteThreshold"` // Optional
Expand All @@ -809,6 +810,7 @@ func (f *FluxMonitorJobSpec) String() (string, error) {
schemaVersion = 1
name = "{{.Name}}"
contractAddress = "{{.ContractAddress}}"
evmChainID = "{{.EVMChainID}}"
precision ={{if not .Precision}} 0 {{else}} {{.Precision}} {{end}}
threshold ={{if not .Threshold}} 0.5 {{else}} {{.Threshold}} {{end}}
absoluteThreshold ={{if not .AbsoluteThreshold}} 0.1 {{else}} {{.AbsoluteThreshold}} {{end}}
Expand All @@ -832,6 +834,7 @@ type KeeperJobSpec struct {
Name string `toml:"name"`
ContractAddress string `toml:"contractAddress"`
FromAddress string `toml:"fromAddress"` // Hex representation of the from address
EVMChainID string `toml:"evmChainID"` // Not optional
MinIncomingConfirmations int `toml:"minIncomingConfirmations"`
}

Expand All @@ -846,6 +849,7 @@ schemaVersion = 1
name = "{{.Name}}"
contractAddress = "{{.ContractAddress}}"
fromAddress = "{{.FromAddress}}"
evmChainID = "{{.EVMChainID}}"
minIncomingConfirmations = {{.MinIncomingConfirmations}}
`
return MarshallTemplate(k, "Keeper Job", keeperTemplateString)
Expand Down
1 change: 1 addition & 0 deletions integration-tests/performance/flux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func TestFluxPerformance(t *testing.T) {
fluxSpec := &client.FluxMonitorJobSpec{
Name: fmt.Sprintf("flux-monitor-%s", adapterUUID),
ContractAddress: fluxInstance.Address(),
EVMChainID: chainClient.GetChainID().String(),
Threshold: 0,
AbsoluteThreshold: 0,
PollTimerPeriod: 15 * time.Second, // min 15s
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/performance/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestKeeperPerformance(t *testing.T) {
// Not the last node, hence not all nodes started profiling yet.
return
}
actions.CreateKeeperJobs(t, chainlinkNodes, registry, contracts.OCRv2Config{})
actions.CreateKeeperJobs(t, chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
err := chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")

Expand Down
1 change: 1 addition & 0 deletions integration-tests/smoke/flux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func TestFluxBasic(t *testing.T) {
fluxSpec := &client.FluxMonitorJobSpec{
Name: fmt.Sprintf("flux-monitor-%s", adapterUUID),
ContractAddress: fluxInstance.Address(),
EVMChainID: env.EVMClient.GetChainID().String(),
Threshold: 0,
AbsoluteThreshold: 0,
PollTimerPeriod: 15 * time.Second, // min 15s
Expand Down
27 changes: 14 additions & 13 deletions integration-tests/smoke/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/utils"

"github.com/smartcontractkit/chainlink/v2/core/store/models"

"github.com/smartcontractkit/chainlink/integration-tests/actions"
Expand Down Expand Up @@ -99,7 +100,7 @@ func TestKeeperBasicSmoke(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down Expand Up @@ -174,7 +175,7 @@ func TestKeeperBlockCountPerTurn(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down Expand Up @@ -280,7 +281,7 @@ func TestKeeperSimulation(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down Expand Up @@ -351,7 +352,7 @@ func TestKeeperCheckPerformGasLimit(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down Expand Up @@ -459,7 +460,7 @@ func TestKeeperRegisterUpkeep(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down Expand Up @@ -546,7 +547,7 @@ func TestKeeperAddFunds(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down Expand Up @@ -608,7 +609,7 @@ func TestKeeperRemove(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down Expand Up @@ -684,7 +685,7 @@ func TestKeeperPauseRegistry(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down Expand Up @@ -744,7 +745,7 @@ func TestKeeperMigrateRegistry(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand All @@ -763,7 +764,7 @@ func TestKeeperMigrateRegistry(t *testing.T) {
)

// Set the jobs for the second registry
_, err = actions.CreateKeeperJobsLocal(chainlinkNodes, secondRegistry, contracts.OCRv2Config{})
_, err = actions.CreateKeeperJobsLocal(chainlinkNodes, secondRegistry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down Expand Up @@ -834,7 +835,7 @@ func TestKeeperNodeDown(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

jobs, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
jobs, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down Expand Up @@ -940,7 +941,7 @@ func TestKeeperPauseUnPauseUpkeep(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down Expand Up @@ -1031,7 +1032,7 @@ func TestKeeperUpdateCheckData(t *testing.T) {
)
gom := gomega.NewGomegaWithT(t)

_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{})
_, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String())
require.NoError(t, err, "Error creating keeper jobs")
err = chainClient.WaitForEvents()
require.NoError(t, err, "Error creating keeper jobs")
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/testsetups/keeper_benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (k *KeeperBenchmarkTest) Run(t *testing.T) {
// Give time for OCR nodes to bootstrap
time.Sleep(1 * time.Minute)
} else {
actions.CreateKeeperJobsWithKeyIndex(t, k.chainlinkNodes, k.keeperRegistries[rIndex], txKeyId, ocrConfig)
actions.CreateKeeperJobsWithKeyIndex(t, k.chainlinkNodes, k.keeperRegistries[rIndex], txKeyId, ocrConfig, k.chainClient.GetChainID().String())
}
err = k.chainClient.WaitForEvents()
require.NoError(t, err, "Error waiting for registry setConfig")
Expand Down

0 comments on commit d3d05da

Please sign in to comment.