From 0f6f84b49a9935f7b077e98c34811d4e2ff74b02 Mon Sep 17 00:00:00 2001 From: Bolek <1416262+bolekk@users.noreply.github.com> Date: Thu, 14 Sep 2023 12:48:55 -0700 Subject: [PATCH 1/3] [Gateway] Return 400 HTTP code on handler errors (#10652) Handler errors are user errors (not allowlisted, rate-limited, etc) so we should return a 4XX code. --- core/services/gateway/api/constants.go | 6 +++--- core/services/gateway/gateway.go | 2 +- core/services/gateway/gateway_test.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/services/gateway/api/constants.go b/core/services/gateway/api/constants.go index 9ab7e0c4495..d64f7dded19 100644 --- a/core/services/gateway/api/constants.go +++ b/core/services/gateway/api/constants.go @@ -6,7 +6,7 @@ const ( NoError ErrorCode = iota UserMessageParseError UnsupportedDONIdError - InternalHandlerError + HandlerError RequestTimeoutError NodeReponseEncodingError FatalError @@ -18,7 +18,7 @@ func ToJsonRPCErrorCode(errorCode ErrorCode) int { NoError: 0, UserMessageParseError: -32700, // Parse Error UnsupportedDONIdError: -32602, // Invalid Params - InternalHandlerError: -32000, // Server Error + HandlerError: -32600, // Invalid Request RequestTimeoutError: -32000, // Server Error NodeReponseEncodingError: -32603, // Internal Error FatalError: -32000, // Server Error @@ -37,7 +37,7 @@ func ToHttpErrorCode(errorCode ErrorCode) int { NoError: 200, // OK UserMessageParseError: 400, // Bad Request UnsupportedDONIdError: 400, // Bad Request - InternalHandlerError: 500, // Internal Server Error + HandlerError: 400, // Bad Request RequestTimeoutError: 504, // Gateway Timeout NodeReponseEncodingError: 500, // Internal Server Error FatalError: 500, // Internal Server Error diff --git a/core/services/gateway/gateway.go b/core/services/gateway/gateway.go index d64ee43233a..fd158d6e0b8 100644 --- a/core/services/gateway/gateway.go +++ b/core/services/gateway/gateway.go @@ -136,7 +136,7 @@ func (g *gateway) ProcessRequest(ctx context.Context, rawRequest []byte) (rawRes responseCh := make(chan handlers.UserCallbackPayload, 1) err = handler.HandleUserMessage(ctx, msg, responseCh) if err != nil { - return newError(g.codec, msg.Body.MessageId, api.InternalHandlerError, err.Error()) + return newError(g.codec, msg.Body.MessageId, api.HandlerError, err.Error()) } // await response var response handlers.UserCallbackPayload diff --git a/core/services/gateway/gateway_test.go b/core/services/gateway/gateway_test.go index a2ee8f7a6c0..5fad6315a31 100644 --- a/core/services/gateway/gateway_test.go +++ b/core/services/gateway/gateway_test.go @@ -242,6 +242,6 @@ func TestGateway_ProcessRequest_HandlerError(t *testing.T) { req := newSignedRequest(t, "abcd", "request", "testDON", []byte{}) response, statusCode := gw.ProcessRequest(testutils.Context(t), req) - requireJsonRPCError(t, response, "abcd", -32000, "failure") - require.Equal(t, 500, statusCode) + requireJsonRPCError(t, response, "abcd", -32600, "failure") + require.Equal(t, 400, statusCode) } From 5570d5a558f18aacc5d5e0d511c0235db9bb4925 Mon Sep 17 00:00:00 2001 From: chainchad <96362174+chainchad@users.noreply.github.com> Date: Thu, 14 Sep 2023 16:35:40 -0400 Subject: [PATCH 2/3] Allow workflow to be dispatched (#10651) --- .github/workflows/build-publish-develop.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-publish-develop.yml b/.github/workflows/build-publish-develop.yml index 22f9ce81f7f..4384956da3c 100644 --- a/.github/workflows/build-publish-develop.yml +++ b/.github/workflows/build-publish-develop.yml @@ -1,9 +1,16 @@ -name: 'Push develop to private ECR' +name: "Push develop to private ECR" on: push: branches: - develop + workflow_dispatch: + inputs: + git_ref: + description: "Git ref (commit SHA, branch name, tag name, etc.) to checkout" + required: true +env: + GIT_REF: ${{ github.event.inputs.git_ref || github.ref }} jobs: push-chainlink-develop: @@ -25,7 +32,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - + with: + ref: ${{ env.GIT_REF }} - name: Build, sign and publish chainlink image uses: ./.github/actions/build-sign-publish-chainlink with: From d407306e50c53c640be73ecc79613f7c5bf538ee Mon Sep 17 00:00:00 2001 From: Tate Date: Thu, 14 Sep 2023 14:48:51 -0600 Subject: [PATCH 3/3] [TT-591] Parallel Test Logging E2E Fixes (#10610) * [TT-591] Fix E2E Test Logging In Parallel Tests * triage why logs are not getting the correct test struct * More logging missing in parallel e2e tests * More improvements to the logging * merge conflict fixes * Cover more missing cases * More and cleanup * Bump ctf and merge conflict fixes --- integration-tests/actions/actions.go | 5 +- .../actions/automation_ocr_helpers.go | 6 +- .../actions/automation_ocr_helpers_local.go | 33 ++--- integration-tests/actions/keeper_helpers.go | 14 +- .../actions/keeper_helpers_local.go | 13 +- integration-tests/actions/ocr2_helpers.go | 4 +- .../ocr2vrf_actions/ocr2vrf_config_helpers.go | 8 +- .../actions/ocr2vrf_actions/ocr2vrf_steps.go | 10 +- integration-tests/actions/ocr_helpers.go | 4 +- .../actions/ocr_helpers_local.go | 5 +- .../actions/operator_forwarder_helpers.go | 8 +- integration-tests/benchmark/keeper_test.go | 9 +- .../chaos/automation_chaos_test.go | 11 +- integration-tests/chaos/ocr2vrf_chaos_test.go | 10 +- integration-tests/chaos/ocr_chaos_test.go | 10 +- integration-tests/client/chainlink.go | 136 +++++++++--------- .../contracts/contract_deployer.go | 34 +++-- .../contracts/contract_loader.go | 22 +-- .../contracts/ethereum_contracts.go | 56 +++++--- .../contracts/ethereum_keeper_contracts.go | 44 +++--- integration-tests/docker/test_env/cl_node.go | 30 +++- integration-tests/docker/test_env/test_env.go | 42 ++++-- .../docker/test_env/test_env_builder.go | 29 +++- integration-tests/go.mod | 2 +- integration-tests/go.sum | 4 +- integration-tests/load/functions/setup.go | 6 +- .../migration/upgrade_version_test.go | 4 +- .../performance/directrequest_test.go | 9 +- integration-tests/performance/flux_test.go | 13 +- integration-tests/performance/keeper_test.go | 10 +- integration-tests/performance/ocr_test.go | 11 +- integration-tests/performance/vrf_test.go | 9 +- .../reorg/automation_reorg_test.go | 10 +- integration-tests/reorg/reorg_test.go | 5 +- integration-tests/smoke/automation_test.go | 28 ++-- integration-tests/smoke/cron_test.go | 5 +- integration-tests/smoke/flux_test.go | 9 +- integration-tests/smoke/forwarder_ocr_test.go | 11 +- .../smoke/forwarders_ocr2_test.go | 11 +- integration-tests/smoke/keeper_test.go | 51 ++++--- integration-tests/smoke/ocr2_test.go | 10 +- integration-tests/smoke/ocr2vrf_test.go | 16 +-- integration-tests/smoke/ocr_test.go | 9 +- integration-tests/smoke/runlog_test.go | 5 +- integration-tests/smoke/vrf_test.go | 5 +- integration-tests/smoke/vrfv2_test.go | 5 +- integration-tests/smoke/vrfv2plus_test.go | 5 +- integration-tests/soak/forwarder_ocr_test.go | 4 +- integration-tests/soak/ocr_test.go | 4 +- integration-tests/testsetups/don_evm_chain.go | 9 +- .../testsetups/keeper_benchmark.go | 15 +- integration-tests/testsetups/ocr.go | 35 +++-- integration-tests/testsetups/vrfv2.go | 4 +- 53 files changed, 498 insertions(+), 369 deletions(-) diff --git a/integration-tests/actions/actions.go b/integration-tests/actions/actions.go index 82187fd0cb8..e37c3738ff8 100644 --- a/integration-tests/actions/actions.go +++ b/integration-tests/actions/actions.go @@ -19,6 +19,7 @@ import ( "github.com/smartcontractkit/chainlink-env/environment" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/testreporters" "github.com/smartcontractkit/chainlink-testing-framework/utils" @@ -251,7 +252,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 := utils.GetTestLogger(t) + l := logging.GetTestLogger(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") } @@ -295,7 +296,7 @@ func TeardownRemoteSuite( optionalTestReporter testreporters.TestReporter, // Optionally pass in a test reporter to log further metrics client blockchain.EVMClient, ) error { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) var err error if err = testreporters.SendReport(t, namespace, "./", optionalTestReporter); err != nil { l.Warn().Err(err).Msg("Error writing test report") diff --git a/integration-tests/actions/automation_ocr_helpers.go b/integration-tests/actions/automation_ocr_helpers.go index bfea6ec302c..fb94d6109b4 100644 --- a/integration-tests/actions/automation_ocr_helpers.go +++ b/integration-tests/actions/automation_ocr_helpers.go @@ -13,7 +13,7 @@ import ( "github.com/lib/pq" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "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" @@ -48,7 +48,7 @@ func BuildAutoOCR2ConfigVarsWithKeyIndex( deltaStage time.Duration, keyIndex int, ) (contracts.OCRv2Config, error) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) S, oracleIdentities, err := GetOracleIdentitiesWithKeyIndex(chainlinkNodes, keyIndex) if err != nil { return contracts.OCRv2Config{}, err @@ -172,7 +172,7 @@ func CreateOCRKeeperJobs( keyIndex int, registryVersion ethereum.KeeperRegistryVersion, ) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) bootstrapNode := chainlinkNodes[0] bootstrapP2PIds, err := bootstrapNode.MustReadP2PKeys() require.NoError(t, err, "Shouldn't fail reading P2P keys from bootstrap node") diff --git a/integration-tests/actions/automation_ocr_helpers_local.go b/integration-tests/actions/automation_ocr_helpers_local.go index dce55e42275..86738b0247d 100644 --- a/integration-tests/actions/automation_ocr_helpers_local.go +++ b/integration-tests/actions/automation_ocr_helpers_local.go @@ -4,17 +4,14 @@ package actions import ( "encoding/json" "fmt" - "testing" "time" "github.com/ethereum/go-ethereum/common" "github.com/lib/pq" "github.com/pkg/errors" - "github.com/rs/zerolog/log" - "github.com/stretchr/testify/require" + "github.com/rs/zerolog" "gopkg.in/guregu/null.v4" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" @@ -30,24 +27,23 @@ import ( ) func BuildAutoOCR2ConfigVarsLocal( - t *testing.T, + l zerolog.Logger, chainlinkNodes []*client.ChainlinkClient, registryConfig contracts.KeeperRegistrySettings, registrar string, deltaStage time.Duration, ) (contracts.OCRv2Config, error) { - return BuildAutoOCR2ConfigVarsWithKeyIndexLocal(t, chainlinkNodes, registryConfig, registrar, deltaStage, 0) + return BuildAutoOCR2ConfigVarsWithKeyIndexLocal(l, chainlinkNodes, registryConfig, registrar, deltaStage, 0) } func BuildAutoOCR2ConfigVarsWithKeyIndexLocal( - t *testing.T, + l zerolog.Logger, chainlinkNodes []*client.ChainlinkClient, registryConfig contracts.KeeperRegistrySettings, registrar string, deltaStage time.Duration, keyIndex int, ) (contracts.OCRv2Config, error) { - l := utils.GetTestLogger(t) S, oracleIdentities, err := GetOracleIdentitiesWithKeyIndexLocal(chainlinkNodes, keyIndex) if err != nil { return contracts.OCRv2Config{}, err @@ -136,13 +132,17 @@ func BuildAutoOCR2ConfigVarsWithKeyIndexLocal( var signers []common.Address for _, signer := range signerOnchainPublicKeys { - require.Equal(t, 20, len(signer), "OnChainPublicKey '%v' has wrong length for address", signer) + if len(signer) != 20 { + return contracts.OCRv2Config{}, fmt.Errorf("OnChainPublicKey '%v' has wrong length for address", signer) + } signers = append(signers, common.BytesToAddress(signer)) } var transmitters []common.Address for _, transmitter := range transmitterAccounts { - require.True(t, common.IsHexAddress(string(transmitter)), "TransmitAccount '%s' is not a valid Ethereum address", string(transmitter)) + if !common.IsHexAddress(string(transmitter)) { + return contracts.OCRv2Config{}, fmt.Errorf("TransmitAccount '%s' is not a valid Ethereum address", string(transmitter)) + } transmitters = append(transmitters, common.HexToAddress(string(transmitter))) } @@ -164,6 +164,7 @@ func BuildAutoOCR2ConfigVarsWithKeyIndexLocal( // CreateOCRKeeperJobs bootstraps the first node and to the other nodes sends ocr jobs func CreateOCRKeeperJobsLocal( + l zerolog.Logger, chainlinkNodes []*client.ChainlinkClient, registryAddr string, chainID int64, @@ -173,7 +174,7 @@ func CreateOCRKeeperJobsLocal( bootstrapNode := chainlinkNodes[0] bootstrapP2PIds, err := bootstrapNode.MustReadP2PKeys() if err != nil { - log.Error().Err(err).Msg("Shouldn't fail reading P2P keys from bootstrap node") + l.Error().Err(err).Msg("Shouldn't fail reading P2P keys from bootstrap node") return err } bootstrapP2PId := bootstrapP2PIds.Data[0].Attributes.PeerID @@ -201,7 +202,7 @@ func CreateOCRKeeperJobsLocal( } _, err = bootstrapNode.MustCreateJob(bootstrapSpec) if err != nil { - log.Error().Err(err).Msg("Shouldn't fail creating bootstrap job on bootstrap node") + l.Error().Err(err).Msg("Shouldn't fail creating bootstrap job on bootstrap node") return err } @@ -209,12 +210,12 @@ func CreateOCRKeeperJobsLocal( for nodeIndex := 1; nodeIndex < len(chainlinkNodes); nodeIndex++ { nodeTransmitterAddress, err := chainlinkNodes[nodeIndex].EthAddresses() if err != nil { - log.Error().Err(err).Msgf("Shouldn't fail getting primary ETH address from OCR node %d", nodeIndex+1) + l.Error().Err(err).Msgf("Shouldn't fail getting primary ETH address from OCR node %d", nodeIndex+1) return err } nodeOCRKeys, err := chainlinkNodes[nodeIndex].MustReadOCR2Keys() if err != nil { - log.Error().Err(err).Msgf("Shouldn't fail getting OCR keys from OCR node %d", nodeIndex+1) + l.Error().Err(err).Msgf("Shouldn't fail getting OCR keys from OCR node %d", nodeIndex+1) return err } var nodeOCRKeyId []string @@ -248,11 +249,11 @@ func CreateOCRKeeperJobsLocal( _, err = chainlinkNodes[nodeIndex].MustCreateJob(&autoOCR2JobSpec) if err != nil { - log.Error().Err(err).Msgf("Shouldn't fail creating OCR Task job on OCR node %d err: %+v", nodeIndex+1, err) + l.Error().Err(err).Msgf("Shouldn't fail creating OCR Task job on OCR node %d err: %+v", nodeIndex+1, err) return err } } - log.Info().Msg("Done creating OCR automation jobs") + l.Info().Msg("Done creating OCR automation jobs") return nil } diff --git a/integration-tests/actions/keeper_helpers.go b/integration-tests/actions/keeper_helpers.go index dfe2acbbed3..f824e75019d 100644 --- a/integration-tests/actions/keeper_helpers.go +++ b/integration-tests/actions/keeper_helpers.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" @@ -339,7 +339,7 @@ func RegisterUpkeepContracts(t *testing.T, linkToken contracts.LinkToken, linkFu } func RegisterUpkeepContractsWithCheckData(t *testing.T, linkToken contracts.LinkToken, linkFunds *big.Int, client blockchain.EVMClient, upkeepGasLimit uint32, registry contracts.KeeperRegistry, registrar contracts.KeeperRegistrar, numberOfContracts int, upkeepAddresses []string, checkData [][]byte, isLogTrigger bool) []*big.Int { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) registrationTxHashes := make([]common.Hash, 0) upkeepIds := make([]*big.Int, 0) for contractCount, upkeepAddress := range upkeepAddresses { @@ -398,7 +398,7 @@ func RegisterUpkeepContractsWithCheckData(t *testing.T, linkToken contracts.Link } func DeployKeeperConsumers(t *testing.T, contractDeployer contracts.ContractDeployer, client blockchain.EVMClient, numberOfContracts int, isLogTrigger bool) []contracts.KeeperConsumer { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) keeperConsumerContracts := make([]contracts.KeeperConsumer, 0) for contractCount := 0; contractCount < numberOfContracts; contractCount++ { @@ -441,7 +441,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 := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) upkeeps := make([]contracts.KeeperConsumerPerformance, 0) for contractCount := 0; contractCount < numberOfContracts; contractCount++ { @@ -478,7 +478,7 @@ func DeployPerformDataChecker( numberOfContracts int, expectedData []byte, ) []contracts.KeeperPerformDataChecker { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) upkeeps := make([]contracts.KeeperPerformDataChecker, 0) for contractCount := 0; contractCount < numberOfContracts; contractCount++ { @@ -510,7 +510,7 @@ func DeployUpkeepCounters( testRange *big.Int, interval *big.Int, ) []contracts.UpkeepCounter { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) upkeepCounters := make([]contracts.UpkeepCounter, 0) for contractCount := 0; contractCount < numberOfContracts; contractCount++ { @@ -543,7 +543,7 @@ func DeployUpkeepPerformCounterRestrictive( testRange *big.Int, averageEligibilityCadence *big.Int, ) []contracts.UpkeepPerformCounterRestrictive { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) upkeepCounters := make([]contracts.UpkeepPerformCounterRestrictive, 0) for contractCount := 0; contractCount < numberOfContracts; contractCount++ { diff --git a/integration-tests/actions/keeper_helpers_local.go b/integration-tests/actions/keeper_helpers_local.go index ade1ab7f1a3..d9d15b33a3e 100644 --- a/integration-tests/actions/keeper_helpers_local.go +++ b/integration-tests/actions/keeper_helpers_local.go @@ -3,13 +3,14 @@ package actions import ( "fmt" - "github.com/rs/zerolog/log" + "github.com/rs/zerolog" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" ) func CreateKeeperJobsLocal( + l zerolog.Logger, chainlinkNodes []*client.ChainlinkClient, keeperRegistry contracts.KeeperRegistry, ocrConfig contracts.OCRv2Config, @@ -19,12 +20,12 @@ func CreateKeeperJobsLocal( primaryNode := chainlinkNodes[0] primaryNodeAddress, err := primaryNode.PrimaryEthAddress() if err != nil { - log.Error().Err(err).Msg("Reading ETH Keys from Chainlink Client shouldn't fail") + l.Error().Err(err).Msg("Reading ETH Keys from Chainlink Client shouldn't fail") return nil, err } nodeAddresses, err := ChainlinkNodeAddressesLocal(chainlinkNodes) if err != nil { - log.Error().Err(err).Msg("Retrieving on-chain wallet addresses for chainlink nodes shouldn't fail") + l.Error().Err(err).Msg("Retrieving on-chain wallet addresses for chainlink nodes shouldn't fail") return nil, err } nodeAddressesStr, payees := make([]string, 0), make([]string, 0) @@ -34,14 +35,14 @@ func CreateKeeperJobsLocal( } err = keeperRegistry.SetKeepers(nodeAddressesStr, payees, ocrConfig) if err != nil { - log.Error().Err(err).Msg("Setting keepers in the registry shouldn't fail") + l.Error().Err(err).Msg("Setting keepers in the registry shouldn't fail") return nil, err } jobs := []*client.Job{} for _, chainlinkNode := range chainlinkNodes { chainlinkNodeAddress, err := chainlinkNode.PrimaryEthAddress() if err != nil { - log.Error().Err(err).Msg("Error retrieving chainlink node address") + l.Error().Err(err).Msg("Error retrieving chainlink node address") return nil, err } job, err := chainlinkNode.MustCreateJob(&client.KeeperJobSpec{ @@ -52,7 +53,7 @@ func CreateKeeperJobsLocal( MinIncomingConfirmations: 1, }) if err != nil { - log.Error().Err(err).Msg("Creating KeeperV2 Job shouldn't fail") + l.Error().Err(err).Msg("Creating KeeperV2 Job shouldn't fail") return nil, err } jobs = append(jobs, job) diff --git a/integration-tests/actions/ocr2_helpers.go b/integration-tests/actions/ocr2_helpers.go index 3c37233a0d3..293ea2b73c0 100644 --- a/integration-tests/actions/ocr2_helpers.go +++ b/integration-tests/actions/ocr2_helpers.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/lib/pq" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "golang.org/x/sync/errgroup" "gopkg.in/guregu/null.v4" @@ -360,13 +361,14 @@ func StartNewOCR2Round( ocrInstances []contracts.OffchainAggregatorV2, client blockchain.EVMClient, timeout time.Duration, + logger zerolog.Logger, ) error { for i := 0; i < len(ocrInstances); i++ { err := ocrInstances[i].RequestNewRound() if err != nil { return fmt.Errorf("requesting new OCR round %d have failed: %w", i+1, err) } - ocrRound := contracts.NewOffchainAggregatorV2RoundConfirmer(ocrInstances[i], big.NewInt(roundNumber), timeout) + ocrRound := contracts.NewOffchainAggregatorV2RoundConfirmer(ocrInstances[i], big.NewInt(roundNumber), timeout, logger) client.AddHeaderEventSubscription(ocrInstances[i].Address(), ocrRound) err = client.WaitForEvents() if err != nil { diff --git a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_config_helpers.go b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_config_helpers.go index 05b983c2f1e..ce693964323 100644 --- a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_config_helpers.go +++ b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_config_helpers.go @@ -16,7 +16,7 @@ import ( "go.dedis.ch/kyber/v3/group/edwards25519" "gopkg.in/guregu/null.v4" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "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/libocr/offchainreporting2plus/confighelper" @@ -39,7 +39,7 @@ func CreateOCR2VRFJobs( chainID int64, keyIndex int, ) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) p2pV2Bootstrapper := createBootstrapJob(t, bootstrapNode, OCR2VRFPluginConfig.DKGConfig.DKGContractAddress, chainID) createNonBootstrapJobs(t, nonBootstrapNodes, OCR2VRFPluginConfig, chainID, keyIndex, p2pV2Bootstrapper) @@ -120,7 +120,7 @@ func BuildOCR2DKGConfigVars( t *testing.T, ocr2VRFPluginConfig *OCR2VRFPluginConfig, ) contracts.OCRv2Config { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) var onchainPublicKeys []common.Address for _, onchainPublicKey := range ocr2VRFPluginConfig.OCR2Config.OnchainPublicKeys { onchainPublicKeys = append(onchainPublicKeys, common.HexToAddress(onchainPublicKey)) @@ -272,7 +272,7 @@ func BuildOCR2VRFConfigVars( t *testing.T, ocr2VRFPluginConfig *OCR2VRFPluginConfig, ) contracts.OCRv2Config { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) var onchainPublicKeys []common.Address for _, onchainPublicKey := range ocr2VRFPluginConfig.OCR2Config.OnchainPublicKeys { onchainPublicKeys = append(onchainPublicKeys, common.HexToAddress(onchainPublicKey)) diff --git a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go index c550fe73a22..c123aaff6a2 100644 --- a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go +++ b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go @@ -13,7 +13,7 @@ import ( ocr2vrftypes "github.com/smartcontractkit/ocr2vrf/types" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" chainlinkutils "github.com/smartcontractkit/chainlink/v2/core/utils" @@ -25,7 +25,7 @@ import ( ) func SetAndWaitForVRFBeaconProcessToFinish(t *testing.T, ocr2VRFPluginConfig *OCR2VRFPluginConfig, vrfBeacon contracts.VRFBeacon) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) ocr2VrfConfig := BuildOCR2VRFConfigVars(t, ocr2VRFPluginConfig) l.Debug().Interface("OCR2 VRF Config", ocr2VrfConfig).Msg("OCR2 VRF Config prepared") @@ -45,7 +45,7 @@ func SetAndWaitForVRFBeaconProcessToFinish(t *testing.T, ocr2VRFPluginConfig *OC } func SetAndWaitForDKGProcessToFinish(t *testing.T, ocr2VRFPluginConfig *OCR2VRFPluginConfig, dkg contracts.DKG) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) ocr2DkgConfig := BuildOCR2DKGConfigVars(t, ocr2VRFPluginConfig) // set config for DKG OCR @@ -208,7 +208,7 @@ func RequestAndRedeemRandomness( confirmationDelay *big.Int, randomnessTransmissionEventTimeout time.Duration, ) *big.Int { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) receipt, err := consumer.RequestRandomness( numberOfRandomWordsToRequest, subscriptionID, @@ -244,7 +244,7 @@ func RequestRandomnessFulfillmentAndWaitForFulfilment( confirmationDelay *big.Int, randomnessTransmissionEventTimeout time.Duration, ) *big.Int { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) receipt, err := consumer.RequestRandomnessFulfillment( numberOfRandomWordsToRequest, subscriptionID, diff --git a/integration-tests/actions/ocr_helpers.go b/integration-tests/actions/ocr_helpers.go index edef393027a..cfc8cfe589b 100644 --- a/integration-tests/actions/ocr_helpers.go +++ b/integration-tests/actions/ocr_helpers.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" + "github.com/rs/zerolog" "github.com/stretchr/testify/require" "golang.org/x/sync/errgroup" @@ -326,13 +327,14 @@ func StartNewRound( roundNumber int64, ocrInstances []contracts.OffchainAggregator, client blockchain.EVMClient, + logger zerolog.Logger, ) error { for i := 0; i < len(ocrInstances); i++ { err := ocrInstances[i].RequestNewRound() if err != nil { return fmt.Errorf("requesting new OCR round %d have failed: %w", i+1, err) } - ocrRound := contracts.NewOffchainAggregatorRoundConfirmer(ocrInstances[i], big.NewInt(roundNumber), client.GetNetworkConfig().Timeout.Duration) + ocrRound := contracts.NewOffchainAggregatorRoundConfirmer(ocrInstances[i], big.NewInt(roundNumber), client.GetNetworkConfig().Timeout.Duration, logger) client.AddHeaderEventSubscription(ocrInstances[i].Address(), ocrRound) err = client.WaitForEvents() if err != nil { diff --git a/integration-tests/actions/ocr_helpers_local.go b/integration-tests/actions/ocr_helpers_local.go index 33d6498b9e5..ae2f3686daf 100644 --- a/integration-tests/actions/ocr_helpers_local.go +++ b/integration-tests/actions/ocr_helpers_local.go @@ -9,7 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" "github.com/pkg/errors" - "github.com/rs/zerolog/log" + "github.com/rs/zerolog" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" "golang.org/x/sync/errgroup" @@ -271,13 +271,14 @@ func TrackForwarderLocal( chainClient blockchain.EVMClient, authorizedForwarder common.Address, node *client.ChainlinkClient, + logger zerolog.Logger, ) error { chainID := chainClient.GetChainID() _, _, err := node.TrackForwarder(chainID, authorizedForwarder) if err != nil { return errors.Wrap(err, "failed to track forwarder") } - log.Info().Str("NodeURL", node.Config.URL). + logger.Info().Str("NodeURL", node.Config.URL). Str("ForwarderAddress", authorizedForwarder.Hex()). Str("ChaindID", chainID.String()). Msg("Forwarder tracked") diff --git a/integration-tests/actions/operator_forwarder_helpers.go b/integration-tests/actions/operator_forwarder_helpers.go index 7add64fbe99..37b50c4fa9a 100644 --- a/integration-tests/actions/operator_forwarder_helpers.go +++ b/integration-tests/actions/operator_forwarder_helpers.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/operator_factory" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -91,7 +91,7 @@ func ProcessNewEvent( contractABI *abi.ABI, chainClient blockchain.EVMClient, ) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) errorChan := make(chan error) eventConfirmed := make(chan bool) err := chainClient.ProcessEvent(eventDetails.Name, event, eventConfirmed, errorChan) @@ -138,7 +138,7 @@ func SubscribeOperatorFactoryEvents( chainClient blockchain.EVMClient, operatorFactoryInstance contracts.OperatorFactory, ) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) contractABI, err := operator_factory.OperatorFactoryMetaData.GetAbi() require.NoError(t, err, "Getting contract abi for OperatorFactory shouldn't fail") latestBlockNum, err := chainClient.LatestBlockNumber(context.Background()) @@ -186,7 +186,7 @@ func TrackForwarder( authorizedForwarder common.Address, node *client.ChainlinkK8sClient, ) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainID := chainClient.GetChainID() _, _, err := node.TrackForwarder(chainID, authorizedForwarder) require.NoError(t, err, "Forwarder track should be created") diff --git a/integration-tests/benchmark/keeper_test.go b/integration-tests/benchmark/keeper_test.go index fbabfab78cc..59406e51583 100644 --- a/integration-tests/benchmark/keeper_test.go +++ b/integration-tests/benchmark/keeper_test.go @@ -18,8 +18,7 @@ import ( "github.com/smartcontractkit/chainlink-env/pkg/helm/ethereum" "github.com/smartcontractkit/chainlink-env/pkg/helm/reorg" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink/integration-tests/actions" @@ -142,7 +141,7 @@ type NetworkConfig struct { } func TestAutomationBenchmark(t *testing.T) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) testEnvironment, benchmarkNetwork := SetupAutomationBenchmarkEnv(t) if testEnvironment.WillUseRemoteRunner() { return @@ -154,7 +153,7 @@ func TestAutomationBenchmark(t *testing.T) { l.Info().Str("Namespace", testEnvironment.Cfg.Namespace).Msg("Connected to Keepers Benchmark Environment") - chainClient, err := blockchain.NewEVMClient(benchmarkNetwork, testEnvironment) + chainClient, err := blockchain.NewEVMClient(benchmarkNetwork, testEnvironment, l) require.NoError(t, err, "Error connecting to blockchain") registryVersions := addRegistry(RegistryToTest) keeperBenchmarkTest := testsetups.NewKeeperBenchmarkTest( @@ -299,7 +298,7 @@ func getEnv(key, fallback string) string { } func SetupAutomationBenchmarkEnv(t *testing.T) (*environment.Environment, blockchain.EVMNetwork) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) testNetwork := networks.SelectedNetwork // Environment currently being used to run benchmark test on blockTime := "1" networkDetailTOML := `MinIncomingConfirmations = 1` diff --git a/integration-tests/chaos/automation_chaos_test.go b/integration-tests/chaos/automation_chaos_test.go index bb7fe1b8f00..1b18b9f6ab7 100644 --- a/integration-tests/chaos/automation_chaos_test.go +++ b/integration-tests/chaos/automation_chaos_test.go @@ -18,9 +18,9 @@ import ( "github.com/smartcontractkit/chainlink-env/pkg/helm/chainlink" "github.com/smartcontractkit/chainlink-env/pkg/helm/ethereum" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" + "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -109,7 +109,7 @@ const ( func TestAutomationChaos(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) testCases := map[string]struct { networkChart environment.ConnectedChart @@ -201,10 +201,11 @@ func TestAutomationChaos(t *testing.T) { err = testEnvironment.Client.LabelChaosGroup(testEnvironment.Cfg.Namespace, "instance=", 2, 5, ChaosGroupMajorityPlus) require.NoError(t, err) - chainClient, err := blockchain.NewEVMClient(network, testEnvironment) + chainClient, err := blockchain.NewEVMClient(network, testEnvironment, l) require.NoError(t, err, "Error connecting to blockchain") - contractDeployer, err := contracts.NewContractDeployer(chainClient) + contractDeployer, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Error building contract deployer") + chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) require.NoError(t, err, "Error connecting to Chainlink nodes") chainClient.ParallelTransactions(true) diff --git a/integration-tests/chaos/ocr2vrf_chaos_test.go b/integration-tests/chaos/ocr2vrf_chaos_test.go index 91c9084d408..fd51fa55db5 100644 --- a/integration-tests/chaos/ocr2vrf_chaos_test.go +++ b/integration-tests/chaos/ocr2vrf_chaos_test.go @@ -16,9 +16,9 @@ import ( "github.com/smartcontractkit/chainlink-env/pkg/helm/chainlink" "github.com/smartcontractkit/chainlink-env/pkg/helm/ethereum" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" + "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/actions/ocr2vrf_actions" @@ -30,7 +30,7 @@ import ( func TestOCR2VRFChaos(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) loadedNetwork := networks.SelectedNetwork defaultOCR2VRFSettings := map[string]interface{}{ @@ -140,9 +140,9 @@ func TestOCR2VRFChaos(t *testing.T) { err = testEnvironment.Client.LabelChaosGroup(testEnvironment.Cfg.Namespace, "instance=", 3, 5, ChaosGroupMajority) require.NoError(t, err) - chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment) + chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment, l) require.NoError(t, err, "Error connecting to blockchain") - contractDeployer, err := contracts.NewContractDeployer(chainClient) + contractDeployer, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Error building contract deployer") chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) require.NoError(t, err, "Error connecting to Chainlink nodes") diff --git a/integration-tests/chaos/ocr_chaos_test.go b/integration-tests/chaos/ocr_chaos_test.go index d765cafb9e6..569a0d1b70c 100644 --- a/integration-tests/chaos/ocr_chaos_test.go +++ b/integration-tests/chaos/ocr_chaos_test.go @@ -20,9 +20,9 @@ import ( mockservercfg "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" - "github.com/smartcontractkit/chainlink-testing-framework/utils" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" + "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -59,7 +59,7 @@ func TestMain(m *testing.M) { func TestOCRChaos(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) testCases := map[string]struct { networkChart environment.ConnectedChart clChart environment.ConnectedChart @@ -153,9 +153,9 @@ func TestOCRChaos(t *testing.T) { err = testEnvironment.Client.LabelChaosGroup(testEnvironment.Cfg.Namespace, "instance=", 2, 5, ChaosGroupMajorityPlus) require.NoError(t, err) - chainClient, err := blockchain.NewEVMClient(blockchain.SimulatedEVMNetwork, testEnvironment) + chainClient, err := blockchain.NewEVMClient(blockchain.SimulatedEVMNetwork, testEnvironment, l) require.NoError(t, err, "Connecting to blockchain nodes shouldn't fail") - cd, err := contracts.NewContractDeployer(chainClient) + cd, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Deploying contracts shouldn't fail") chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) diff --git a/integration-tests/client/chainlink.go b/integration-tests/client/chainlink.go index 7d3bd0284d0..8a79cb3ec95 100644 --- a/integration-tests/client/chainlink.go +++ b/integration-tests/client/chainlink.go @@ -9,11 +9,13 @@ import ( "sync" "time" + "os" + "github.com/ethereum/go-ethereum/common" "github.com/go-resty/resty/v2" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "golang.org/x/sync/errgroup" - "os" ) const ( @@ -39,10 +41,11 @@ type ChainlinkClient struct { pageSize int primaryEthAddress string ethAddresses []string + l zerolog.Logger } // NewChainlinkClient creates a new Chainlink model using a provided config -func NewChainlinkClient(c *ChainlinkConfig) (*ChainlinkClient, error) { +func NewChainlinkClient(c *ChainlinkConfig, logger zerolog.Logger) (*ChainlinkClient, error) { rc, err := initRestyClient(c.URL, c.Email, c.Password, c.HTTPTimeout) if err != nil { return nil, err @@ -55,6 +58,7 @@ func NewChainlinkClient(c *ChainlinkConfig) (*ChainlinkClient, error) { Config: c, APIClient: rc, pageSize: 25, + l: logger, }, nil } @@ -92,8 +96,8 @@ func (c *ChainlinkClient) URL() string { // CreateJobRaw creates a Chainlink job based on the provided spec string func (c *ChainlinkClient) CreateJobRaw(spec string) (*Job, *http.Response, error) { job := &Job{} - log.Info().Str("Node URL", c.Config.URL).Msg("Creating Job") - log.Trace().Str("Node URL", c.Config.URL).Str("Job Body", spec).Msg("Creating Job") + c.l.Info().Str("Node URL", c.Config.URL).Msg("Creating Job") + c.l.Trace().Str("Node URL", c.Config.URL).Str("Job Body", spec).Msg("Creating Job") resp, err := c.APIClient.R(). SetBody(&JobForm{ TOML: spec, @@ -123,8 +127,8 @@ func (c *ChainlinkClient) CreateJob(spec JobSpec) (*Job, *http.Response, error) if err != nil { return nil, nil, err } - log.Info().Str("Node URL", c.Config.URL).Str("Type", spec.Type()).Msg("Creating Job") - log.Trace().Str("Node URL", c.Config.URL).Str("Type", spec.Type()).Str("Spec", specString).Msg("Creating Job") + c.l.Info().Str("Node URL", c.Config.URL).Str("Type", spec.Type()).Msg("Creating Job") + c.l.Trace().Str("Node URL", c.Config.URL).Str("Type", spec.Type()).Str("Spec", specString).Msg("Creating Job") resp, err := c.APIClient.R(). SetBody(&JobForm{ TOML: specString, @@ -140,7 +144,7 @@ func (c *ChainlinkClient) CreateJob(spec JobSpec) (*Job, *http.Response, error) // ReadJobs reads all jobs from the Chainlink node func (c *ChainlinkClient) ReadJobs() (*ResponseSlice, *http.Response, error) { specObj := &ResponseSlice{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Getting Jobs") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Getting Jobs") resp, err := c.APIClient.R(). SetResult(&specObj). Get("/v2/jobs") @@ -153,7 +157,7 @@ func (c *ChainlinkClient) ReadJobs() (*ResponseSlice, *http.Response, error) { // ReadJob reads a job with the provided ID from the Chainlink node func (c *ChainlinkClient) ReadJob(id string) (*Response, *http.Response, error) { specObj := &Response{} - log.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Reading Job") + c.l.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Reading Job") resp, err := c.APIClient.R(). SetResult(&specObj). SetPathParams(map[string]string{ @@ -178,7 +182,7 @@ func (c *ChainlinkClient) MustDeleteJob(id string) error { // DeleteJob deletes a job with a provided ID from the Chainlink node func (c *ChainlinkClient) DeleteJob(id string) (*http.Response, error) { - log.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Deleting Job") + c.l.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Deleting Job") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "id": id, @@ -194,7 +198,7 @@ func (c *ChainlinkClient) DeleteJob(id string) (*http.Response, error) { func (c *ChainlinkClient) CreateSpec(spec string) (*Spec, *http.Response, error) { s := &Spec{} r := strings.NewReplacer("\n", "", " ", "", "\\", "") // Makes it more compact and readable for logging - log.Info().Str(NodeURL, c.Config.URL).Str("Spec", r.Replace(spec)).Msg("Creating Spec") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Spec", r.Replace(spec)).Msg("Creating Spec") resp, err := c.APIClient.R(). SetBody([]byte(spec)). SetResult(&s). @@ -208,7 +212,7 @@ func (c *ChainlinkClient) CreateSpec(spec string) (*Spec, *http.Response, error) // ReadSpec reads a job spec with the provided ID on the Chainlink node func (c *ChainlinkClient) ReadSpec(id string) (*Response, *http.Response, error) { specObj := &Response{} - log.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Reading Spec") + c.l.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Reading Spec") resp, err := c.APIClient.R(). SetResult(&specObj). SetPathParams(map[string]string{ @@ -234,7 +238,7 @@ func (c *ChainlinkClient) MustReadRunsByJob(jobID string) (*JobRunsResponse, err // ReadRunsByJob reads all runs for a job func (c *ChainlinkClient) ReadRunsByJob(jobID string) (*JobRunsResponse, *http.Response, error) { runsObj := &JobRunsResponse{} - log.Debug().Str(NodeURL, c.Config.URL).Str("JobID", jobID).Msg("Reading runs for a job") + c.l.Debug().Str(NodeURL, c.Config.URL).Str("JobID", jobID).Msg("Reading runs for a job") resp, err := c.APIClient.R(). SetResult(&runsObj). SetPathParams(map[string]string{ @@ -249,7 +253,7 @@ func (c *ChainlinkClient) ReadRunsByJob(jobID string) (*JobRunsResponse, *http.R // DeleteSpec deletes a job spec with the provided ID from the Chainlink node func (c *ChainlinkClient) DeleteSpec(id string) (*http.Response, error) { - log.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Deleting Spec") + c.l.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Deleting Spec") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "id": id, @@ -272,7 +276,7 @@ func (c *ChainlinkClient) MustCreateBridge(bta *BridgeTypeAttributes) error { } func (c *ChainlinkClient) CreateBridge(bta *BridgeTypeAttributes) (*http.Response, error) { - log.Info().Str(NodeURL, c.Config.URL).Str("Name", bta.Name).Msg("Creating Bridge") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Name", bta.Name).Msg("Creating Bridge") resp, err := c.APIClient.R(). SetBody(bta). Post("/v2/bridge_types") @@ -285,7 +289,7 @@ func (c *ChainlinkClient) CreateBridge(bta *BridgeTypeAttributes) (*http.Respons // ReadBridge reads a bridge from the Chainlink node based on the provided name func (c *ChainlinkClient) ReadBridge(name string) (*BridgeType, *http.Response, error) { bt := BridgeType{} - log.Info().Str(NodeURL, c.Config.URL).Str("Name", name).Msg("Reading Bridge") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Name", name).Msg("Reading Bridge") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "name": name, @@ -300,7 +304,7 @@ func (c *ChainlinkClient) ReadBridge(name string) (*BridgeType, *http.Response, // DeleteBridge deletes a bridge on the Chainlink node based on the provided name func (c *ChainlinkClient) DeleteBridge(name string) (*http.Response, error) { - log.Info().Str(NodeURL, c.Config.URL).Str("Name", name).Msg("Deleting Bridge") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Name", name).Msg("Deleting Bridge") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "name": name, @@ -315,7 +319,7 @@ func (c *ChainlinkClient) DeleteBridge(name string) (*http.Response, error) { // CreateOCRKey creates an OCRKey on the Chainlink node func (c *ChainlinkClient) CreateOCRKey() (*OCRKey, *http.Response, error) { ocrKey := &OCRKey{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Creating OCR Key") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Creating OCR Key") resp, err := c.APIClient.R(). SetResult(ocrKey). Post("/v2/keys/ocr") @@ -329,7 +333,7 @@ func (c *ChainlinkClient) CreateOCRKey() (*OCRKey, *http.Response, error) { // the request is unsuccessful func (c *ChainlinkClient) MustReadOCRKeys() (*OCRKeys, error) { ocrKeys := &OCRKeys{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading OCR Keys") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading OCR Keys") resp, err := c.APIClient.R(). SetResult(ocrKeys). Get("/v2/keys/ocr") @@ -350,7 +354,7 @@ func (c *ChainlinkClient) MustReadOCRKeys() (*OCRKeys, error) { // DeleteOCRKey deletes an OCRKey based on the provided ID func (c *ChainlinkClient) DeleteOCRKey(id string) (*http.Response, error) { - log.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Deleting OCR Key") + c.l.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Deleting OCR Key") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "id": id, @@ -365,7 +369,7 @@ func (c *ChainlinkClient) DeleteOCRKey(id string) (*http.Response, error) { // CreateOCR2Key creates an OCR2Key on the Chainlink node func (c *ChainlinkClient) CreateOCR2Key(chain string) (*OCR2Key, *http.Response, error) { ocr2Key := &OCR2Key{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Creating OCR2 Key") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Creating OCR2 Key") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "chain": chain, @@ -381,7 +385,7 @@ func (c *ChainlinkClient) CreateOCR2Key(chain string) (*OCR2Key, *http.Response, // ReadOCR2Keys reads all OCR2Keys from the Chainlink node func (c *ChainlinkClient) ReadOCR2Keys() (*OCR2Keys, *http.Response, error) { ocr2Keys := &OCR2Keys{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading OCR2 Keys") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading OCR2 Keys") resp, err := c.APIClient.R(). SetResult(ocr2Keys). Get("/v2/keys/ocr2") @@ -391,7 +395,7 @@ func (c *ChainlinkClient) ReadOCR2Keys() (*OCR2Keys, *http.Response, error) { // MustReadOCR2Keys reads all OCR2Keys from the Chainlink node returns err if response not 200 func (c *ChainlinkClient) MustReadOCR2Keys() (*OCR2Keys, error) { ocr2Keys := &OCR2Keys{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading OCR2 Keys") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading OCR2 Keys") resp, err := c.APIClient.R(). SetResult(ocr2Keys). Get("/v2/keys/ocr2") @@ -404,7 +408,7 @@ func (c *ChainlinkClient) MustReadOCR2Keys() (*OCR2Keys, error) { // DeleteOCR2Key deletes an OCR2Key based on the provided ID func (c *ChainlinkClient) DeleteOCR2Key(id string) (*http.Response, error) { - log.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Deleting OCR2 Key") + c.l.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Deleting OCR2 Key") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "id": id, @@ -419,7 +423,7 @@ func (c *ChainlinkClient) DeleteOCR2Key(id string) (*http.Response, error) { // CreateP2PKey creates an P2PKey on the Chainlink node func (c *ChainlinkClient) CreateP2PKey() (*P2PKey, *http.Response, error) { p2pKey := &P2PKey{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Creating P2P Key") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Creating P2P Key") resp, err := c.APIClient.R(). SetResult(p2pKey). Post("/v2/keys/p2p") @@ -433,7 +437,7 @@ func (c *ChainlinkClient) CreateP2PKey() (*P2PKey, *http.Response, error) { // the request is unsuccessful func (c *ChainlinkClient) MustReadP2PKeys() (*P2PKeys, error) { p2pKeys := &P2PKeys{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading P2P Keys") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading P2P Keys") resp, err := c.APIClient.R(). SetResult(p2pKeys). Get("/v2/keys/p2p") @@ -443,7 +447,7 @@ func (c *ChainlinkClient) MustReadP2PKeys() (*P2PKeys, error) { err = VerifyStatusCode(resp.StatusCode(), http.StatusOK) if len(p2pKeys.Data) == 0 { err = fmt.Errorf("Found no P2P Keys on the Chainlink node. Node URL: %s", c.Config.URL) - log.Err(err).Msg("Error getting P2P keys") + c.l.Err(err).Msg("Error getting P2P keys") return nil, err } for index := range p2pKeys.Data { @@ -454,7 +458,7 @@ func (c *ChainlinkClient) MustReadP2PKeys() (*P2PKeys, error) { // DeleteP2PKey deletes a P2PKey on the Chainlink node based on the provided ID func (c *ChainlinkClient) DeleteP2PKey(id int) (*http.Response, error) { - log.Info().Str(NodeURL, c.Config.URL).Int("ID", id).Msg("Deleting P2P Key") + c.l.Info().Str(NodeURL, c.Config.URL).Int("ID", id).Msg("Deleting P2P Key") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "id": fmt.Sprint(id), @@ -470,7 +474,7 @@ func (c *ChainlinkClient) DeleteP2PKey(id int) (*http.Response, error) { // the request is unsuccessful func (c *ChainlinkClient) MustReadETHKeys() (*ETHKeys, error) { ethKeys := ÐKeys{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading ETH Keys") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading ETH Keys") resp, err := c.APIClient.R(). SetResult(ethKeys). Get("/v2/keys/eth") @@ -479,7 +483,7 @@ func (c *ChainlinkClient) MustReadETHKeys() (*ETHKeys, error) { } err = VerifyStatusCode(resp.StatusCode(), http.StatusOK) if len(ethKeys.Data) == 0 { - log.Warn().Str(NodeURL, c.Config.URL).Msg("Found no ETH Keys on the node") + c.l.Warn().Str(NodeURL, c.Config.URL).Msg("Found no ETH Keys on the node") } return ethKeys, err } @@ -487,7 +491,7 @@ func (c *ChainlinkClient) MustReadETHKeys() (*ETHKeys, error) { // UpdateEthKeyMaxGasPriceGWei updates the maxGasPriceGWei for an eth key func (c *ChainlinkClient) UpdateEthKeyMaxGasPriceGWei(keyId string, gWei int) (*ETHKey, *http.Response, error) { ethKey := ÐKey{} - log.Info().Str(NodeURL, c.Config.URL).Str("ID", keyId).Int("maxGasPriceGWei", gWei).Msg("Update maxGasPriceGWei for eth key") + c.l.Info().Str(NodeURL, c.Config.URL).Str("ID", keyId).Int("maxGasPriceGWei", gWei).Msg("Update maxGasPriceGWei for eth key") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "keyId": keyId, @@ -608,7 +612,7 @@ func (c *ChainlinkClient) ExportEVMKeys() ([]*ExportedEVMKey, error) { exportedKeys = append(exportedKeys, exportedKey) } } - log.Info(). + c.l.Info(). Str(NodeURL, c.Config.URL). Str("Password", ChainlinkKeyPassword). Msg("Exported EVM Keys") @@ -636,7 +640,7 @@ func (c *ChainlinkClient) ExportEVMKeysForChain(chainid string) ([]*ExportedEVMK exportedKeys = append(exportedKeys, exportedKey) } } - log.Info(). + c.l.Info(). Str(NodeURL, c.Config.URL). Str("Password", ChainlinkKeyPassword). Msg("Exported EVM Keys") @@ -646,7 +650,7 @@ func (c *ChainlinkClient) ExportEVMKeysForChain(chainid string) ([]*ExportedEVMK // CreateTxKey creates a tx key on the Chainlink node func (c *ChainlinkClient) CreateTxKey(chain string, chainId string) (*TxKey, *http.Response, error) { txKey := &TxKey{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Creating Tx Key") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Creating Tx Key") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "chain": chain, @@ -663,7 +667,7 @@ func (c *ChainlinkClient) CreateTxKey(chain string, chainId string) (*TxKey, *ht // ReadTxKeys reads all tx keys from the Chainlink node func (c *ChainlinkClient) ReadTxKeys(chain string) (*TxKeys, *http.Response, error) { txKeys := &TxKeys{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading Tx Keys") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading Tx Keys") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "chain": chain, @@ -678,7 +682,7 @@ func (c *ChainlinkClient) ReadTxKeys(chain string) (*TxKeys, *http.Response, err // DeleteTxKey deletes an tx key based on the provided ID func (c *ChainlinkClient) DeleteTxKey(chain string, id string) (*http.Response, error) { - log.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Deleting Tx Key") + c.l.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Deleting Tx Key") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "chain": chain, @@ -695,7 +699,7 @@ func (c *ChainlinkClient) DeleteTxKey(chain string, id string) (*http.Response, // and returns error if the request is unsuccessful func (c *ChainlinkClient) MustReadTransactionAttempts() (*TransactionsData, error) { txsData := &TransactionsData{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading Transaction Attempts") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading Transaction Attempts") resp, err := c.APIClient.R(). SetResult(txsData). Get("/v2/tx_attempts") @@ -709,7 +713,7 @@ func (c *ChainlinkClient) MustReadTransactionAttempts() (*TransactionsData, erro // ReadTransactions reads all transactions made by the Chainlink node func (c *ChainlinkClient) ReadTransactions() (*TransactionsData, *http.Response, error) { txsData := &TransactionsData{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading Transactions") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading Transactions") resp, err := c.APIClient.R(). SetResult(txsData). Get("/v2/transactions") @@ -735,7 +739,7 @@ func (c *ChainlinkClient) MustSendNativeToken(amount *big.Int, fromAddress, toAd SetResult(txData). Post("/v2/transfers") - log.Info(). + c.l.Info(). Str(NodeURL, c.Config.URL). Str("From", fromAddress). Str("To", toAddress). @@ -751,7 +755,7 @@ func (c *ChainlinkClient) MustSendNativeToken(amount *big.Int, fromAddress, toAd // ReadVRFKeys reads all VRF keys from the Chainlink node func (c *ChainlinkClient) ReadVRFKeys() (*VRFKeys, *http.Response, error) { vrfKeys := &VRFKeys{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading VRF Keys") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading VRF Keys") resp, err := c.APIClient.R(). SetResult(vrfKeys). Get("/v2/keys/vrf") @@ -759,7 +763,7 @@ func (c *ChainlinkClient) ReadVRFKeys() (*VRFKeys, *http.Response, error) { return nil, nil, err } if len(vrfKeys.Data) == 0 { - log.Warn().Str(NodeURL, c.Config.URL).Msg("Found no VRF Keys on the node") + c.l.Warn().Str(NodeURL, c.Config.URL).Msg("Found no VRF Keys on the node") } return vrfKeys, resp.RawResponse, err } @@ -768,7 +772,7 @@ func (c *ChainlinkClient) ReadVRFKeys() (*VRFKeys, *http.Response, error) { // and returns error if the request is unsuccessful func (c *ChainlinkClient) MustCreateVRFKey() (*VRFKey, error) { vrfKey := &VRFKey{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Creating VRF Key") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Creating VRF Key") resp, err := c.APIClient.R(). SetResult(vrfKey). Post("/v2/keys/vrf") @@ -781,7 +785,7 @@ func (c *ChainlinkClient) MustCreateVRFKey() (*VRFKey, error) { // ExportVRFKey exports a vrf key by key id func (c *ChainlinkClient) ExportVRFKey(keyId string) (*VRFExportKey, *http.Response, error) { vrfExportKey := &VRFExportKey{} - log.Info().Str(NodeURL, c.Config.URL).Str("ID", keyId).Msg("Exporting VRF Key") + c.l.Info().Str(NodeURL, c.Config.URL).Str("ID", keyId).Msg("Exporting VRF Key") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "keyId": keyId, @@ -797,7 +801,7 @@ func (c *ChainlinkClient) ExportVRFKey(keyId string) (*VRFExportKey, *http.Respo // ImportVRFKey import vrf key func (c *ChainlinkClient) ImportVRFKey(vrfExportKey *VRFExportKey) (*VRFKey, *http.Response, error) { vrfKey := &VRFKey{} - log.Info().Str(NodeURL, c.Config.URL).Str("ID", vrfExportKey.VrfKey.Address).Msg("Importing VRF Key") + c.l.Info().Str(NodeURL, c.Config.URL).Str("ID", vrfExportKey.VrfKey.Address).Msg("Importing VRF Key") resp, err := c.APIClient.R(). SetBody(vrfExportKey). SetResult(vrfKey). @@ -812,7 +816,7 @@ func (c *ChainlinkClient) ImportVRFKey(vrfExportKey *VRFExportKey) (*VRFKey, *ht // and returns error if the request is unsuccessful func (c *ChainlinkClient) MustCreateDkgSignKey() (*DKGSignKey, error) { dkgSignKey := &DKGSignKey{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Creating DKG Sign Key") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Creating DKG Sign Key") resp, err := c.APIClient.R(). SetResult(dkgSignKey). Post("/v2/keys/dkgsign") @@ -826,7 +830,7 @@ func (c *ChainlinkClient) MustCreateDkgSignKey() (*DKGSignKey, error) { // and returns error if the request is unsuccessful func (c *ChainlinkClient) MustCreateDkgEncryptKey() (*DKGEncryptKey, error) { dkgEncryptKey := &DKGEncryptKey{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Creating DKG Encrypt Key") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Creating DKG Encrypt Key") resp, err := c.APIClient.R(). SetResult(dkgEncryptKey). Post("/v2/keys/dkgencrypt") @@ -839,7 +843,7 @@ func (c *ChainlinkClient) MustCreateDkgEncryptKey() (*DKGEncryptKey, error) { // MustReadDKGSignKeys reads all DKG Sign Keys from the Chainlink node returns err if response not 200 func (c *ChainlinkClient) MustReadDKGSignKeys() (*DKGSignKeys, error) { dkgSignKeys := &DKGSignKeys{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading DKG Sign Keys") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading DKG Sign Keys") resp, err := c.APIClient.R(). SetResult(dkgSignKeys). Get("/v2/keys/dkgsign") @@ -853,7 +857,7 @@ func (c *ChainlinkClient) MustReadDKGSignKeys() (*DKGSignKeys, error) { // MustReadDKGEncryptKeys reads all DKG Encrypt Keys from the Chainlink node returns err if response not 200 func (c *ChainlinkClient) MustReadDKGEncryptKeys() (*DKGEncryptKeys, error) { dkgEncryptKeys := &DKGEncryptKeys{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading DKG Encrypt Keys") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading DKG Encrypt Keys") resp, err := c.APIClient.R(). SetResult(dkgEncryptKeys). Get("/v2/keys/dkgencrypt") @@ -867,7 +871,7 @@ func (c *ChainlinkClient) MustReadDKGEncryptKeys() (*DKGEncryptKeys, error) { // CreateCSAKey creates a CSA key on the Chainlink node, only 1 CSA key per noe func (c *ChainlinkClient) CreateCSAKey() (*CSAKey, *http.Response, error) { csaKey := &CSAKey{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Creating CSA Key") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Creating CSA Key") resp, err := c.APIClient.R(). SetResult(csaKey). Post("/v2/keys/csa") @@ -880,12 +884,12 @@ func (c *ChainlinkClient) CreateCSAKey() (*CSAKey, *http.Response, error) { // ReadCSAKeys reads CSA keys from the Chainlink node func (c *ChainlinkClient) ReadCSAKeys() (*CSAKeys, *http.Response, error) { csaKeys := &CSAKeys{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading CSA Keys") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading CSA Keys") resp, err := c.APIClient.R(). SetResult(csaKeys). Get("/v2/keys/csa") if len(csaKeys.Data) == 0 { - log.Warn().Str(NodeURL, c.Config.URL).Msg("Found no CSA Keys on the node") + c.l.Warn().Str(NodeURL, c.Config.URL).Msg("Found no CSA Keys on the node") } if err != nil { return nil, nil, err @@ -896,7 +900,7 @@ func (c *ChainlinkClient) ReadCSAKeys() (*CSAKeys, *http.Response, error) { // CreateEI creates an EI on the Chainlink node based on the provided attributes and returns the respective secrets func (c *ChainlinkClient) CreateEI(eia *EIAttributes) (*EIKeyCreate, *http.Response, error) { ei := EIKeyCreate{} - log.Info().Str(NodeURL, c.Config.URL).Str("Name", eia.Name).Msg("Creating External Initiator") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Name", eia.Name).Msg("Creating External Initiator") resp, err := c.APIClient.R(). SetBody(eia). SetResult(&ei). @@ -910,7 +914,7 @@ func (c *ChainlinkClient) CreateEI(eia *EIAttributes) (*EIKeyCreate, *http.Respo // ReadEIs reads all of the configured EIs from the Chainlink node func (c *ChainlinkClient) ReadEIs() (*EIKeys, *http.Response, error) { ei := EIKeys{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading EI Keys") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading EI Keys") resp, err := c.APIClient.R(). SetResult(&ei). Get("/v2/external_initiators") @@ -922,7 +926,7 @@ func (c *ChainlinkClient) ReadEIs() (*EIKeys, *http.Response, error) { // DeleteEI deletes an external initiator in the Chainlink node based on the provided name func (c *ChainlinkClient) DeleteEI(name string) (*http.Response, error) { - log.Info().Str(NodeURL, c.Config.URL).Str("Name", name).Msg("Deleting EI") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Name", name).Msg("Deleting EI") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ "name": name, @@ -937,7 +941,7 @@ func (c *ChainlinkClient) DeleteEI(name string) (*http.Response, error) { // CreateCosmosChain creates a cosmos chain func (c *ChainlinkClient) CreateCosmosChain(chain *CosmosChainAttributes) (*CosmosChainCreate, *http.Response, error) { response := CosmosChainCreate{} - log.Info().Str(NodeURL, c.Config.URL).Str("Chain ID", chain.ChainID).Msg("Creating Cosmos Chain") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Chain ID", chain.ChainID).Msg("Creating Cosmos Chain") resp, err := c.APIClient.R(). SetBody(chain). SetResult(&response). @@ -951,7 +955,7 @@ func (c *ChainlinkClient) CreateCosmosChain(chain *CosmosChainAttributes) (*Cosm // CreateCosmosNode creates a cosmos node func (c *ChainlinkClient) CreateCosmosNode(node *CosmosNodeAttributes) (*CosmosNodeCreate, *http.Response, error) { response := CosmosNodeCreate{} - log.Info().Str(NodeURL, c.Config.URL).Str("Name", node.Name).Msg("Creating Cosmos Node") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Name", node.Name).Msg("Creating Cosmos Node") resp, err := c.APIClient.R(). SetBody(node). SetResult(&response). @@ -965,7 +969,7 @@ func (c *ChainlinkClient) CreateCosmosNode(node *CosmosNodeAttributes) (*CosmosN // CreateSolanaChain creates a solana chain func (c *ChainlinkClient) CreateSolanaChain(chain *SolanaChainAttributes) (*SolanaChainCreate, *http.Response, error) { response := SolanaChainCreate{} - log.Info().Str(NodeURL, c.Config.URL).Str("Chain ID", chain.ChainID).Msg("Creating Solana Chain") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Chain ID", chain.ChainID).Msg("Creating Solana Chain") resp, err := c.APIClient.R(). SetBody(chain). SetResult(&response). @@ -979,7 +983,7 @@ func (c *ChainlinkClient) CreateSolanaChain(chain *SolanaChainAttributes) (*Sola // CreateSolanaNode creates a solana node func (c *ChainlinkClient) CreateSolanaNode(node *SolanaNodeAttributes) (*SolanaNodeCreate, *http.Response, error) { response := SolanaNodeCreate{} - log.Info().Str(NodeURL, c.Config.URL).Str("Name", node.Name).Msg("Creating Solana Node") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Name", node.Name).Msg("Creating Solana Node") resp, err := c.APIClient.R(). SetBody(node). SetResult(&response). @@ -993,7 +997,7 @@ func (c *ChainlinkClient) CreateSolanaNode(node *SolanaNodeAttributes) (*SolanaN // CreateStarkNetChain creates a starknet chain func (c *ChainlinkClient) CreateStarkNetChain(chain *StarkNetChainAttributes) (*StarkNetChainCreate, *http.Response, error) { response := StarkNetChainCreate{} - log.Info().Str(NodeURL, c.Config.URL).Str("Chain ID", chain.ChainID).Msg("Creating StarkNet Chain") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Chain ID", chain.ChainID).Msg("Creating StarkNet Chain") resp, err := c.APIClient.R(). SetBody(chain). SetResult(&response). @@ -1007,7 +1011,7 @@ func (c *ChainlinkClient) CreateStarkNetChain(chain *StarkNetChainAttributes) (* // CreateStarkNetNode creates a starknet node func (c *ChainlinkClient) CreateStarkNetNode(node *StarkNetNodeAttributes) (*StarkNetNodeCreate, *http.Response, error) { response := StarkNetNodeCreate{} - log.Info().Str(NodeURL, c.Config.URL).Str("Name", node.Name).Msg("Creating StarkNet Node") + c.l.Info().Str(NodeURL, c.Config.URL).Str("Name", node.Name).Msg("Creating StarkNet Node") resp, err := c.APIClient.R(). SetBody(node). SetResult(&response). @@ -1030,14 +1034,14 @@ func (c *ChainlinkClient) Profile(profileTime time.Duration, profileFunction fun profileResults := NewBlankChainlinkProfileResults() profileErrorGroup := new(errgroup.Group) var profileExecutedGroup sync.WaitGroup - log.Info().Int("Seconds to Profile", profileSeconds).Str(NodeURL, c.Config.URL).Msg("Starting Node PPROF session") + c.l.Info().Int("Seconds to Profile", profileSeconds).Str(NodeURL, c.Config.URL).Msg("Starting Node PPROF session") for _, rep := range profileResults.Reports { profileExecutedGroup.Add(1) profileReport := rep // The profile function returns with the profile results after the profile time frame has concluded // e.g. a profile API call of 5 seconds will start profiling, wait for 5 seconds, then send back results profileErrorGroup.Go(func() error { - log.Debug().Str("Type", profileReport.Type).Msg("PROFILING") + c.l.Debug().Str("Type", profileReport.Type).Msg("PROFILING") profileExecutedGroup.Done() resp, err := c.APIClient.R(). SetPathParams(map[string]string{ @@ -1054,7 +1058,7 @@ func (c *ChainlinkClient) Profile(profileTime time.Duration, profileFunction fun if err != nil { return err } - log.Debug().Str("Type", profileReport.Type).Msg("DONE PROFILING") + c.l.Debug().Str("Type", profileReport.Type).Msg("DONE PROFILING") profileReport.Data = resp.Body() return err }) @@ -1070,12 +1074,12 @@ func (c *ChainlinkClient) Profile(profileTime time.Duration, profileFunction fun actualSeconds := int(actualRunTime.Seconds()) if actualSeconds > profileSeconds { - log.Warn(). + c.l.Warn(). Int("Actual Seconds", actualSeconds). Int("Profile Seconds", profileSeconds). Msg("Your profile function took longer than expected to run, increase profileTime") } else if actualSeconds < profileSeconds && actualSeconds > 0 { - log.Warn(). + c.l.Warn(). Int("Actual Seconds", actualSeconds). Int("Profile Seconds", profileSeconds). Msg("Your profile function took shorter than expected to run, you can decrease profileTime") @@ -1174,7 +1178,7 @@ func (c *ChainlinkClient) TrackForwarder(chainID *big.Int, address common.Addres ChainID: chainID.String(), Address: address.Hex(), } - log.Debug().Str(NodeURL, c.Config.URL). + c.l.Debug().Str(NodeURL, c.Config.URL). Str("Forwarder address", (address).Hex()). Str("Chain ID", chainID.String()). Msg("Track forwarder") @@ -1196,7 +1200,7 @@ func (c *ChainlinkClient) TrackForwarder(chainID *big.Int, address common.Addres // GetForwarders get list of tracked forwarders func (c *ChainlinkClient) GetForwarders() (*Forwarders, *http.Response, error) { response := &Forwarders{} - log.Info().Str(NodeURL, c.Config.URL).Msg("Reading Tracked Forwarders") + c.l.Info().Str(NodeURL, c.Config.URL).Msg("Reading Tracked Forwarders") resp, err := c.APIClient.R(). SetResult(response). Get("/v2/nodes/evm/forwarders") diff --git a/integration-tests/contracts/contract_deployer.go b/integration-tests/contracts/contract_deployer.go index 4c4d2b87a81..a3adb6db13a 100644 --- a/integration-tests/contracts/contract_deployer.go +++ b/integration-tests/contracts/contract_deployer.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/libocr/gethwrappers/offchainaggregator" @@ -116,30 +117,30 @@ type ContractDeployer interface { } // NewContractDeployer returns an instance of a contract deployer based on the client type -func NewContractDeployer(bcClient blockchain.EVMClient) (ContractDeployer, error) { +func NewContractDeployer(bcClient blockchain.EVMClient, logger zerolog.Logger) (ContractDeployer, error) { switch clientImpl := bcClient.Get().(type) { case *blockchain.EthereumClient: - return NewEthereumContractDeployer(clientImpl), nil + return NewEthereumContractDeployer(clientImpl, logger), nil case *blockchain.KlaytnClient: - return &KlaytnContractDeployer{NewEthereumContractDeployer(clientImpl)}, nil + return &KlaytnContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil case *blockchain.MetisClient: - return &MetisContractDeployer{NewEthereumContractDeployer(clientImpl)}, nil + return &MetisContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil case *blockchain.ArbitrumClient: - return &MetisContractDeployer{NewEthereumContractDeployer(clientImpl)}, nil + return &MetisContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil case *blockchain.OptimismClient: - return &OptimismContractDeployer{NewEthereumContractDeployer(clientImpl)}, nil + return &OptimismContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil case *blockchain.RSKClient: - return &RSKContractDeployer{NewEthereumContractDeployer(clientImpl)}, nil + return &RSKContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil case *blockchain.PolygonClient: - return &PolygonContractDeployer{NewEthereumContractDeployer(clientImpl)}, nil + return &PolygonContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil case *blockchain.CeloClient: - return &CeloContractDeployer{NewEthereumContractDeployer(clientImpl)}, nil + return &CeloContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil case *blockchain.QuorumClient: - return &QuorumContractDeployer{NewEthereumContractDeployer(clientImpl)}, nil + return &QuorumContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil case *blockchain.BSCClient: - return &BSCContractDeployer{NewEthereumContractDeployer(clientImpl)}, nil + return &BSCContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil case *blockchain.ScrollClient: - return &ScrollContractDeployer{NewEthereumContractDeployer(clientImpl)}, nil + return &ScrollContractDeployer{NewEthereumContractDeployer(clientImpl, logger)}, nil } return nil, errors.New("unknown blockchain client implementation for contract deployer, register blockchain client in NewContractDeployer") } @@ -147,6 +148,7 @@ func NewContractDeployer(bcClient blockchain.EVMClient) (ContractDeployer, error // EthereumContractDeployer provides the implementations for deploying ETH (EVM) based contracts type EthereumContractDeployer struct { client blockchain.EVMClient + l zerolog.Logger } // KlaytnContractDeployer wraps ethereum contract deployments for Klaytn @@ -195,9 +197,10 @@ type ScrollContractDeployer struct { } // NewEthereumContractDeployer returns an instantiated instance of the ETH contract deployer -func NewEthereumContractDeployer(ethClient blockchain.EVMClient) *EthereumContractDeployer { +func NewEthereumContractDeployer(ethClient blockchain.EVMClient, logger zerolog.Logger) *EthereumContractDeployer { return &EthereumContractDeployer{ client: ethClient, + l: logger, } } @@ -451,6 +454,7 @@ func (e *EthereumContractDeployer) DeployLinkTokenContract() (LinkToken, error) client: e.client, instance: instance.(*link_token_interface.LinkToken), address: *linkTokenAddress, + l: e.l, }, err } @@ -469,6 +473,7 @@ func (e *EthereumContractDeployer) LoadLinkToken(address common.Address) (LinkTo address: address, client: e.client, instance: instance.(*link_token_interface.LinkToken), + l: e.l, }, err } @@ -551,6 +556,7 @@ func (e *EthereumContractDeployer) DeployOffChainAggregator( client: e.client, ocr: instance.(*offchainaggregator.OffchainAggregator), address: address, + l: e.l, }, err } @@ -569,6 +575,7 @@ func (e *EthereumContractDeployer) LoadOffChainAggregator(address *common.Addres address: address, client: e.client, ocr: instance.(*offchainaggregator.OffchainAggregator), + l: e.l, }, err } @@ -1423,5 +1430,6 @@ func (e *EthereumContractDeployer) DeployOffchainAggregatorV2( client: e.client, contract: instance.(*ocr2aggregator.OCR2Aggregator), address: address, + l: e.l, }, err } diff --git a/integration-tests/contracts/contract_loader.go b/integration-tests/contracts/contract_loader.go index 2c079a61b8b..a790747e38d 100644 --- a/integration-tests/contracts/contract_loader.go +++ b/integration-tests/contracts/contract_loader.go @@ -5,6 +5,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/rs/zerolog" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_coordinator" @@ -34,20 +35,20 @@ type ContractLoader interface { } // NewContractLoader returns an instance of a contract Loader based on the client type -func NewContractLoader(bcClient blockchain.EVMClient) (ContractLoader, error) { +func NewContractLoader(bcClient blockchain.EVMClient, logger zerolog.Logger) (ContractLoader, error) { switch clientImpl := bcClient.Get().(type) { case *blockchain.EthereumClient: - return NewEthereumContractLoader(clientImpl), nil + return NewEthereumContractLoader(clientImpl, logger), nil case *blockchain.KlaytnClient: - return &KlaytnContractLoader{NewEthereumContractLoader(clientImpl)}, nil + return &KlaytnContractLoader{NewEthereumContractLoader(clientImpl, logger)}, nil case *blockchain.MetisClient: - return &MetisContractLoader{NewEthereumContractLoader(clientImpl)}, nil + return &MetisContractLoader{NewEthereumContractLoader(clientImpl, logger)}, nil case *blockchain.ArbitrumClient: - return &ArbitrumContractLoader{NewEthereumContractLoader(clientImpl)}, nil + return &ArbitrumContractLoader{NewEthereumContractLoader(clientImpl, logger)}, nil case *blockchain.PolygonClient: - return &PolygonContractLoader{NewEthereumContractLoader(clientImpl)}, nil + return &PolygonContractLoader{NewEthereumContractLoader(clientImpl, logger)}, nil case *blockchain.OptimismClient: - return &OptimismContractLoader{NewEthereumContractLoader(clientImpl)}, nil + return &OptimismContractLoader{NewEthereumContractLoader(clientImpl, logger)}, nil } return nil, errors.New("unknown blockchain client implementation for contract Loader, register blockchain client in NewContractLoader") } @@ -55,6 +56,7 @@ func NewContractLoader(bcClient blockchain.EVMClient) (ContractLoader, error) { // EthereumContractLoader provides the implementations for deploying ETH (EVM) based contracts type EthereumContractLoader struct { client blockchain.EVMClient + l zerolog.Logger } // KlaytnContractLoader wraps ethereum contract deployments for Klaytn @@ -83,9 +85,10 @@ type OptimismContractLoader struct { } // NewEthereumContractLoader returns an instantiated instance of the ETH contract Loader -func NewEthereumContractLoader(ethClient blockchain.EVMClient) *EthereumContractLoader { +func NewEthereumContractLoader(ethClient blockchain.EVMClient, logger zerolog.Logger) *EthereumContractLoader { return &EthereumContractLoader{ client: ethClient, + l: logger, } } @@ -104,6 +107,7 @@ func (e *EthereumContractLoader) LoadLINKToken(addr string) (LinkToken, error) { client: e.client, instance: instance.(*link_token_interface.LinkToken), address: common.HexToAddress(addr), + l: e.l, }, err } @@ -140,6 +144,7 @@ func (e *EthereumContractLoader) LoadFunctionsRouter(addr string) (FunctionsRout client: e.client, instance: instance.(*functions_router.FunctionsRouter), address: common.HexToAddress(addr), + l: e.l, }, err } @@ -176,6 +181,7 @@ func (e *EthereumContractLoader) LoadOperatorContract(address common.Address) (O address: address, client: e.client, operator: instance.(*operator_wrapper.Operator), + l: e.l, }, err } diff --git a/integration-tests/contracts/ethereum_contracts.go b/integration-tests/contracts/ethereum_contracts.go index 763faecace7..d11eefecd47 100644 --- a/integration-tests/contracts/ethereum_contracts.go +++ b/integration-tests/contracts/ethereum_contracts.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/libocr/gethwrappers/offchainaggregator" @@ -1115,6 +1116,7 @@ type FluxAggregatorRoundConfirmer struct { context context.Context cancel context.CancelFunc complete bool + l zerolog.Logger } // NewFluxAggregatorRoundConfirmer provides a new instance of a FluxAggregatorRoundConfirmer @@ -1122,6 +1124,7 @@ func NewFluxAggregatorRoundConfirmer( contract FluxAggregator, roundID *big.Int, timeout time.Duration, + logger zerolog.Logger, ) *FluxAggregatorRoundConfirmer { ctx, ctxCancel := context.WithTimeout(context.Background(), timeout) return &FluxAggregatorRoundConfirmer{ @@ -1130,6 +1133,7 @@ func NewFluxAggregatorRoundConfirmer( doneChan: make(chan struct{}), context: ctx, cancel: ctxCancel, + l: logger, } } @@ -1149,11 +1153,11 @@ func (f *FluxAggregatorRoundConfirmer) ReceiveHeader(header blockchain.NodeHeade "Header Number": header.Number.Uint64(), } if lr.Cmp(f.roundID) >= 0 { - log.Info().Fields(logFields).Msg("FluxAggregator round completed") + f.l.Info().Fields(logFields).Msg("FluxAggregator round completed") f.complete = true f.doneChan <- struct{}{} } else { - log.Debug().Fields(logFields).Msg("Waiting for FluxAggregator round") + f.l.Debug().Fields(logFields).Msg("Waiting for FluxAggregator round") } return nil } @@ -1181,6 +1185,7 @@ type EthereumLinkToken struct { client blockchain.EVMClient instance *link_token_interface.LinkToken address common.Address + l zerolog.Logger } // Fund the LINK Token contract with ETH to distribute the token @@ -1222,7 +1227,7 @@ func (l *EthereumLinkToken) Approve(to string, amount *big.Int) error { if err != nil { return err } - log.Info(). + l.l.Info(). Str("From", l.client.GetDefaultWallet().Address()). Str("To", to). Str("Amount", amount.String()). @@ -1240,7 +1245,7 @@ func (l *EthereumLinkToken) Transfer(to string, amount *big.Int) error { if err != nil { return err } - log.Info(). + l.l.Info(). Str("From", l.client.GetDefaultWallet().Address()). Str("To", to). Str("Amount", amount.String()). @@ -1262,7 +1267,7 @@ func (l *EthereumLinkToken) TransferAndCall(to string, amount *big.Int, data []b if err != nil { return nil, err } - log.Info(). + l.l.Info(). Str("From", l.client.GetDefaultWallet().Address()). Str("To", to). Str("Amount", amount.String()). @@ -1277,6 +1282,7 @@ type EthereumOffchainAggregator struct { client blockchain.EVMClient ocr *offchainaggregator.OffchainAggregator address *common.Address + l zerolog.Logger } // Fund sends specified currencies to the contract @@ -1322,7 +1328,7 @@ func (o *EthereumOffchainAggregator) SetPayees( payeesAddr = append(payeesAddr, common.HexToAddress(p)) } - log.Info(). + o.l.Info(). Str("Transmitters", fmt.Sprintf("%v", transmitters)). Str("Payees", fmt.Sprintf("%v", payees)). Str("OCR Address", o.Address()). @@ -1430,7 +1436,7 @@ func (o *EthereumOffchainAggregator) RequestNewRound() error { if err != nil { return err } - log.Info().Str("Contract Address", o.address.Hex()).Msg("New OCR round requested") + o.l.Info().Str("Contract Address", o.address.Hex()).Msg("New OCR round requested") return o.client.ProcessTransaction(tx) } @@ -1512,6 +1518,7 @@ type RunlogRoundConfirmer struct { doneChan chan struct{} context context.Context cancel context.CancelFunc + l zerolog.Logger } // NewRunlogRoundConfirmer provides a new instance of a RunlogRoundConfirmer @@ -1519,6 +1526,7 @@ func NewRunlogRoundConfirmer( contract APIConsumer, roundID *big.Int, timeout time.Duration, + logger zerolog.Logger, ) *RunlogRoundConfirmer { ctx, ctxCancel := context.WithTimeout(context.Background(), timeout) return &RunlogRoundConfirmer{ @@ -1527,6 +1535,7 @@ func NewRunlogRoundConfirmer( doneChan: make(chan struct{}), context: ctx, cancel: ctxCancel, + l: logger, } } @@ -1542,10 +1551,10 @@ func (o *RunlogRoundConfirmer) ReceiveHeader(_ blockchain.NodeHeader) error { "Waiting for Round": o.roundID.Int64(), } if currentRoundID.Cmp(o.roundID) >= 0 { - log.Info().Fields(logFields).Msg("Runlog round completed") + o.l.Info().Fields(logFields).Msg("Runlog round completed") o.doneChan <- struct{}{} } else { - log.Debug().Fields(logFields).Msg("Waiting for Runlog round") + o.l.Debug().Fields(logFields).Msg("Waiting for Runlog round") } return nil } @@ -1572,6 +1581,7 @@ type OffchainAggregatorRoundConfirmer struct { cancel context.CancelFunc blocksSinceAnswer uint complete bool + l zerolog.Logger } // NewOffchainAggregatorRoundConfirmer provides a new instance of a OffchainAggregatorRoundConfirmer @@ -1579,6 +1589,7 @@ func NewOffchainAggregatorRoundConfirmer( contract OffchainAggregator, roundID *big.Int, timeout time.Duration, + logger zerolog.Logger, ) *OffchainAggregatorRoundConfirmer { ctx, ctxCancel := context.WithTimeout(context.Background(), timeout) return &OffchainAggregatorRoundConfirmer{ @@ -1588,6 +1599,7 @@ func NewOffchainAggregatorRoundConfirmer( context: ctx, cancel: ctxCancel, complete: false, + l: logger, } } @@ -1609,11 +1621,11 @@ func (o *OffchainAggregatorRoundConfirmer) ReceiveHeader(_ blockchain.NodeHeader "Waiting for Round": o.roundID.Int64(), } if currRound.Cmp(o.roundID) >= 0 { - log.Info().Fields(logFields).Msg("OCR round completed") + o.l.Info().Fields(logFields).Msg("OCR round completed") o.doneChan <- struct{}{} o.complete = true } else { - log.Debug().Fields(logFields).Msg("Waiting on OCR Round") + o.l.Debug().Fields(logFields).Msg("Waiting on OCR Round") } return nil } @@ -1646,6 +1658,7 @@ type OffchainAggregatorV2RoundConfirmer struct { cancel context.CancelFunc blocksSinceAnswer uint complete bool + l zerolog.Logger } // NewOffchainAggregatorRoundConfirmer provides a new instance of a OffchainAggregatorRoundConfirmer @@ -1653,6 +1666,7 @@ func NewOffchainAggregatorV2RoundConfirmer( contract OffchainAggregatorV2, roundID *big.Int, timeout time.Duration, + logger zerolog.Logger, ) *OffchainAggregatorV2RoundConfirmer { ctx, ctxCancel := context.WithTimeout(context.Background(), timeout) return &OffchainAggregatorV2RoundConfirmer{ @@ -1662,6 +1676,7 @@ func NewOffchainAggregatorV2RoundConfirmer( context: ctx, cancel: ctxCancel, complete: false, + l: logger, } } @@ -1683,11 +1698,11 @@ func (o *OffchainAggregatorV2RoundConfirmer) ReceiveHeader(_ blockchain.NodeHead "Waiting for Round": o.roundID.Int64(), } if currRound.Cmp(o.roundID) >= 0 { - log.Info().Fields(logFields).Msg("OCR round completed") + o.l.Info().Fields(logFields).Msg("OCR round completed") o.doneChan <- struct{}{} o.complete = true } else { - log.Debug().Fields(logFields).Msg("Waiting on OCR Round") + o.l.Debug().Fields(logFields).Msg("Waiting on OCR Round") } return nil } @@ -1815,6 +1830,7 @@ type EthereumOperator struct { address common.Address client blockchain.EVMClient operator *operator_wrapper.Operator + l zerolog.Logger } func (e *EthereumOperator) Address() string { @@ -1826,7 +1842,7 @@ func (e *EthereumOperator) AcceptAuthorizedReceivers(forwarders []common.Address if err != nil { return err } - log.Info(). + e.l.Info(). Str("ForwardersAddresses", fmt.Sprint(forwarders)). Str("EoaAddresses", fmt.Sprint(eoa)). Msg("Accepting Authorized Receivers") @@ -1923,6 +1939,7 @@ type EthereumOffchainAggregatorV2 struct { address *common.Address client blockchain.EVMClient contract *ocr2aggregator.OCR2Aggregator + l zerolog.Logger } // OCRv2Config represents the config for the OCRv2 contract @@ -2008,7 +2025,7 @@ func (e *EthereumOffchainAggregatorV2) SetPayees(transmitters, payees []string) if err != nil { return err } - log.Info(). + e.l.Info(). Str("Transmitters", fmt.Sprintf("%v", transmitters)). Str("Payees", fmt.Sprintf("%v", payees)). Str("OCRv2 Address", e.Address()). @@ -2034,7 +2051,7 @@ func (e *EthereumOffchainAggregatorV2) SetConfig(ocrConfig *OCRv2Config) error { if err != nil { return err } - log.Info(). + e.l.Info(). Str("Address", e.Address()). Interface("Signers", ocrConfig.Signers). Interface("Transmitters", ocrConfig.Transmitters). @@ -2091,6 +2108,7 @@ type EthereumFunctionsRouter struct { address common.Address client blockchain.EVMClient instance *functions_router.FunctionsRouter + l zerolog.Logger } func (e *EthereumFunctionsRouter) Address() string { @@ -2114,7 +2132,7 @@ func (e *EthereumFunctionsRouter) CreateSubscriptionWithConsumer(consumer string return 0, err } for _, l := range r.Logs { - log.Info().Interface("Log", common.Bytes2Hex(l.Data)).Send() + e.l.Info().Interface("Log", common.Bytes2Hex(l.Data)).Send() } topicsMap := map[string]interface{}{} @@ -2123,14 +2141,14 @@ func (e *EthereumFunctionsRouter) CreateSubscriptionWithConsumer(consumer string return 0, err } for _, ev := range fabi.Events { - log.Info().Str("EventName", ev.Name).Send() + e.l.Info().Str("EventName", ev.Name).Send() } topicOneInputs := abi.Arguments{fabi.Events["SubscriptionCreated"].Inputs[0]} topicOneHash := []common.Hash{r.Logs[0].Topics[1:][0]} if err := abi.ParseTopicsIntoMap(topicsMap, topicOneInputs, topicOneHash); err != nil { return 0, errors.Wrap(err, "failed to decode topic value") } - log.Info().Interface("NewTopicsDecoded", topicsMap).Send() + e.l.Info().Interface("NewTopicsDecoded", topicsMap).Send() if topicsMap["subscriptionId"] == 0 { return 0, errors.New("failed to decode subscription ID after creation") } diff --git a/integration-tests/contracts/ethereum_keeper_contracts.go b/integration-tests/contracts/ethereum_keeper_contracts.go index 67d26960585..afb6550bd2c 100644 --- a/integration-tests/contracts/ethereum_keeper_contracts.go +++ b/integration-tests/contracts/ethereum_keeper_contracts.go @@ -15,7 +15,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/rs/zerolog/log" + "github.com/rs/zerolog" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" goabi "github.com/umbracle/ethgo/abi" @@ -204,6 +204,7 @@ type EthereumKeeperRegistry struct { registry2_0 *keeper_registry_wrapper2_0.KeeperRegistry registry2_1 *i_keeper_registry_master_wrapper_2_1.IKeeperRegistryMaster address *common.Address + l zerolog.Logger } func (v *EthereumKeeperRegistry) Address() string { @@ -777,7 +778,7 @@ func (v *EthereumKeeperRegistry) CancelUpkeep(id *big.Int) error { } } - log.Info(). + v.l.Info(). Str("Upkeep ID", strconv.FormatInt(id.Int64(), 10)). Str("From", v.client.GetDefaultWallet().Address()). Str("TX Hash", tx.Hash().String()). @@ -1132,6 +1133,7 @@ type KeeperConsumerRoundConfirmer struct { doneChan chan struct{} context context.Context cancel context.CancelFunc + l zerolog.Logger } // NewKeeperConsumerRoundConfirmer provides a new instance of a KeeperConsumerRoundConfirmer @@ -1139,6 +1141,7 @@ func NewKeeperConsumerRoundConfirmer( contract KeeperConsumer, counterValue int, timeout time.Duration, + logger zerolog.Logger, ) *KeeperConsumerRoundConfirmer { ctx, ctxCancel := context.WithTimeout(context.Background(), timeout) return &KeeperConsumerRoundConfirmer{ @@ -1147,6 +1150,7 @@ func NewKeeperConsumerRoundConfirmer( doneChan: make(chan struct{}), context: ctx, cancel: ctxCancel, + l: logger, } } @@ -1156,7 +1160,7 @@ func (o *KeeperConsumerRoundConfirmer) ReceiveHeader(_ blockchain.NodeHeader) er if err != nil { return err } - l := log.Info(). + l := o.l.Info(). Str("Contract Address", o.instance.Address()). Int64("Upkeeps", upkeeps.Int64()). Int("Required upkeeps", o.upkeepsValue) @@ -1200,6 +1204,7 @@ type KeeperConsumerPerformanceRoundConfirmer struct { metricsReporter *testreporters.KeeperBlockTimeTestReporter // Testreporter to track results complete bool + l zerolog.Logger } // NewKeeperConsumerPerformanceRoundConfirmer provides a new instance of a KeeperConsumerPerformanceRoundConfirmer @@ -1209,6 +1214,7 @@ func NewKeeperConsumerPerformanceRoundConfirmer( expectedBlockCadence int64, // Expected to upkeep every 5/10/20 blocks, for example blockRange int64, metricsReporter *testreporters.KeeperBlockTimeTestReporter, + logger zerolog.Logger, ) *KeeperConsumerPerformanceRoundConfirmer { ctx, cancelFunc := context.WithCancel(context.Background()) return &KeeperConsumerPerformanceRoundConfirmer{ @@ -1226,6 +1232,7 @@ func NewKeeperConsumerPerformanceRoundConfirmer( metricsReporter: metricsReporter, complete: false, lastBlockNum: 0, + l: logger, } } @@ -1248,22 +1255,22 @@ func (o *KeeperConsumerPerformanceRoundConfirmer) ReceiveHeader(receivedHeader b return err } if isEligible { - log.Trace(). + o.l.Trace(). Str("Contract Address", o.instance.Address()). Int64("Upkeeps Performed", upkeepCount.Int64()). Msg("Upkeep Now Eligible") } if upkeepCount.Int64() >= o.expectedUpkeepCount { // Upkeep was successful if o.blocksSinceSuccessfulUpkeep < o.blockCadence { // If there's an early upkeep, that's weird - log.Error(). + o.l.Error(). Str("Contract Address", o.instance.Address()). Int64("Upkeeps Performed", upkeepCount.Int64()). Int64("Expected Cadence", o.blockCadence). Int64("Actual Cadence", o.blocksSinceSuccessfulUpkeep). - Err(errors.New("Found an early Upkeep")) - return fmt.Errorf("Found an early Upkeep on contract %s", o.instance.Address()) + Err(errors.New("found an early Upkeep")) + return fmt.Errorf("found an early Upkeep on contract %s", o.instance.Address()) } else if o.blocksSinceSuccessfulUpkeep == o.blockCadence { // Perfectly timed upkeep - log.Info(). + o.l.Info(). Str("Contract Address", o.instance.Address()). Int64("Upkeeps Performed", upkeepCount.Int64()). Int64("Expected Cadence", o.blockCadence). @@ -1271,7 +1278,7 @@ func (o *KeeperConsumerPerformanceRoundConfirmer) ReceiveHeader(receivedHeader b Msg("Successful Upkeep on Expected Cadence") o.totalSuccessfulUpkeeps++ } else { // Late upkeep - log.Warn(). + o.l.Warn(). Str("Contract Address", o.instance.Address()). Int64("Upkeeps Performed", upkeepCount.Int64()). Int64("Expected Cadence", o.blockCadence). @@ -1286,7 +1293,7 @@ func (o *KeeperConsumerPerformanceRoundConfirmer) ReceiveHeader(receivedHeader b if o.blocksSinceSubscription > o.blockRange { if o.blocksSinceSuccessfulUpkeep > o.blockCadence { - log.Warn(). + o.l.Warn(). Str("Contract Address", o.instance.Address()). Int64("Upkeeps Performed", upkeepCount.Int64()). Int64("Expected Cadence", o.blockCadence). @@ -1296,7 +1303,7 @@ func (o *KeeperConsumerPerformanceRoundConfirmer) ReceiveHeader(receivedHeader b Msg("Finished Watching for Upkeeps While Waiting on a Late Upkeep") o.allMissedUpkeeps = append(o.allMissedUpkeeps, o.blocksSinceSuccessfulUpkeep-o.blockCadence) } else { - log.Info(). + o.l.Info(). Str("Contract Address", o.instance.Address()). Int64("Upkeeps Performed", upkeepCount.Int64()). Int64("Total Blocks Watched", o.blocksSinceSubscription). @@ -1365,6 +1372,7 @@ type KeeperConsumerBenchmarkRoundConfirmer struct { upkeepCount int64 // The count of upkeeps done so far allCheckDelays []int64 // Tracks the amount of blocks missed before an upkeep since it became eligible complete bool + l zerolog.Logger } // NewKeeperConsumerBenchmarkRoundConfirmer provides a new instance of a KeeperConsumerBenchmarkRoundConfirmer @@ -1378,6 +1386,7 @@ func NewKeeperConsumerBenchmarkRoundConfirmer( metricsReporter *testreporters.KeeperBenchmarkTestReporter, upkeepIndex int64, firstEligibleuffer int64, + logger zerolog.Logger, ) *KeeperConsumerBenchmarkRoundConfirmer { ctx, cancelFunc := context.WithCancel(context.Background()) return &KeeperConsumerBenchmarkRoundConfirmer{ @@ -1399,6 +1408,7 @@ func NewKeeperConsumerBenchmarkRoundConfirmer( upkeepIndex: upkeepIndex, firstBlockNum: 0, firstEligibleuffer: firstEligibleuffer, + l: logger, } } @@ -1423,7 +1433,7 @@ func (o *KeeperConsumerBenchmarkRoundConfirmer) ReceiveHeader(receivedHeader blo if upkeepCount.Int64() != o.upkeepCount+1 { return errors.New("upkeep count increased by more than 1 in a single block") } - log.Info(). + o.l.Info(). Uint64("Block_Number", receivedHeader.Number.Uint64()). Str("Upkeep_ID", o.upkeepID.String()). Str("Contract_Address", o.instance.Address()). @@ -1433,7 +1443,7 @@ func (o *KeeperConsumerBenchmarkRoundConfirmer) ReceiveHeader(receivedHeader blo Msg("Upkeep Performed") if o.blocksSinceEligible > o.upkeepSLA { - log.Warn(). + o.l.Warn(). Uint64("Block_Number", receivedHeader.Number.Uint64()). Str("Upkeep_ID", o.upkeepID.String()). Str("Contract_Address", o.instance.Address()). @@ -1456,7 +1466,7 @@ func (o *KeeperConsumerBenchmarkRoundConfirmer) ReceiveHeader(receivedHeader blo if o.blocksSinceEligible == 0 { // First time this upkeep became eligible o.countEligible++ - log.Info(). + o.l.Info(). Uint64("Block_Number", receivedHeader.Number.Uint64()). Str("Upkeep_ID", o.upkeepID.String()). Str("Contract_Address", o.instance.Address()). @@ -1469,7 +1479,7 @@ func (o *KeeperConsumerBenchmarkRoundConfirmer) ReceiveHeader(receivedHeader blo if o.blocksSinceSubscription >= o.blockRange || int64(o.lastBlockNum-o.firstBlockNum) >= o.blockRange { if o.blocksSinceEligible > 0 { if o.blocksSinceEligible > o.upkeepSLA { - log.Warn(). + o.l.Warn(). Uint64("Block_Number", receivedHeader.Number.Uint64()). Str("Upkeep_ID", o.upkeepID.String()). Str("Contract_Address", o.instance.Address()). @@ -1478,7 +1488,7 @@ func (o *KeeperConsumerBenchmarkRoundConfirmer) ReceiveHeader(receivedHeader blo Msg("Upkeep remained eligible at end of test and missed SLA") o.countMissed++ } else { - log.Info(). + o.l.Info(). Uint64("Block_Number", receivedHeader.Number.Uint64()). Str("Upkeep_ID", o.upkeepID.String()). Str("Contract_Address", o.instance.Address()). @@ -1490,7 +1500,7 @@ func (o *KeeperConsumerBenchmarkRoundConfirmer) ReceiveHeader(receivedHeader blo o.allCheckDelays = append(o.allCheckDelays, o.blocksSinceEligible) } - log.Info(). + o.l.Info(). Uint64("Block_Number", receivedHeader.Number.Uint64()). Str("Upkeep_ID", o.upkeepID.String()). Str("Contract_Address", o.instance.Address()). diff --git a/integration-tests/docker/test_env/cl_node.go b/integration-tests/docker/test_env/cl_node.go index 49d3cdc369d..e4182ca4c36 100644 --- a/integration-tests/docker/test_env/cl_node.go +++ b/integration-tests/docker/test_env/cl_node.go @@ -10,6 +10,7 @@ import ( "os" "strings" "sync" + "testing" "time" "github.com/ethereum/go-ethereum" @@ -17,6 +18,7 @@ import ( "github.com/google/uuid" "github.com/pelletier/go-toml/v2" "github.com/pkg/errors" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" tc "github.com/testcontainers/testcontainers-go" tcwait "github.com/testcontainers/testcontainers-go/wait" @@ -24,6 +26,7 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/docker" "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/logwatch" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" @@ -49,6 +52,8 @@ type ClNode struct { lw *logwatch.LogWatch ContainerImage string ContainerVersion string + t *testing.T + l zerolog.Logger } type ClNodeOption = func(c *ClNode) @@ -88,6 +93,7 @@ func NewClNode(networks []string, nodeConfig *chainlink.Config, opts ...ClNodeOp }, NodeConfig: nodeConfig, PostgresDb: pgDb, + l: log.Logger, } for _, opt := range opts { opt(n) @@ -95,6 +101,13 @@ func NewClNode(networks []string, nodeConfig *chainlink.Config, opts ...ClNodeOp return n } +func (n *ClNode) WithTestLogger(t *testing.T) *ClNode { + n.l = logging.GetTestLogger(t) + n.t = t + n.PostgresDb.WithTestLogger(t) + return n +} + // Restart restarts only CL node, DB container is reused func (n *ClNode) Restart(cfg *chainlink.Config) error { if err := n.Container.Terminate(context.Background()); err != nil { @@ -238,10 +251,19 @@ func (n *ClNode) StartContainer() error { if err != nil { return err } - container, err := docker.StartContainerWithRetry(tc.GenericContainerRequest{ + + l := tc.Logger + if n.t != nil { + l = logging.CustomT{ + T: n.t, + L: n.l, + } + } + container, err := docker.StartContainerWithRetry(n.l, tc.GenericContainerRequest{ ContainerRequest: *cReq, Started: true, Reuse: true, + Logger: l, }) if err != nil { return errors.Wrap(err, ErrStartCLNodeContainer) @@ -259,7 +281,7 @@ func (n *ClNode) StartContainer() error { if err != nil { return err } - log.Info().Str("containerName", n.ContainerName). + n.l.Info().Str("containerName", n.ContainerName). Str("clEndpoint", clEndpoint). Str("clInternalIP", ip). Msg("Started Chainlink Node container") @@ -268,11 +290,11 @@ func (n *ClNode) StartContainer() error { Email: "local@local.com", Password: "localdevpassword", InternalIP: ip, - }) + }, + n.l) if err != nil { return errors.Wrap(err, ErrConnectNodeClient) } - clClient.Config.InternalIP = n.ContainerName n.Container = container n.API = clClient diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index 7de4064a259..8c4faadbd2b 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -14,6 +14,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" tc "github.com/testcontainers/testcontainers-go" "golang.org/x/sync/errgroup" @@ -21,8 +22,8 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/docker" "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/logwatch" - testUtils "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -48,11 +49,13 @@ type CLClusterTestEnv struct { EVMClient blockchain.EVMClient ContractDeployer contracts.ContractDeployer ContractLoader contracts.ContractLoader + l zerolog.Logger + t *testing.T } func NewTestEnv() (*CLClusterTestEnv, error) { utils.SetupCoreDockerEnvLogger() - network, err := docker.CreateNetwork() + network, err := docker.CreateNetwork(log.Logger) if err != nil { return nil, err } @@ -61,22 +64,32 @@ func NewTestEnv() (*CLClusterTestEnv, error) { Network: network, Geth: test_env.NewGeth(networks), MockServer: test_env.NewMockServer(networks), + l: log.Logger, }, nil } -func NewTestEnvFromCfg(cfg *TestEnvConfig) (*CLClusterTestEnv, error) { +func (te *CLClusterTestEnv) WithTestLogger(t *testing.T) *CLClusterTestEnv { + te.t = t + te.l = logging.GetTestLogger(t) + te.Geth.WithTestLogger(t) + te.MockServer.WithTestLogger(t) + return te +} + +func NewTestEnvFromCfg(l zerolog.Logger, cfg *TestEnvConfig) (*CLClusterTestEnv, error) { utils.SetupCoreDockerEnvLogger() - network, err := docker.CreateNetwork() + network, err := docker.CreateNetwork(log.Logger) if err != nil { return nil, err } networks := []string{network.Name} - log.Info().Interface("Cfg", cfg).Send() + l.Info().Interface("Cfg", cfg).Send() return &CLClusterTestEnv{ Cfg: cfg, Network: network, Geth: test_env.NewGeth(networks, test_env.WithContainerName(cfg.Geth.ContainerName)), MockServer: test_env.NewMockServer(networks, test_env.WithContainerName(cfg.MockServer.ContainerName)), + l: log.Logger, }, nil } @@ -88,6 +101,11 @@ func (te *CLClusterTestEnv) WithPrivateChain(evmNetworks []blockchain.EVMNetwork var chains []test_env.PrivateChain for _, evmNetwork := range evmNetworks { n := evmNetwork + pgc := test_env.NewPrivateGethChain(&n, []string{te.Network.Name}) + if te.t != nil { + pgc.GetPrimaryNode().WithTestLogger(te.t) + } + chains = append(chains, pgc) var privateChain test_env.PrivateChain switch n.SimulationType { case "besu": @@ -153,6 +171,9 @@ func (te *CLClusterTestEnv) StartClNodes(nodeConfig *chainlink.Config, count int WithNodeContainerName(nodeContainerName), WithDbContainerName(dbContainerName), ) + if te.t != nil { + n.WithTestLogger(te.t) + } err := n.StartContainer() if err != nil { return err @@ -218,7 +239,6 @@ func (te *CLClusterTestEnv) Terminate() error { // Cleanup cleans the environment up after it's done being used, mainly for returning funds when on live networks. // Intended to be used as part of t.Cleanup() in tests. func (te *CLClusterTestEnv) Cleanup(t *testing.T) error { - l := testUtils.GetTestLogger(t) if te.EVMClient == nil { return errors.New("blockchain client is nil, unable to return funds from chainlink nodes") } @@ -228,10 +248,10 @@ func (te *CLClusterTestEnv) Cleanup(t *testing.T) error { // Check if we need to return funds if te.EVMClient.NetworkSimulated() { - l.Info().Str("Network Name", te.EVMClient.GetNetworkName()). + te.l.Info().Str("Network Name", te.EVMClient.GetNetworkName()). Msg("Network is a simulated network. Skipping fund return.") } else { - l.Info().Msg("Attempting to return Chainlink node funds to default network wallets") + te.l.Info().Msg("Attempting to return Chainlink node funds to default network wallets") for _, chainlinkNode := range te.CLNodes { fundedKeys, err := chainlinkNode.API.ExportEVMKeysForChain(te.EVMClient.GetChainID().String()) if err != nil { @@ -266,7 +286,7 @@ func (te *CLClusterTestEnv) Cleanup(t *testing.T) error { return err } - l.Warn().Msg("Test failed, collecting logs") + te.l.Warn().Msg("Test failed, collecting logs") eg := &errgroup.Group{} for _, n := range te.CLNodes { node := n @@ -285,7 +305,7 @@ func (te *CLClusterTestEnv) Cleanup(t *testing.T) error { if err != nil { return err } - l.Info().Str("Node", node.ContainerName).Str("File", logFileName).Msg("Wrote Logs") + te.l.Info().Str("Node", node.ContainerName).Str("File", logFileName).Msg("Wrote Logs") return nil }) } @@ -294,7 +314,7 @@ func (te *CLClusterTestEnv) Cleanup(t *testing.T) error { return err } - l.Info().Str("Logs Location", folder).Msg("Wrote Logs for Failed Test") + te.l.Info().Str("Logs Location", folder).Msg("Wrote Logs for Failed Test") return nil } diff --git a/integration-tests/docker/test_env/test_env_builder.go b/integration-tests/docker/test_env/test_env_builder.go index f08c024d16e..f3944b0ba96 100644 --- a/integration-tests/docker/test_env/test_env_builder.go +++ b/integration-tests/docker/test_env/test_env_builder.go @@ -4,16 +4,18 @@ import ( "fmt" "math/big" "os" + "testing" "github.com/pkg/errors" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/logwatch" - "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink-testing-framework/networks" + "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" @@ -30,6 +32,8 @@ type CLTestEnvBuilder struct { externalAdapterCount int customNodeCsaKeys []string defaultNodeCsaKeys []string + l zerolog.Logger + t *testing.T /* funding */ ETHFunds *big.Float @@ -38,9 +42,16 @@ type CLTestEnvBuilder struct { func NewCLTestEnvBuilder() *CLTestEnvBuilder { return &CLTestEnvBuilder{ externalAdapterCount: 1, + l: log.Logger, } } +func (b *CLTestEnvBuilder) WithTestLogger(t *testing.T) *CLTestEnvBuilder { + b.t = t + b.l = logging.GetTestLogger(t) + return b +} + func (b *CLTestEnvBuilder) WithLogWatcher() *CLTestEnvBuilder { b.hasLogWatch = true return b @@ -96,7 +107,7 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { } func (b *CLTestEnvBuilder) buildNewEnv(cfg *TestEnvConfig) (*CLClusterTestEnv, error) { - log.Info(). + b.l.Info(). Bool("hasGeth", b.hasGeth). Bool("hasMockServer", b.hasMockServer). Int("externalAdapterCount", b.externalAdapterCount). @@ -108,7 +119,7 @@ func (b *CLTestEnvBuilder) buildNewEnv(cfg *TestEnvConfig) (*CLClusterTestEnv, e var te *CLClusterTestEnv var err error if cfg != nil { - te, err = NewTestEnvFromCfg(cfg) + te, err = NewTestEnvFromCfg(b.l, cfg) if err != nil { return nil, err } @@ -119,6 +130,10 @@ func (b *CLTestEnvBuilder) buildNewEnv(cfg *TestEnvConfig) (*CLClusterTestEnv, e } } + if b.t != nil { + te.WithTestLogger(b.t) + } + if b.hasLogWatch { te.LogWatch, err = logwatch.NewLogWatch(nil, nil) if err != nil { @@ -172,20 +187,20 @@ func (b *CLTestEnvBuilder) buildNewEnv(cfg *TestEnvConfig) (*CLClusterTestEnv, e } - bc, err := blockchain.NewEVMClientFromNetwork(networkConfig) + bc, err := blockchain.NewEVMClientFromNetwork(networkConfig, b.l) if err != nil { return nil, err } te.EVMClient = bc - cd, err := contracts.NewContractDeployer(bc) + cd, err := contracts.NewContractDeployer(bc, b.l) if err != nil { return nil, err } te.ContractDeployer = cd - cl, err := contracts.NewContractLoader(bc) + cl, err := contracts.NewContractLoader(bc, b.l) if err != nil { return nil, err } diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 1ae49de72d2..9edf6d72be5 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -20,7 +20,7 @@ require ( github.com/rs/zerolog v1.30.0 github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-env v0.36.0 - github.com/smartcontractkit/chainlink-testing-framework v1.16.9-0.20230913144245-620fbcd69dfb + github.com/smartcontractkit/chainlink-testing-framework v1.17.0 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20230816220705-665e93233ae5 github.com/smartcontractkit/ocr2keepers v0.7.23 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 73c77682f35..55686ce2ef4 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -2258,8 +2258,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20230831134610-680240b97ac github.com/smartcontractkit/chainlink-solana v1.0.3-0.20230831134610-680240b97aca/go.mod h1:RIUJXn7EVp24TL2p4FW79dYjyno23x5mjt1nKN+5WEk= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20230901115736-bbabe542a918 h1:ByVauKFXphRlSNG47lNuxZ9aicu+r8AoNp933VRPpCw= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20230901115736-bbabe542a918/go.mod h1:/yp/sqD8Iz5GU5fcercjrw0ivJF7HDcupYg+Gjr7EPg= -github.com/smartcontractkit/chainlink-testing-framework v1.16.9-0.20230913144245-620fbcd69dfb h1:ZLBIvWgoB4Op24yNYJ87qGI9yd6B/6WM+uYs3Vj1Hww= -github.com/smartcontractkit/chainlink-testing-framework v1.16.9-0.20230913144245-620fbcd69dfb/go.mod h1:Ry6fRPr8TwrIsYVNEF1pguAgzE3QW1s54tbLWnFtfI4= +github.com/smartcontractkit/chainlink-testing-framework v1.17.0 h1:JcJwfawW7jfLBG+By5hGTVcNgKQ7bJCqvN9TEF3qBis= +github.com/smartcontractkit/chainlink-testing-framework v1.17.0/go.mod h1:Ry6fRPr8TwrIsYVNEF1pguAgzE3QW1s54tbLWnFtfI4= github.com/smartcontractkit/go-plugin v0.0.0-20230605132010-0f4d515d1472 h1:x3kNwgFlDmbE/n0gTSRMt9GBDfsfGrs4X9b9arPZtFI= github.com/smartcontractkit/go-plugin v0.0.0-20230605132010-0f4d515d1472/go.mod h1:6/1TEzT0eQznvI/gV2CM29DLSkAK/e58mUWKVsPaph0= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= diff --git a/integration-tests/load/functions/setup.go b/integration-tests/load/functions/setup.go index 60986595b9f..5d44cbc698e 100644 --- a/integration-tests/load/functions/setup.go +++ b/integration-tests/load/functions/setup.go @@ -50,16 +50,16 @@ type S4SecretsCfg struct { } func SetupLocalLoadTestEnv(cfg *PerformanceConfig) (*FunctionsTest, error) { - bc, err := blockchain.NewEVMClientFromNetwork(networks.SelectedNetwork) + bc, err := blockchain.NewEVMClientFromNetwork(networks.SelectedNetwork, log.Logger) if err != nil { return nil, err } - cd, err := contracts.NewContractDeployer(bc) + cd, err := contracts.NewContractDeployer(bc, log.Logger) if err != nil { return nil, err } - cl, err := contracts.NewContractLoader(bc) + cl, err := contracts.NewContractLoader(bc, log.Logger) if err != nil { return nil, err } diff --git a/integration-tests/migration/upgrade_version_test.go b/integration-tests/migration/upgrade_version_test.go index 1f90bd123eb..d1d79de5eed 100644 --- a/integration-tests/migration/upgrade_version_test.go +++ b/integration-tests/migration/upgrade_version_test.go @@ -6,13 +6,15 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "os" + + "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" ) func TestVersionUpgrade(t *testing.T) { t.Parallel() env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithCLNodes(1). Build() diff --git a/integration-tests/performance/directrequest_test.go b/integration-tests/performance/directrequest_test.go index a24493a6781..98c03c2bb96 100644 --- a/integration-tests/performance/directrequest_test.go +++ b/integration-tests/performance/directrequest_test.go @@ -18,8 +18,7 @@ import ( mockservercfg "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" - "github.com/smartcontractkit/chainlink-testing-framework/utils" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink/integration-tests/actions" @@ -31,15 +30,15 @@ import ( ) func TestDirectRequestPerformance(t *testing.T) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) testEnvironment := setupDirectRequestTest(t) if testEnvironment.WillUseRemoteRunner() { return } - chainClient, err := blockchain.NewEVMClient(blockchain.SimulatedEVMNetwork, testEnvironment) + chainClient, err := blockchain.NewEVMClient(blockchain.SimulatedEVMNetwork, testEnvironment, l) require.NoError(t, err, "Connecting to blockchain nodes shouldn't fail") - contractDeployer, err := contracts.NewContractDeployer(chainClient) + contractDeployer, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Deploying contracts shouldn't fail") chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) require.NoError(t, err, "Connecting to chainlink nodes shouldn't fail") diff --git a/integration-tests/performance/flux_test.go b/integration-tests/performance/flux_test.go index 47b2b22e1ad..2c33096a356 100644 --- a/integration-tests/performance/flux_test.go +++ b/integration-tests/performance/flux_test.go @@ -19,8 +19,7 @@ import ( mockservercfg "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" - "github.com/smartcontractkit/chainlink-testing-framework/utils" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink/integration-tests/actions" @@ -30,15 +29,15 @@ import ( ) func TestFluxPerformance(t *testing.T) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) testEnvironment, testNetwork := setupFluxTest(t) if testEnvironment.WillUseRemoteRunner() { return } - chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment) + chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment, l) require.NoError(t, err, "Connecting to blockchain nodes shouldn't fail") - contractDeployer, err := contracts.NewContractDeployer(chainClient) + contractDeployer, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Deploying contracts shouldn't fail") chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) require.NoError(t, err, "Connecting to chainlink nodes shouldn't fail") @@ -117,7 +116,7 @@ func TestFluxPerformance(t *testing.T) { return } fluxRoundTimeout := 2 * time.Minute - fluxRound := contracts.NewFluxAggregatorRoundConfirmer(fluxInstance, big.NewInt(1), fluxRoundTimeout) + fluxRound := contracts.NewFluxAggregatorRoundConfirmer(fluxInstance, big.NewInt(1), fluxRoundTimeout, l) chainClient.AddHeaderEventSubscription(fluxInstance.Address(), fluxRound) err = chainClient.WaitForEvents() require.NoError(t, err, "Waiting for event subscriptions in nodes shouldn't fail") @@ -135,7 +134,7 @@ func TestFluxPerformance(t *testing.T) { require.Equal(t, int64(3), data.AllocatedFunds.Int64(), "Expected allocated funds to be %d, but found %d", int64(3), data.AllocatedFunds.Int64()) - fluxRound = contracts.NewFluxAggregatorRoundConfirmer(fluxInstance, big.NewInt(2), fluxRoundTimeout) + fluxRound = contracts.NewFluxAggregatorRoundConfirmer(fluxInstance, big.NewInt(2), fluxRoundTimeout, l) chainClient.AddHeaderEventSubscription(fluxInstance.Address(), fluxRound) err = mockServer.SetValuePath(adapterPath, 1e10) require.NoError(t, err, "Setting value path in mock server shouldn't fail") diff --git a/integration-tests/performance/keeper_test.go b/integration-tests/performance/keeper_test.go index 5688a05aa6d..7ab0f53d0d0 100644 --- a/integration-tests/performance/keeper_test.go +++ b/integration-tests/performance/keeper_test.go @@ -18,8 +18,7 @@ import ( "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver" mockservercfg "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink/integration-tests/actions" @@ -45,7 +44,7 @@ var keeperDefaultRegistryConfig = contracts.KeeperRegistrySettings{ } func TestKeeperPerformance(t *testing.T) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) testEnvironment, chainClient, chainlinkNodes, contractDeployer, linkToken := setupKeeperTest(t, "basic-smoke") if testEnvironment.WillUseRemoteRunner() { return @@ -174,9 +173,10 @@ PerformGasOverhead = 150_000` return testEnvironment, nil, nil, nil, nil } - chainClient, err := blockchain.NewEVMClient(network, testEnvironment) + l := logging.GetTestLogger(t) + chainClient, err := blockchain.NewEVMClient(network, testEnvironment, l) require.NoError(t, err, "Connecting to blockchain nodes shouldn't fail") - contractDeployer, err := contracts.NewContractDeployer(chainClient) + contractDeployer, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Deploying contracts shouldn't fail") chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) require.NoError(t, err, "Connecting to chainlink nodes shouldn't fail") diff --git a/integration-tests/performance/ocr_test.go b/integration-tests/performance/ocr_test.go index a1f588c4411..d3d29049653 100644 --- a/integration-tests/performance/ocr_test.go +++ b/integration-tests/performance/ocr_test.go @@ -17,6 +17,7 @@ import ( mockservercfg "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" @@ -32,10 +33,10 @@ func TestOCRBasic(t *testing.T) { if testEnvironment.WillUseRemoteRunner() { return } - - chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment) + l := logging.GetTestLogger(t) + chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment, l) require.NoError(t, err, "Connecting to blockchain nodes shouldn't fail") - contractDeployer, err := contracts.NewContractDeployer(chainClient) + contractDeployer, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Deploying contracts shouldn't fail") chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) @@ -60,7 +61,7 @@ func TestOCRBasic(t *testing.T) { profileFunction := func(chainlinkNode *client.ChainlinkClient) { err = actions.CreateOCRJobs(ocrInstances, bootstrapNode, workerNodes, 5, mockServer, chainClient.GetChainID().String()) require.NoError(t, err) - err = actions.StartNewRound(1, ocrInstances, chainClient) + err = actions.StartNewRound(1, ocrInstances, chainClient, l) require.NoError(t, err) answer, err := ocrInstances[0].GetLatestAnswer(context.Background()) @@ -69,7 +70,7 @@ func TestOCRBasic(t *testing.T) { err = mockServer.SetValuePath("ocr", 10) require.NoError(t, err) - err = actions.StartNewRound(2, ocrInstances, chainClient) + err = actions.StartNewRound(2, ocrInstances, chainClient, l) require.NoError(t, err) answer, err = ocrInstances[0].GetLatestAnswer(context.Background()) diff --git a/integration-tests/performance/vrf_test.go b/integration-tests/performance/vrf_test.go index 59eb5e3980b..af3a3ecba81 100644 --- a/integration-tests/performance/vrf_test.go +++ b/integration-tests/performance/vrf_test.go @@ -16,8 +16,7 @@ import ( "github.com/smartcontractkit/chainlink-env/pkg/helm/chainlink" "github.com/smartcontractkit/chainlink-env/pkg/helm/ethereum" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink/integration-tests/actions" @@ -28,15 +27,15 @@ import ( func TestVRFBasic(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) testEnvironment, testNetwork := setupVRFTest(t) if testEnvironment.WillUseRemoteRunner() { return } - chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment) + chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment, l) require.NoError(t, err, "Connecting client shouldn't fail") - cd, err := contracts.NewContractDeployer(chainClient) + cd, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Deploying contracts shouldn't fail") chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) require.NoError(t, err, "Connecting to chainlink nodes shouldn't fail") diff --git a/integration-tests/reorg/automation_reorg_test.go b/integration-tests/reorg/automation_reorg_test.go index f3d3ed9369f..ab439e59f29 100644 --- a/integration-tests/reorg/automation_reorg_test.go +++ b/integration-tests/reorg/automation_reorg_test.go @@ -17,9 +17,9 @@ import ( "github.com/smartcontractkit/chainlink-env/pkg/helm/chainlink" "github.com/smartcontractkit/chainlink-env/pkg/helm/reorg" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" + "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -124,7 +124,7 @@ const ( * normal pace after the event. */ func TestAutomationReorg(t *testing.T) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) network := networks.SelectedNetwork cd, err := chainlink.NewDeployment(numberOfNodes, defaultAutomationSettings) @@ -147,9 +147,9 @@ func TestAutomationReorg(t *testing.T) { return } - chainClient, err := blockchain.NewEVMClient(network, testEnvironment) + chainClient, err := blockchain.NewEVMClient(network, testEnvironment, l) require.NoError(t, err, "Error connecting to blockchain") - contractDeployer, err := contracts.NewContractDeployer(chainClient) + contractDeployer, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Error building contract deployer") chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) require.NoError(t, err, "Error connecting to Chainlink nodes") diff --git a/integration-tests/reorg/reorg_test.go b/integration-tests/reorg/reorg_test.go index 03d179ce268..5666d8c7540 100644 --- a/integration-tests/reorg/reorg_test.go +++ b/integration-tests/reorg/reorg_test.go @@ -91,6 +91,7 @@ func CleanupReorgTest( func TestDirectRequestReorg(t *testing.T) { logging.Init() + l := logging.GetTestLogger(t) testEnvironment := environment.New(&environment.Config{ TTL: 1 * time.Hour, Test: t, @@ -131,9 +132,9 @@ func TestDirectRequestReorg(t *testing.T) { err = testEnvironment.AddHelmCharts(chainlinkDeployment).Run() require.NoError(t, err, "Error adding to test environment") - chainClient, err := blockchain.NewEVMClient(networkSettings, testEnvironment) + chainClient, err := blockchain.NewEVMClient(networkSettings, testEnvironment, l) require.NoError(t, err, "Error connecting to blockchain") - cd, err := contracts.NewContractDeployer(chainClient) + cd, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Error building contract deployer") chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) require.NoError(t, err, "Error connecting to Chainlink nodes") diff --git a/integration-tests/smoke/automation_test.go b/integration-tests/smoke/automation_test.go index 63d52d326ba..76ee75b21ba 100644 --- a/integration-tests/smoke/automation_test.go +++ b/integration-tests/smoke/automation_test.go @@ -13,17 +13,15 @@ import ( "github.com/onsi/gomega" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-env/logging" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" + "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" - "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" @@ -98,7 +96,7 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) var ( upgradeImage string @@ -214,7 +212,7 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { func TestSetUpkeepTriggerConfig(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( t, "set-trigger-config", ethereum.RegistryVersion_2_1, defaultOCRRegistryConfig, false, @@ -440,7 +438,7 @@ func TestAutomationPauseUnPause(t *testing.T) { registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( t, "pause-unpause", registryVersion, defaultOCRRegistryConfig, false, ) @@ -523,7 +521,7 @@ func TestAutomationRegisterUpkeep(t *testing.T) { registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( t, "register-upkeep", registryVersion, defaultOCRRegistryConfig, false, ) @@ -652,7 +650,7 @@ func TestAutomationKeeperNodesDown(t *testing.T) { registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( t, "keeper-nodes-down", registryVersion, defaultOCRRegistryConfig, false, ) @@ -801,7 +799,7 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) { registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( t, "gas-limit", registryVersion, defaultOCRRegistryConfig, false, ) @@ -882,7 +880,7 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) { highCheckGasLimit := automationDefaultRegistryConfig highCheckGasLimit.CheckGasLimit = uint32(5000000) highCheckGasLimit.RegistryVersion = registryVersion - ocrConfig, err := actions.BuildAutoOCR2ConfigVarsLocal(t, nodesWithoutBootstrap, highCheckGasLimit, registrar.Address(), 30*time.Second) + ocrConfig, err := actions.BuildAutoOCR2ConfigVarsLocal(l, nodesWithoutBootstrap, highCheckGasLimit, registrar.Address(), 30*time.Second) require.NoError(t, err, "Error building OCR config") err = registry.SetConfig(highCheckGasLimit, ocrConfig) @@ -914,7 +912,7 @@ func TestUpdateCheckData(t *testing.T) { registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( t, "update-check-data", registryVersion, defaultOCRRegistryConfig, false, ) @@ -990,6 +988,7 @@ func setupAutomationTestDocker( contracts.KeeperRegistrar, *test_env.CLClusterTestEnv, ) { + l := logging.GetTestLogger(t) // Add registry version to config registryConfig.RegistryVersion = registryVersion network := networks.SelectedNetwork @@ -1008,6 +1007,7 @@ func setupAutomationTestDocker( // launch the environment env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithMockServer(1). WithCLNodes(5). @@ -1040,9 +1040,9 @@ func setupAutomationTestDocker( err = linkToken.Transfer(registry.Address(), big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(int64(defaultAmountOfUpkeeps)))) require.NoError(t, err, "Funding keeper registry contract shouldn't fail") - err = actions.CreateOCRKeeperJobsLocal(nodeClients, registry.Address(), network.ChainID, 0, registryVersion) + err = actions.CreateOCRKeeperJobsLocal(l, nodeClients, registry.Address(), network.ChainID, 0, registryVersion) require.NoError(t, err, "Error creating OCR Keeper Jobs") - ocrConfig, err := actions.BuildAutoOCR2ConfigVarsLocal(t, workerNodes, registryConfig, registrar.Address(), 30*time.Second) + ocrConfig, err := actions.BuildAutoOCR2ConfigVarsLocal(l, workerNodes, registryConfig, registrar.Address(), 30*time.Second) require.NoError(t, err, "Error building OCR config vars") err = registry.SetConfig(automationDefaultRegistryConfig, ocrConfig) require.NoError(t, err, "Registry config should be set successfully") diff --git a/integration-tests/smoke/cron_test.go b/integration-tests/smoke/cron_test.go index 4019b50dfe2..717ff8db1e9 100644 --- a/integration-tests/smoke/cron_test.go +++ b/integration-tests/smoke/cron_test.go @@ -8,7 +8,7 @@ import ( "github.com/onsi/gomega" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" @@ -16,9 +16,10 @@ import ( func TestCronBasic(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithMockServer(1). WithCLNodes(1). diff --git a/integration-tests/smoke/flux_test.go b/integration-tests/smoke/flux_test.go index f9eef6d06ab..ed907e9e460 100644 --- a/integration-tests/smoke/flux_test.go +++ b/integration-tests/smoke/flux_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -22,9 +22,10 @@ import ( func TestFluxBasic(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithMockServer(1). WithCLNodes(3). @@ -106,7 +107,7 @@ func TestFluxBasic(t *testing.T) { // initial value set is performed before jobs creation fluxRoundTimeout := 1 * time.Minute - fluxRound := contracts.NewFluxAggregatorRoundConfirmer(fluxInstance, big.NewInt(1), fluxRoundTimeout) + fluxRound := contracts.NewFluxAggregatorRoundConfirmer(fluxInstance, big.NewInt(1), fluxRoundTimeout, l) env.EVMClient.AddHeaderEventSubscription(fluxInstance.Address(), fluxRound) err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Waiting for event subscriptions in nodes shouldn't fail") @@ -123,7 +124,7 @@ func TestFluxBasic(t *testing.T) { require.Equal(t, int64(3), data.AllocatedFunds.Int64(), "Expected allocated funds to be %d, but found %d", int64(3), data.AllocatedFunds.Int64()) - fluxRound = contracts.NewFluxAggregatorRoundConfirmer(fluxInstance, big.NewInt(2), fluxRoundTimeout) + fluxRound = contracts.NewFluxAggregatorRoundConfirmer(fluxInstance, big.NewInt(2), fluxRoundTimeout, l) env.EVMClient.AddHeaderEventSubscription(fluxInstance.Address(), fluxRound) err = env.MockServer.Client.SetValuePath(adapterPath, 1e10) require.NoError(t, err, "Setting value path in mock server shouldn't fail") diff --git a/integration-tests/smoke/forwarder_ocr_test.go b/integration-tests/smoke/forwarder_ocr_test.go index 24825323147..f0d20e5245c 100644 --- a/integration-tests/smoke/forwarder_ocr_test.go +++ b/integration-tests/smoke/forwarder_ocr_test.go @@ -8,7 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" @@ -16,9 +16,10 @@ import ( func TestForwarderOCRBasic(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithMockServer(1). WithForwarders(). @@ -54,7 +55,7 @@ func TestForwarderOCRBasic(t *testing.T) { t, operators[i], authorizedForwarders[i], []common.Address{workerNodeAddresses[i]}, env.EVMClient, env.ContractLoader, ) require.NoError(t, err, "Accepting Authorize Receivers on Operator shouldn't fail") - err = actions.TrackForwarderLocal(env.EVMClient, authorizedForwarders[i], workerNodes[i]) + err = actions.TrackForwarderLocal(env.EVMClient, authorizedForwarders[i], workerNodes[i], l) require.NoError(t, err) err = env.EVMClient.WaitForEvents() } @@ -70,7 +71,7 @@ func TestForwarderOCRBasic(t *testing.T) { err = actions.CreateOCRJobsWithForwarderLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockServer.Client, env.EVMClient.GetChainID().String()) require.NoError(t, err, "failed to setup forwarder jobs") - err = actions.StartNewRound(1, ocrInstances, env.EVMClient) + err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l) require.NoError(t, err) err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") @@ -82,7 +83,7 @@ func TestForwarderOCRBasic(t *testing.T) { err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockServer.Client) require.NoError(t, err) - err = actions.StartNewRound(2, ocrInstances, env.EVMClient) + err = actions.StartNewRound(2, ocrInstances, env.EVMClient, l) require.NoError(t, err) err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") diff --git a/integration-tests/smoke/forwarders_ocr2_test.go b/integration-tests/smoke/forwarders_ocr2_test.go index 62e8eec591a..2f7c4fa21d9 100644 --- a/integration-tests/smoke/forwarders_ocr2_test.go +++ b/integration-tests/smoke/forwarders_ocr2_test.go @@ -10,7 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" @@ -19,9 +19,10 @@ import ( func TestForwarderOCR2Basic(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithMockServer(1). WithCLNodeConfig(node.NewConfig(node.NewBaseConfig(), @@ -60,7 +61,7 @@ func TestForwarderOCR2Basic(t *testing.T) { for i := range workerNodes { actions.AcceptAuthorizedReceiversOperator(t, operators[i], authorizedForwarders[i], []common.Address{workerNodeAddresses[i]}, env.EVMClient, env.ContractLoader) require.NoError(t, err, "Accepting Authorized Receivers on Operator shouldn't fail") - err = actions.TrackForwarderLocal(env.EVMClient, authorizedForwarders[i], workerNodes[i]) + err = actions.TrackForwarderLocal(env.EVMClient, authorizedForwarders[i], workerNodes[i], l) require.NoError(t, err, "failed to track forwarders") err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") @@ -89,7 +90,7 @@ func TestForwarderOCR2Basic(t *testing.T) { err = actions.ConfigureOCRv2AggregatorContracts(env.EVMClient, ocrv2Config, ocrInstances) require.NoError(t, err, "Error configuring OCRv2 aggregator contracts") - err = actions.StartNewOCR2Round(1, ocrInstances, env.EVMClient, time.Minute*10) + err = actions.StartNewOCR2Round(1, ocrInstances, env.EVMClient, time.Minute*10, l) require.NoError(t, err) answer, err := ocrInstances[0].GetLatestAnswer(context.Background()) @@ -100,7 +101,7 @@ func TestForwarderOCR2Basic(t *testing.T) { ocrRoundVal := (5 + i) % 10 err = env.MockServer.Client.SetValuePath("ocr2", ocrRoundVal) require.NoError(t, err) - err = actions.StartNewOCR2Round(int64(i), ocrInstances, env.EVMClient, time.Minute*10) + err = actions.StartNewOCR2Round(int64(i), ocrInstances, env.EVMClient, time.Minute*10, l) require.NoError(t, err) answer, err = ocrInstances[0].GetLatestAnswer(context.Background()) diff --git a/integration-tests/smoke/keeper_test.go b/integration-tests/smoke/keeper_test.go index a2ff0989924..0e4cb7ce041 100644 --- a/integration-tests/smoke/keeper_test.go +++ b/integration-tests/smoke/keeper_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/v2/core/store/models" @@ -86,7 +86,7 @@ func TestKeeperBasicSmoke(t *testing.T) { registryVersion := rv t.Run(fmt.Sprintf("registry_1_%d", registryVersion), func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, @@ -101,7 +101,7 @@ func TestKeeperBasicSmoke(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - _, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err := actions.CreateKeeperJobsLocal(l, 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") @@ -162,7 +162,7 @@ func TestKeeperBlockCountPerTurn(t *testing.T) { registryVersion := rv t.Run(fmt.Sprintf("registry_1_%d", registryVersion), func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, @@ -177,7 +177,7 @@ func TestKeeperBlockCountPerTurn(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - _, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err := actions.CreateKeeperJobsLocal(l, 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") @@ -266,6 +266,7 @@ func TestKeeperSimulation(t *testing.T) { registryVersion := rv t.Run(fmt.Sprintf("registry_1_%d", registryVersion), func(t *testing.T) { t.Parallel() + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, _, consumersPerformance, upkeepIDs := actions.DeployPerformanceKeeperContracts( t, @@ -284,7 +285,7 @@ func TestKeeperSimulation(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - _, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err := actions.CreateKeeperJobsLocal(l, 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") @@ -338,7 +339,7 @@ func TestKeeperCheckPerformGasLimit(t *testing.T) { registryVersion := rv t.Run(fmt.Sprintf("registry_1_%d", registryVersion), func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, _, consumersPerformance, upkeepIDs := actions.DeployPerformanceKeeperContracts( t, @@ -357,7 +358,7 @@ func TestKeeperCheckPerformGasLimit(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - _, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err := actions.CreateKeeperJobsLocal(l, 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") @@ -451,7 +452,7 @@ func TestKeeperRegisterUpkeep(t *testing.T) { registryVersion := rv t.Run(fmt.Sprintf("registry_1_%d", registryVersion), func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, registrar, consumers, upkeepIDs := actions.DeployKeeperContracts( t, @@ -466,7 +467,7 @@ func TestKeeperRegisterUpkeep(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - _, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err := actions.CreateKeeperJobsLocal(l, 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") @@ -540,6 +541,7 @@ func TestKeeperAddFunds(t *testing.T) { registryVersion := rv t.Run(fmt.Sprintf("registry_1_%d", registryVersion), func(t *testing.T) { t.Parallel() + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, @@ -554,7 +556,7 @@ func TestKeeperAddFunds(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - _, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err := actions.CreateKeeperJobsLocal(l, 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") @@ -602,7 +604,7 @@ func TestKeeperRemove(t *testing.T) { registryVersion := rv t.Run(fmt.Sprintf("registry_1_%d", registryVersion), func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, @@ -617,7 +619,7 @@ func TestKeeperRemove(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - _, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err := actions.CreateKeeperJobsLocal(l, 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") @@ -680,6 +682,7 @@ func TestKeeperPauseRegistry(t *testing.T) { registryVersion := rv t.Run(fmt.Sprintf("registry_1_%d", registryVersion), func(t *testing.T) { t.Parallel() + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, @@ -694,7 +697,7 @@ func TestKeeperPauseRegistry(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - _, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err := actions.CreateKeeperJobsLocal(l, 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") @@ -740,6 +743,7 @@ func TestKeeperPauseRegistry(t *testing.T) { func TestKeeperMigrateRegistry(t *testing.T) { t.Parallel() + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, @@ -754,7 +758,7 @@ func TestKeeperMigrateRegistry(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - _, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err := actions.CreateKeeperJobsLocal(l, 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") @@ -773,7 +777,7 @@ func TestKeeperMigrateRegistry(t *testing.T) { ) // Set the jobs for the second registry - _, err = actions.CreateKeeperJobsLocal(chainlinkNodes, secondRegistry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err = actions.CreateKeeperJobsLocal(l, 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") @@ -831,7 +835,7 @@ func TestKeeperNodeDown(t *testing.T) { registryVersion := rv t.Run(fmt.Sprintf("registry_1_%d", registryVersion), func(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, @@ -846,7 +850,7 @@ func TestKeeperNodeDown(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - jobs, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + jobs, err := actions.CreateKeeperJobsLocal(l, 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") @@ -937,7 +941,7 @@ type nodeAndJob struct { func TestKeeperPauseUnPauseUpkeep(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, _, consumers, upkeepIDs := actions.DeployKeeperContracts( t, @@ -952,7 +956,7 @@ func TestKeeperPauseUnPauseUpkeep(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - _, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err := actions.CreateKeeperJobsLocal(l, 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") @@ -1027,7 +1031,7 @@ func TestKeeperPauseUnPauseUpkeep(t *testing.T) { func TestKeeperUpdateCheckData(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, _ := setupKeeperTest(t) registry, _, performDataChecker, upkeepIDs := actions.DeployPerformDataCheckerContracts( t, @@ -1043,7 +1047,7 @@ func TestKeeperUpdateCheckData(t *testing.T) { ) gom := gomega.NewGomegaWithT(t) - _, err := actions.CreateKeeperJobsLocal(chainlinkNodes, registry, contracts.OCRv2Config{}, chainClient.GetChainID().String()) + _, err := actions.CreateKeeperJobsLocal(l, 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") @@ -1101,9 +1105,10 @@ func setupKeeperTest(t *testing.T) ( clNodeConfig.Keeper.TurnLookBack = &turnLookBack clNodeConfig.Keeper.Registry.SyncInterval = &syncInterval clNodeConfig.Keeper.Registry.PerformGasOverhead = &performGasOverhead - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithMockServer(1). WithCLNodes(5). diff --git a/integration-tests/smoke/ocr2_test.go b/integration-tests/smoke/ocr2_test.go index fe53d2cb6a7..db11f187f5a 100644 --- a/integration-tests/smoke/ocr2_test.go +++ b/integration-tests/smoke/ocr2_test.go @@ -16,9 +16,8 @@ import ( "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver" mockservercfg "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -29,9 +28,10 @@ import ( // Tests a basic OCRv2 median feed func TestOCRv2Basic(t *testing.T) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithMockServer(1). WithCLNodeConfig(node.NewConfig(node.NewBaseConfig(), @@ -81,7 +81,7 @@ func TestOCRv2Basic(t *testing.T) { err = actions.ConfigureOCRv2AggregatorContracts(env.EVMClient, ocrv2Config, aggregatorContracts) require.NoError(t, err, "Error configuring OCRv2 aggregator contracts") - err = actions.StartNewOCR2Round(1, aggregatorContracts, env.EVMClient, time.Minute*5) + err = actions.StartNewOCR2Round(1, aggregatorContracts, env.EVMClient, time.Minute*5, l) require.NoError(t, err, "Error starting new OCR2 round") roundData, err := aggregatorContracts[0].GetRound(context.Background(), big.NewInt(1)) require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail") @@ -92,7 +92,7 @@ func TestOCRv2Basic(t *testing.T) { err = env.MockServer.Client.SetValuePath("ocr2", 10) require.NoError(t, err) - err = actions.StartNewOCR2Round(2, aggregatorContracts, env.EVMClient, time.Minute*5) + err = actions.StartNewOCR2Round(2, aggregatorContracts, env.EVMClient, time.Minute*5, l) require.NoError(t, err) roundData, err = aggregatorContracts[0].GetRound(context.Background(), big.NewInt(2)) diff --git a/integration-tests/smoke/ocr2vrf_test.go b/integration-tests/smoke/ocr2vrf_test.go index 50a21b81d8e..c9f689ca7ae 100644 --- a/integration-tests/smoke/ocr2vrf_test.go +++ b/integration-tests/smoke/ocr2vrf_test.go @@ -13,9 +13,9 @@ import ( "github.com/smartcontractkit/chainlink-env/pkg/helm/chainlink" eth "github.com/smartcontractkit/chainlink-env/pkg/helm/ethereum" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/utils" - + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" + "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/actions/ocr2vrf_actions" @@ -28,15 +28,15 @@ import ( func TestOCR2VRFRedeemModel(t *testing.T) { t.Parallel() t.Skip("VRFv3 is on pause, skipping") - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) testEnvironment, testNetwork := setupOCR2VRFEnvironment(t) if testEnvironment.WillUseRemoteRunner() { return } - chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment) + chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment, l) require.NoError(t, err, "Error connecting to blockchain") - contractDeployer, err := contracts.NewContractDeployer(chainClient) + contractDeployer, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Error building contract deployer") chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) require.NoError(t, err, "Error connecting to Chainlink nodes") @@ -90,15 +90,15 @@ func TestOCR2VRFRedeemModel(t *testing.T) { func TestOCR2VRFFulfillmentModel(t *testing.T) { t.Parallel() t.Skip("VRFv3 is on pause, skipping") - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) testEnvironment, testNetwork := setupOCR2VRFEnvironment(t) if testEnvironment.WillUseRemoteRunner() { return } - chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment) + chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment, l) require.NoError(t, err, "Error connecting to blockchain") - contractDeployer, err := contracts.NewContractDeployer(chainClient) + contractDeployer, err := contracts.NewContractDeployer(chainClient, l) require.NoError(t, err, "Error building contract deployer") chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) require.NoError(t, err, "Error connecting to Chainlink nodes") diff --git a/integration-tests/smoke/ocr_test.go b/integration-tests/smoke/ocr_test.go index d8f905480c8..56d045fa097 100644 --- a/integration-tests/smoke/ocr_test.go +++ b/integration-tests/smoke/ocr_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" @@ -15,9 +15,10 @@ import ( func TestOCRBasic(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithMockServer(1). WithCLNodes(6). @@ -46,7 +47,7 @@ func TestOCRBasic(t *testing.T) { err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockServer.Client, env.EVMClient.GetChainID().String()) require.NoError(t, err) - err = actions.StartNewRound(1, ocrInstances, env.EVMClient) + err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l) require.NoError(t, err) answer, err := ocrInstances[0].GetLatestAnswer(context.Background()) @@ -55,7 +56,7 @@ func TestOCRBasic(t *testing.T) { err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockServer.Client) require.NoError(t, err) - err = actions.StartNewRound(2, ocrInstances, env.EVMClient) + err = actions.StartNewRound(2, ocrInstances, env.EVMClient, l) require.NoError(t, err) answer, err = ocrInstances[0].GetLatestAnswer(context.Background()) diff --git a/integration-tests/smoke/runlog_test.go b/integration-tests/smoke/runlog_test.go index 37fb4a76c53..0bfc41eca71 100644 --- a/integration-tests/smoke/runlog_test.go +++ b/integration-tests/smoke/runlog_test.go @@ -11,7 +11,7 @@ import ( "github.com/onsi/gomega" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" @@ -19,9 +19,10 @@ import ( func TestRunLogBasic(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithMockServer(1). WithCLNodes(1). diff --git a/integration-tests/smoke/vrf_test.go b/integration-tests/smoke/vrf_test.go index 3164fcf2329..47f8cd8e30f 100644 --- a/integration-tests/smoke/vrf_test.go +++ b/integration-tests/smoke/vrf_test.go @@ -11,7 +11,7 @@ import ( "github.com/onsi/gomega" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv1" @@ -21,9 +21,10 @@ import ( func TestVRFBasic(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithMockServer(1). WithCLNodes(1). diff --git a/integration-tests/smoke/vrfv2_test.go b/integration-tests/smoke/vrfv2_test.go index c34e60fe6bb..18e9efeae44 100644 --- a/integration-tests/smoke/vrfv2_test.go +++ b/integration-tests/smoke/vrfv2_test.go @@ -9,7 +9,7 @@ import ( "github.com/onsi/gomega" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions" @@ -20,9 +20,10 @@ import ( func TestVRFv2Basic(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithCLNodes(1). WithFunding(vrfConst.ChainlinkNodeFundingAmountEth). diff --git a/integration-tests/smoke/vrfv2plus_test.go b/integration-tests/smoke/vrfv2plus_test.go index 7fd4a580bc5..bec31c5681f 100644 --- a/integration-tests/smoke/vrfv2plus_test.go +++ b/integration-tests/smoke/vrfv2plus_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus" @@ -18,9 +18,10 @@ import ( func TestVRFv2PlusBilling(t *testing.T) { t.Parallel() - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). + WithTestLogger(t). WithGeth(). WithCLNodes(1). WithFunding(vrfv2plus_constants.ChainlinkNodeFundingAmountEth). diff --git a/integration-tests/soak/forwarder_ocr_test.go b/integration-tests/soak/forwarder_ocr_test.go index e8bcea0f5b8..bc02f367892 100644 --- a/integration-tests/soak/forwarder_ocr_test.go +++ b/integration-tests/soak/forwarder_ocr_test.go @@ -5,14 +5,14 @@ import ( "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/testsetups" ) func TestForwarderOCRSoak(t *testing.T) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) // Use this variable to pass in any custom EVM specific TOML values to your Chainlink nodes customNetworkTOML := `[EVM.Transactions] ForwardersEnabled = true` diff --git a/integration-tests/soak/ocr_test.go b/integration-tests/soak/ocr_test.go index c0fd0a4525f..b2375f13ac2 100644 --- a/integration-tests/soak/ocr_test.go +++ b/integration-tests/soak/ocr_test.go @@ -5,14 +5,14 @@ import ( "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/testsetups" ) func TestOCRSoak(t *testing.T) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) // Use this variable to pass in any custom EVM specific TOML values to your Chainlink nodes customNetworkTOML := `` // Uncomment below for debugging TOML issues on the node diff --git a/integration-tests/testsetups/don_evm_chain.go b/integration-tests/testsetups/don_evm_chain.go index a9e69b32f49..545d9515801 100644 --- a/integration-tests/testsetups/don_evm_chain.go +++ b/integration-tests/testsetups/don_evm_chain.go @@ -3,6 +3,7 @@ package testsetups import ( "testing" + "github.com/rs/zerolog" "github.com/stretchr/testify/require" e "github.com/smartcontractkit/chainlink-env/environment" @@ -25,6 +26,7 @@ type DonChain struct { LinkTokenContract contracts.LinkToken ChainlinkNodes []*client.ChainlinkK8sClient Mockserver *ctfClient.MockserverClient + l zerolog.Logger } type DonChainConfig struct { @@ -35,10 +37,11 @@ type DonChainConfig struct { ChainlinkValues map[string]interface{} } -func NewDonChain(conf *DonChainConfig) *DonChain { +func NewDonChain(conf *DonChainConfig, logger zerolog.Logger) *DonChain { return &DonChain{ conf: conf, EVMNetwork: conf.EVMNetwork, + l: logger, } } @@ -59,10 +62,10 @@ func (s *DonChain) Deploy() { func (s *DonChain) initializeClients() { var err error network := *s.conf.EVMNetwork - s.EVMClient, err = blockchain.NewEVMClient(network, s.conf.Env) + s.EVMClient, err = blockchain.NewEVMClient(network, s.conf.Env, s.l) require.NoError(s.conf.T, err, "Connecting to blockchain nodes shouldn't fail") - s.ContractDeployer, err = contracts.NewContractDeployer(s.EVMClient) + s.ContractDeployer, err = contracts.NewContractDeployer(s.EVMClient, s.l) require.NoError(s.conf.T, err) s.ChainlinkNodes, err = client.ConnectChainlinkNodes(s.conf.Env) diff --git a/integration-tests/testsetups/keeper_benchmark.go b/integration-tests/testsetups/keeper_benchmark.go index bdba3a67665..ba0cc23b23b 100644 --- a/integration-tests/testsetups/keeper_benchmark.go +++ b/integration-tests/testsetups/keeper_benchmark.go @@ -19,8 +19,8 @@ import ( "github.com/smartcontractkit/chainlink-env/environment" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink-testing-framework/logging" reportModel "github.com/smartcontractkit/chainlink-testing-framework/testreporters" - "github.com/smartcontractkit/chainlink-testing-framework/utils" iregistry21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_1" @@ -100,7 +100,7 @@ func NewKeeperBenchmarkTest(inputs KeeperBenchmarkTestInputs) *KeeperBenchmarkTe // Setup prepares contracts for the test func (k *KeeperBenchmarkTest) Setup(t *testing.T, env *environment.Environment) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) startTime := time.Now() k.TestReporter.Summary.StartTime = startTime.UnixMilli() k.ensureInputValues(t) @@ -116,7 +116,7 @@ func (k *KeeperBenchmarkTest) Setup(t *testing.T, env *environment.Environment) var err error // Connect to networks and prepare for contract deployment - k.contractDeployer, err = contracts.NewContractDeployer(k.chainClient) + k.contractDeployer, err = contracts.NewContractDeployer(k.chainClient, l) require.NoError(t, err, "Building a new contract deployer shouldn't fail") k.chainlinkNodes, err = client.ConnectChainlinkNodes(k.env) require.NoError(t, err, "Connecting to chainlink nodes shouldn't fail") @@ -202,7 +202,7 @@ func (k *KeeperBenchmarkTest) Setup(t *testing.T, env *environment.Environment) // Run runs the keeper benchmark test func (k *KeeperBenchmarkTest) Run(t *testing.T) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) u := k.Inputs.Upkeeps k.TestReporter.Summary.Load.TotalCheckGasPerBlock = int64(u.NumberOfUpkeeps) * u.CheckGasToBurn k.TestReporter.Summary.Load.TotalPerformGasPerBlock = int64((float64(u.NumberOfUpkeeps) / @@ -264,6 +264,7 @@ func (k *KeeperBenchmarkTest) Run(t *testing.T) { &k.TestReporter, int64(index), inputs.Upkeeps.FirstEligibleBuffer, + l, ), ) } @@ -323,7 +324,7 @@ func (k *KeeperBenchmarkTest) subscribeToUpkeepPerformedEvent( metricsReporter *testreporters.KeeperBenchmarkTestReporter, rIndex int, ) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) contractABI, err := keeper_registry_wrapper1_1.KeeperRegistryMetaData.GetAbi() require.NoError(t, err, "Error getting ABI") switch k.Inputs.RegistryVersions[rIndex] { @@ -476,7 +477,7 @@ func (k *KeeperBenchmarkTest) DeployBenchmarkKeeperContracts( t *testing.T, index int, ) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) registryVersion := k.Inputs.RegistryVersions[index] k.Inputs.KeeperRegistrySettings.RegistryVersion = registryVersion upkeep := k.Inputs.Upkeeps @@ -587,7 +588,7 @@ func DeployKeeperConsumersBenchmark( contractDeployer contracts.ContractDeployer, client blockchain.EVMClient, ) contracts.AutomationConsumerBenchmark { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) // Deploy consumer keeperConsumerInstance, err := contractDeployer.DeployKeeperConsumerBenchmark() diff --git a/integration-tests/testsetups/ocr.go b/integration-tests/testsetups/ocr.go index c0e84525822..5f12995cc06 100644 --- a/integration-tests/testsetups/ocr.go +++ b/integration-tests/testsetups/ocr.go @@ -22,7 +22,6 @@ import ( "github.com/kelseyhightower/envconfig" "github.com/pelletier/go-toml/v2" "github.com/rs/zerolog" - "github.com/rs/zerolog/log" "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-env/environment" @@ -32,8 +31,8 @@ import ( mockservercfg "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" + "github.com/smartcontractkit/chainlink-testing-framework/logging" reportModel "github.com/smartcontractkit/chainlink-testing-framework/testreporters" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/libocr/gethwrappers/offchainaggregator" "github.com/smartcontractkit/chainlink-testing-framework/networks" @@ -115,7 +114,7 @@ func NewOCRSoakTest(t *testing.T, forwarderFlow bool) (*OCRSoakTest, error) { t: t, startTime: time.Now(), timeLeft: testInputs.TestDuration, - log: utils.GetTestLogger(t), + log: logging.GetTestLogger(t), ocrRoundStates: make([]*testreporters.OCRRoundState, 0), ocrInstanceMap: make(map[string]contracts.OffchainAggregator), } @@ -165,7 +164,7 @@ func (o *OCRSoakTest) LoadEnvironment(chainlinkURLs []string, chainURL, mockServ network = networks.SelectedNetwork err error ) - o.chainClient, err = blockchain.ConnectEVMClient(network) + o.chainClient, err = blockchain.ConnectEVMClient(network, o.log) require.NoError(o.t, err, "Error connecting to EVM client") chainlinkNodes, err := client.ConnectChainlinkNodeURLs(chainlinkURLs) require.NoError(o.t, err, "Error connecting to chainlink nodes") @@ -187,9 +186,9 @@ func (o *OCRSoakTest) Setup() { // Environment currently being used to soak test on // Make connections to soak test resources - o.chainClient, err = blockchain.NewEVMClient(network, o.testEnvironment) + o.chainClient, err = blockchain.NewEVMClient(network, o.testEnvironment, o.log) require.NoError(o.t, err, "Error creating EVM client") - contractDeployer, err := contracts.NewContractDeployer(o.chainClient) + contractDeployer, err := contracts.NewContractDeployer(o.chainClient, o.log) require.NoError(o.t, err, "Unable to create contract deployer") require.NotNil(o.t, contractDeployer, "Contract deployer shouldn't be nil") nodes, err := client.ConnectChainlinkNodes(o.testEnvironment) @@ -207,7 +206,7 @@ func (o *OCRSoakTest) Setup() { require.NoError(o.t, err, "Error funding Chainlink nodes") if o.OperatorForwarderFlow { - contractLoader, err := contracts.NewContractLoader(o.chainClient) + contractLoader, err := contracts.NewContractLoader(o.chainClient, o.log) require.NoError(o.t, err, "Loading contracts shouldn't fail") operators, authorizedForwarders, _ := actions.DeployForwarderContracts( @@ -385,11 +384,11 @@ func (o *OCRSoakTest) LoadState() error { o.startingBlockNum = testState.StartingBlockNum network := networks.SelectedNetwork - o.chainClient, err = blockchain.ConnectEVMClient(network) + o.chainClient, err = blockchain.ConnectEVMClient(network, o.log) if err != nil { return err } - contractDeployer, err := contracts.NewContractDeployer(o.chainClient) + contractDeployer, err := contracts.NewContractDeployer(o.chainClient, o.log) if err != nil { return err } @@ -424,7 +423,7 @@ func (o *OCRSoakTest) Resume() { StartTime: time.Now(), Message: "Test Resumed", }) - log.Info(). + o.log.Info(). Str("Total Duration", o.Inputs.TestDuration.String()). Str("Time Left", o.timeLeft.String()). Msg("Resuming OCR Soak Test") @@ -447,7 +446,7 @@ func (o *OCRSoakTest) Resume() { o.log.Info().Msg("Test Complete, collecting on-chain events") err = o.collectEvents() - log.Error().Err(err).Interface("Query", o.filterQuery).Msg("Error collecting on-chain events, expect malformed report") + o.log.Error().Err(err).Interface("Query", o.filterQuery).Msg("Error collecting on-chain events, expect malformed report") o.TestReporter.RecordEvents(o.ocrRoundStates, o.testIssues) } @@ -485,7 +484,7 @@ func (o *OCRSoakTest) testLoop(testDuration time.Duration, newValue int) { if err := o.SaveState(); err != nil { o.log.Error().Err(err).Msg("Error saving state") } - log.Warn().Str("Time Taken", time.Since(saveStart).String()).Msg("Saved state") + o.log.Warn().Str("Time Taken", time.Since(saveStart).String()).Msg("Saved state") os.Exit(2) // Exit with code 2 to indicate test was interrupted, not just a normal failure case <-endTest: return @@ -526,7 +525,7 @@ func (o *OCRSoakTest) complete() { err := o.collectEvents() if err != nil { - log.Error().Err(err).Interface("Query", o.filterQuery).Msg("Error collecting on-chain events, expect malformed report") + o.log.Error().Err(err).Interface("Query", o.filterQuery).Msg("Error collecting on-chain events, expect malformed report") } o.TestReporter.RecordEvents(o.ocrRoundStates, o.testIssues) } @@ -544,7 +543,7 @@ func (o *OCRSoakTest) setFilterQuery() { Topics: [][]common.Hash{{contractABI.Events["AnswerUpdated"].ID}}, FromBlock: big.NewInt(0).SetUint64(o.startingBlockNum), } - log.Debug(). + o.log.Debug(). Interface("Addresses", ocrAddresses). Str("Topic", contractABI.Events["AnswerUpdated"].ID.Hex()). Uint64("Starting Block", o.startingBlockNum). @@ -569,7 +568,7 @@ func (o *OCRSoakTest) observeOCREvents() error { case event := <-eventLogs: answerUpdated, err := o.ocrInstances[0].ParseEventAnswerUpdated(event) if err != nil { - log.Warn(). + o.log.Warn(). Err(err). Str("Address", event.Address.Hex()). Uint64("Block Number", event.BlockNumber). @@ -634,18 +633,18 @@ func (o *OCRSoakTest) collectEvents() error { // We must retrieve the events, use exponential backoff for timeout to retry timeout := time.Second * 15 - log.Info().Interface("Filter Query", o.filterQuery).Str("Timeout", timeout.String()).Msg("Retrieving on-chain events") + o.log.Info().Interface("Filter Query", o.filterQuery).Str("Timeout", timeout.String()).Msg("Retrieving on-chain events") ctx, cancel := context.WithTimeout(context.Background(), timeout) contractEvents, err := o.chainClient.FilterLogs(ctx, o.filterQuery) cancel() for err != nil { - log.Info().Interface("Filter Query", o.filterQuery).Str("Timeout", timeout.String()).Msg("Retrieving on-chain events") + o.log.Info().Interface("Filter Query", o.filterQuery).Str("Timeout", timeout.String()).Msg("Retrieving on-chain events") ctx, cancel := context.WithTimeout(context.Background(), timeout) contractEvents, err = o.chainClient.FilterLogs(ctx, o.filterQuery) cancel() if err != nil { - log.Warn().Interface("Filter Query", o.filterQuery).Str("Timeout", timeout.String()).Msg("Error collecting on-chain events, trying again") + o.log.Warn().Interface("Filter Query", o.filterQuery).Str("Timeout", timeout.String()).Msg("Error collecting on-chain events, trying again") timeout *= 2 } } diff --git a/integration-tests/testsetups/vrfv2.go b/integration-tests/testsetups/vrfv2.go index 7afe9cf2cca..cfa26e8f279 100644 --- a/integration-tests/testsetups/vrfv2.go +++ b/integration-tests/testsetups/vrfv2.go @@ -16,8 +16,8 @@ import ( "github.com/smartcontractkit/chainlink-env/environment" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink-testing-framework/logging" reportModel "github.com/smartcontractkit/chainlink-testing-framework/testreporters" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" @@ -80,7 +80,7 @@ func (v *VRFV2SoakTest) Setup(t *testing.T, env *environment.Environment) { // Run starts the VRFV2 soak test func (v *VRFV2SoakTest) Run(t *testing.T) { - l := utils.GetTestLogger(t) + l := logging.GetTestLogger(t) l.Info(). Str("Test Duration", v.Inputs.TestDuration.Truncate(time.Second).String()). Int("Max number of requests per minute wanted", v.Inputs.RequestsPerMinute).