Skip to content

Commit

Permalink
Merge branch 'develop' into http_ws_load_groups
Browse files Browse the repository at this point in the history
# Conflicts:
#	integration-tests/testsetups/mercury.go
  • Loading branch information
skudasov committed Mar 6, 2023
2 parents 5224d3a + 5526378 commit 56d3179
Show file tree
Hide file tree
Showing 32 changed files with 273 additions and 205 deletions.
11 changes: 7 additions & 4 deletions integration-tests/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
uuid "github.com/satori/go.uuid"
"go.uber.org/zap/zapcore"
Expand Down Expand Up @@ -231,6 +232,7 @@ func TeardownSuite(
failingLogLevel zapcore.Level, // Examines logs after the test, and fails the test if any Chainlink logs are found at or above provided level
clients ...blockchain.EVMClient,
) error {
l := zerolog.New(zerolog.NewTestWriter(t))
if err := testreporters.WriteTeardownLogs(t, env, optionalTestReporter, failingLogLevel); err != nil {
return errors.Wrap(err, "Error dumping environment logs, leaving environment running for manual retrieval")
}
Expand All @@ -240,12 +242,12 @@ func TeardownSuite(
// This printed line is required for tests that use real funds to propagate the failure
// out to the system running the test. Do not remove
fmt.Println(environment.FAILED_FUND_RETURN)
log.Error().Err(err).Str("Namespace", env.Cfg.Namespace).
l.Error().Err(err).Str("Namespace", env.Cfg.Namespace).
Msg("Error attempting to return funds from chainlink nodes to network's default wallet. " +
"Environment is left running so you can try manually!")
}
} else {
log.Info().Msg("Successfully returned funds from chainlink nodes to default network wallets")
l.Info().Msg("Successfully returned funds from chainlink nodes to default network wallets")
}
// nolint
if c != nil {
Expand All @@ -268,12 +270,13 @@ func TeardownRemoteSuite(
optionalTestReporter testreporters.TestReporter, // Optionally pass in a test reporter to log further metrics
client blockchain.EVMClient,
) error {
l := zerolog.New(zerolog.NewTestWriter(t))
var err error
if err = testreporters.SendReport(t, env, "./", optionalTestReporter); err != nil {
log.Warn().Err(err).Msg("Error writing test report")
l.Warn().Err(err).Msg("Error writing test report")
}
if err = returnFunds(chainlinkNodes, client); err != nil {
log.Error().Err(err).Str("Namespace", env.Cfg.Namespace).
l.Error().Err(err).Str("Namespace", env.Cfg.Namespace).
Msg("Error attempting to return funds from chainlink nodes to network's default wallet. " +
"Environment is left running so you can try manually!")
}
Expand Down
17 changes: 10 additions & 7 deletions integration-tests/actions/automation_ocr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/lib/pq"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog"
"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/contracts/ethereum"
"github.com/smartcontractkit/libocr/offchainreporting2/confighelper"
types2 "github.com/smartcontractkit/ocr2keepers/pkg/types"
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink/core/services/job"
"github.com/smartcontractkit/chainlink/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/core/store/models"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/libocr/offchainreporting2/confighelper"
types2 "github.com/smartcontractkit/ocr2keepers/pkg/types"
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v4"
)

func BuildAutoOCR2ConfigVars(
Expand All @@ -31,6 +32,7 @@ func BuildAutoOCR2ConfigVars(
registrar string,
deltaStage time.Duration,
) contracts.OCRConfig {
l := zerolog.New(zerolog.NewTestWriter(t))
S, oracleIdentities := getOracleIdentities(t, chainlinkNodes)

signerOnchainPublicKeys, transmitterAccounts, f, _, offchainConfigVersion, offchainConfig, err := confighelper.ContractSetConfigArgsForTests(
Expand Down Expand Up @@ -77,7 +79,7 @@ func BuildAutoOCR2ConfigVars(
onchainConfig, err := registryConfig.EncodeOnChainConfig(registrar)
require.NoError(t, err, "Shouldn't fail encoding config")

log.Info().Msg("Done building OCR config")
l.Info().Msg("Done building OCR config")
return contracts.OCRConfig{
Signers: signers,
Transmitters: transmitters,
Expand All @@ -96,6 +98,7 @@ func CreateOCRKeeperJobs(
chainID int64,
keyIndex int,
) {
l := zerolog.New(zerolog.NewTestWriter(t))
bootstrapNode := chainlinkNodes[0]
bootstrapNode.RemoteIP()
bootstrapP2PIds, err := bootstrapNode.MustReadP2PKeys()
Expand Down Expand Up @@ -154,7 +157,7 @@ func CreateOCRKeeperJobs(
_, err = chainlinkNodes[nodeIndex].MustCreateJob(&autoOCR2JobSpec)
require.NoError(t, err, "Shouldn't fail creating OCR Task job on OCR node %d", nodeIndex+1)
}
log.Info().Msg("Done creating OCR automation jobs")
l.Info().Msg("Done creating OCR automation jobs")
}

// DeployAutoOCRRegistryAndRegistrar registry and registrar
Expand Down
30 changes: 16 additions & 14 deletions integration-tests/actions/keeper_benchmark_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"testing"
"time"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/rs/zerolog"
"github.com/stretchr/testify/require"

"github.com/ethereum/go-ethereum/common"
"github.com/rs/zerolog/log"
"github.com/smartcontractkit/chainlink/integration-tests/client"

"github.com/ethereum/go-ethereum/common"
"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/contracts/ethereum"

Expand Down Expand Up @@ -117,6 +117,7 @@ func ResetUpkeeps(
predeployedContracts []contracts.KeeperConsumerBenchmark,
upkeepResetterAddr string,
) {
l := zerolog.New(zerolog.NewTestWriter(t))
contractLoader, err := contracts.NewContractLoader(client)
require.NoError(t, err, "Error loading upkeep contract")
upkeepChunkSize := 500
Expand All @@ -131,11 +132,11 @@ func ResetUpkeeps(
}
err = client.WaitForEvents()
require.NoError(t, err, "Failed to wait for deploying UpkeepResetter")
log.Info().Str("UpkeepResetter Address", upkeepResetter.Address()).Msg("Deployed UpkeepResetter")
l.Info().Str("UpkeepResetter Address", upkeepResetter.Address()).Msg("Deployed UpkeepResetter")
upkeepResetterAddr = upkeepResetter.Address()
}
upkeepResetter, _ := contractLoader.LoadUpkeepResetter(common.HexToAddress(upkeepResetterAddr))
log.Info().Str("UpkeepResetter Address", upkeepResetter.Address()).Msg("Loaded UpkeepResetter")
l.Info().Str("UpkeepResetter Address", upkeepResetter.Address()).Msg("Loaded UpkeepResetter")

iter := 0
upkeepChunks[iter] = make([]string, 0)
Expand All @@ -146,13 +147,13 @@ func ResetUpkeeps(
}
upkeepChunks[iter] = append(upkeepChunks[iter], predeployedContracts[count].Address())
}
log.Debug().Int("UpkeepChunk length", len(upkeepChunks))
l.Debug().Int("UpkeepChunk length", len(upkeepChunks))
for it, upkeepChunk := range upkeepChunks {
err := upkeepResetter.ResetManyConsumerBenchmark(context.Background(), upkeepChunk, big.NewInt(blockRange),
big.NewInt(blockInterval), big.NewInt(firstEligibleBuffer), big.NewInt(checkGasToBurn), big.NewInt(performGasToBurn))
log.Info().Int("Number of Contracts", len(upkeepChunk)).Int("Batch", it).Msg("Resetting batch of Contracts")
log.Debug().Str("Address", upkeepChunk[0]).Msg("First Upkeep to be reset")
log.Debug().Str("Address", upkeepChunk[len(upkeepChunk)-1]).Msg("Last Upkeep to be reset")
l.Info().Int("Number of Contracts", len(upkeepChunk)).Int("Batch", it).Msg("Resetting batch of Contracts")
l.Debug().Str("Address", upkeepChunk[0]).Msg("First Upkeep to be reset")
l.Debug().Str("Address", upkeepChunk[len(upkeepChunk)-1]).Msg("Last Upkeep to be reset")
if err != nil {
require.NoError(t, err, "Resetting upkeeps shouldn't fail")
}
Expand All @@ -174,19 +175,20 @@ func DeployKeeperConsumersBenchmark(
predeployedContracts []string,
upkeepResetterAddr string,
) []contracts.KeeperConsumerBenchmark {
l := zerolog.New(zerolog.NewTestWriter(t))
upkeeps := make([]contracts.KeeperConsumerBenchmark, 0)
firstEligibleBuffer = 10000

if len(predeployedContracts) >= numberOfContracts {
contractLoader, err := contracts.NewContractLoader(client)
if err != nil {
log.Error().Err(err).Msg("Loading Contract Loader shouldn't fail")
l.Error().Err(err).Msg("Loading Contract Loader shouldn't fail")
}
for count, address := range predeployedContracts {
if count < numberOfContracts {
keeperConsumerInstance, err := contractLoader.LoadKeeperConsumerBenchmark(common.HexToAddress(address))
if err != nil {
log.Error().Err(err).Int("count", count+1).Str("UpkeepAddress", address).Msg("Loading KeeperConsumerBenchmark instance shouldn't fail")
l.Error().Err(err).Int("count", count+1).Str("UpkeepAddress", address).Msg("Loading KeeperConsumerBenchmark instance shouldn't fail")
require.NoError(t, err, "Failed to load KeeperConsumerBenchmark")
}
upkeeps = append(upkeeps, keeperConsumerInstance)
Expand All @@ -208,7 +210,7 @@ func DeployKeeperConsumersBenchmark(
big.NewInt(firstEligibleBuffer),
)
if err != nil {
log.Error().Err(err).Int("count", contractCount+1).Msg("Deploying KeeperConsumerBenchmark instance %d shouldn't fail")
l.Error().Err(err).Int("count", contractCount+1).Msg("Deploying KeeperConsumerBenchmark instance %d shouldn't fail")
keeperConsumerInstance, err = contractDeployer.DeployKeeperConsumerBenchmark(
big.NewInt(blockRange),
big.NewInt(blockInterval),
Expand All @@ -220,7 +222,7 @@ func DeployKeeperConsumersBenchmark(
}
//require.NoError(t, err, "Deploying KeeperConsumerBenchmark instance %d shouldn't fail", contractCount+1)
upkeeps = append(upkeeps, keeperConsumerInstance)
log.Debug().
l.Debug().
Str("Contract Address", keeperConsumerInstance.Address()).
Int("Number", contractCount+1).
Int("Out Of", numberOfContracts).
Expand All @@ -232,7 +234,7 @@ func DeployKeeperConsumersBenchmark(
}
err := client.WaitForEvents()
require.NoError(t, err, "Failed waiting for to deploy all keeper consumer contracts")
log.Info().Msg("Successfully deployed all Keeper Consumer Contracts")
l.Info().Msg("Successfully deployed all Keeper Consumer Contracts")

return upkeeps
}
34 changes: 20 additions & 14 deletions integration-tests/actions/keeper_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog"
"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/contracts/ethereum"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -338,6 +338,7 @@ func RegisterUpkeepContracts(
numberOfContracts int,
upkeepAddresses []string,
) []*big.Int {
l := zerolog.New(zerolog.NewTestWriter(t))
registrationTxHashes := make([]common.Hash, 0)
upkeepIds := make([]*big.Int, 0)
for contractCount, upkeepAddress := range upkeepAddresses {
Expand All @@ -355,7 +356,7 @@ func RegisterUpkeepContracts(
require.NoError(t, err, "Encoding the register request shouldn't fail")
tx, err := linkToken.TransferAndCall(registrar.Address(), linkFunds, req)
require.NoError(t, err, "Error registering the upkeep consumer to the registrar")
log.Debug().
l.Debug().
Str("Contract Address", upkeepAddress).
Int("Number", contractCount+1).
Int("Out Of", numberOfContracts).
Expand Down Expand Up @@ -383,13 +384,13 @@ func RegisterUpkeepContracts(
}
}
require.NotNil(t, upkeepId, "Upkeep ID should be found after registration")
log.Debug().
l.Debug().
Str("TxHash", txHash.String()).
Str("Upkeep ID", upkeepId.String()).
Msg("Found upkeepId in tx hash")
upkeepIds = append(upkeepIds, upkeepId)
}
log.Info().Msg("Successfully registered all Keeper Consumer Contracts")
l.Info().Msg("Successfully registered all Keeper Consumer Contracts")
return upkeepIds
}

Expand All @@ -399,14 +400,15 @@ func DeployKeeperConsumers(
client blockchain.EVMClient,
numberOfContracts int,
) []contracts.KeeperConsumer {
l := zerolog.New(zerolog.NewTestWriter(t))
keeperConsumerContracts := make([]contracts.KeeperConsumer, 0)

for contractCount := 0; contractCount < numberOfContracts; contractCount++ {
// Deploy consumer
keeperConsumerInstance, err := contractDeployer.DeployKeeperConsumer(big.NewInt(5))
require.NoError(t, err, "Deploying KeeperConsumer instance %d shouldn't fail", contractCount+1)
keeperConsumerContracts = append(keeperConsumerContracts, keeperConsumerInstance)
log.Debug().
l.Debug().
Str("Contract Address", keeperConsumerInstance.Address()).
Int("Number", contractCount+1).
Int("Out Of", numberOfContracts).
Expand All @@ -418,7 +420,7 @@ func DeployKeeperConsumers(
}
err := client.WaitForEvents()
require.NoError(t, err, "Failed waiting for to deploy all keeper consumer contracts")
log.Info().Msg("Successfully deployed all Keeper Consumer Contracts")
l.Info().Msg("Successfully deployed all Keeper Consumer Contracts")

return keeperConsumerContracts
}
Expand All @@ -433,6 +435,7 @@ func DeployKeeperConsumersPerformance(
checkGasToBurn, // How much gas should be burned on checkUpkeep() calls
performGasToBurn int64, // How much gas should be burned on performUpkeep() calls
) []contracts.KeeperConsumerPerformance {
l := zerolog.New(zerolog.NewTestWriter(t))
upkeeps := make([]contracts.KeeperConsumerPerformance, 0)

for contractCount := 0; contractCount < numberOfContracts; contractCount++ {
Expand All @@ -445,7 +448,7 @@ func DeployKeeperConsumersPerformance(
)
require.NoError(t, err, "Deploying KeeperConsumerPerformance instance %d shouldn't fail", contractCount+1)
upkeeps = append(upkeeps, keeperConsumerInstance)
log.Debug().
l.Debug().
Str("Contract Address", keeperConsumerInstance.Address()).
Int("Number", contractCount+1).
Int("Out Of", numberOfContracts).
Expand All @@ -457,7 +460,7 @@ func DeployKeeperConsumersPerformance(
}
err := client.WaitForEvents()
require.NoError(t, err, "Failed waiting for to deploy all keeper consumer contracts")
log.Info().Msg("Successfully deployed all Keeper Consumer Contracts")
l.Info().Msg("Successfully deployed all Keeper Consumer Contracts")

return upkeeps
}
Expand All @@ -469,13 +472,14 @@ func DeployPerformDataChecker(
numberOfContracts int,
expectedData []byte,
) []contracts.KeeperPerformDataChecker {
l := zerolog.New(zerolog.NewTestWriter(t))
upkeeps := make([]contracts.KeeperPerformDataChecker, 0)

for contractCount := 0; contractCount < numberOfContracts; contractCount++ {
performDataCheckerInstance, err := contractDeployer.DeployKeeperPerformDataChecker(expectedData)
require.NoError(t, err, "Deploying KeeperPerformDataChecker instance %d shouldn't fail", contractCount+1)
upkeeps = append(upkeeps, performDataCheckerInstance)
log.Debug().
l.Debug().
Str("Contract Address", performDataCheckerInstance.Address()).
Int("Number", contractCount+1).
Int("Out Of", numberOfContracts).
Expand All @@ -487,7 +491,7 @@ func DeployPerformDataChecker(
}
err := client.WaitForEvents()
require.NoError(t, err, "Failed waiting for to deploy all keeper perform data checker contracts")
log.Info().Msg("Successfully deployed all PerformDataChecker Contracts")
l.Info().Msg("Successfully deployed all PerformDataChecker Contracts")

return upkeeps
}
Expand All @@ -500,14 +504,15 @@ func DeployUpkeepCounters(
testRange *big.Int,
interval *big.Int,
) []contracts.UpkeepCounter {
l := zerolog.New(zerolog.NewTestWriter(t))
upkeepCounters := make([]contracts.UpkeepCounter, 0)

for contractCount := 0; contractCount < numberOfContracts; contractCount++ {
// Deploy consumer
upkeepCounter, err := contractDeployer.DeployUpkeepCounter(testRange, interval)
require.NoError(t, err, "Deploying KeeperConsumer instance %d shouldn't fail", contractCount+1)
upkeepCounters = append(upkeepCounters, upkeepCounter)
log.Debug().
l.Debug().
Str("Contract Address", upkeepCounter.Address()).
Int("Number", contractCount+1).
Int("Out Of", numberOfContracts).
Expand All @@ -519,7 +524,7 @@ func DeployUpkeepCounters(
}
err := client.WaitForEvents()
require.NoError(t, err, "Failed waiting for to deploy all keeper consumer contracts")
log.Info().Msg("Successfully deployed all Keeper Consumer Contracts")
l.Info().Msg("Successfully deployed all Keeper Consumer Contracts")

return upkeepCounters
}
Expand All @@ -532,14 +537,15 @@ func DeployUpkeepPerformCounterRestrictive(
testRange *big.Int,
averageEligibilityCadence *big.Int,
) []contracts.UpkeepPerformCounterRestrictive {
l := zerolog.New(zerolog.NewTestWriter(t))
upkeepCounters := make([]contracts.UpkeepPerformCounterRestrictive, 0)

for contractCount := 0; contractCount < numberOfContracts; contractCount++ {
// Deploy consumer
upkeepCounter, err := contractDeployer.DeployUpkeepPerformCounterRestrictive(testRange, averageEligibilityCadence)
require.NoError(t, err, "Deploying KeeperConsumer instance %d shouldn't fail", contractCount+1)
upkeepCounters = append(upkeepCounters, upkeepCounter)
log.Debug().
l.Debug().
Str("Contract Address", upkeepCounter.Address()).
Int("Number", contractCount+1).
Int("Out Of", numberOfContracts).
Expand All @@ -551,7 +557,7 @@ func DeployUpkeepPerformCounterRestrictive(
}
err := client.WaitForEvents()
require.NoError(t, err, "Failed waiting for to deploy all keeper consumer contracts")
log.Info().Msg("Successfully deployed all Keeper Consumer Contracts")
l.Info().Msg("Successfully deployed all Keeper Consumer Contracts")

return upkeepCounters
}
Expand Down
Loading

0 comments on commit 56d3179

Please sign in to comment.