From f5d6797e4f0af7a7d8e634b31daaecc098548c8c Mon Sep 17 00:00:00 2001 From: Tate Date: Tue, 7 Nov 2023 12:21:32 -0700 Subject: [PATCH] [TT-681] Remove usages of github.com/pkg/errors (#11213) --- integration-tests/actions/actions.go | 18 +-- integration-tests/actions/actions_local.go | 5 +- .../actions/automation_ocr_helpers_local.go | 3 +- .../actions/ocr_helpers_local.go | 9 +- integration-tests/actions/vrfv1/actions.go | 9 +- .../actions/vrfv2_actions/vrfv2_steps.go | 27 ++-- .../actions/vrfv2plus/vrfv2plus_steps.go | 127 +++++++++--------- .../contracts/ethereum_contracts.go | 5 +- .../contracts/ethereum_ocr2vrf_contracts.go | 23 ++-- integration-tests/docker/test_env/cl_node.go | 5 +- .../docker/test_env/cl_node_cluster.go | 5 +- integration-tests/docker/test_env/test_env.go | 12 +- .../docker/test_env/test_env_builder.go | 8 +- integration-tests/go.mod | 4 +- integration-tests/go.sum | 4 +- integration-tests/load/functions/config.go | 13 +- integration-tests/load/functions/gateway.go | 20 +-- integration-tests/load/functions/setup.go | 24 ++-- integration-tests/load/vrfv2/config.go | 11 +- integration-tests/load/vrfv2/vu.go | 7 +- integration-tests/load/vrfv2plus/config.go | 11 +- integration-tests/reorg/reorg_confirmer.go | 8 +- integration-tests/smoke/ocr2_test.go | 49 ------- integration-tests/smoke/ocr2vrf_test.go | 5 +- integration-tests/smoke/vrfv2plus_test.go | 8 +- 25 files changed, 189 insertions(+), 231 deletions(-) diff --git a/integration-tests/actions/actions.go b/integration-tests/actions/actions.go index b45b8e83b95..bacf5a9dbfa 100644 --- a/integration-tests/actions/actions.go +++ b/integration-tests/actions/actions.go @@ -5,16 +5,16 @@ import ( "crypto/ecdsa" "encoding/json" "fmt" - "github.com/ethereum/go-ethereum/crypto" "math/big" "strings" "testing" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" - "github.com/pkg/errors" "github.com/rs/zerolog/log" "go.uber.org/zap/zapcore" @@ -262,7 +262,7 @@ func TeardownSuite( ) error { 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") + return fmt.Errorf("Error dumping environment logs, leaving environment running for manual retrieval, err: %w", err) } // Delete all jobs to stop depleting the funds err := DeleteAllJobs(chainlinkNodes) @@ -330,16 +330,16 @@ func DeleteAllJobs(chainlinkNodes []*client.ChainlinkK8sClient) error { } jobs, _, err := node.ReadJobs() if err != nil { - return errors.Wrap(err, "error reading jobs from chainlink node") + return fmt.Errorf("error reading jobs from chainlink node, err: %w", err) } for _, maps := range jobs.Data { if _, ok := maps["id"]; !ok { - return errors.Errorf("error reading job id from chainlink node's jobs %+v", jobs.Data) + return fmt.Errorf("error reading job id from chainlink node's jobs %+v", jobs.Data) } id := maps["id"].(string) _, err := node.DeleteJob(id) if err != nil { - return errors.Wrap(err, "error deleting job from chainlink node") + return fmt.Errorf("error deleting job from chainlink node, err: %w", err) } } } @@ -350,7 +350,7 @@ func DeleteAllJobs(chainlinkNodes []*client.ChainlinkK8sClient) error { // all from a remote, k8s style environment func ReturnFunds(chainlinkNodes []*client.ChainlinkK8sClient, blockchainClient blockchain.EVMClient) error { if blockchainClient == nil { - return errors.New("blockchain client is nil, unable to return funds from chainlink nodes") + return fmt.Errorf("blockchain client is nil, unable to return funds from chainlink nodes") } log.Info().Msg("Attempting to return Chainlink node funds to default network wallets") if blockchainClient.NetworkSimulated() { @@ -416,7 +416,7 @@ func UpgradeChainlinkNodeVersions( nodes ...*client.ChainlinkK8sClient, ) error { if newImage == "" && newVersion == "" { - return errors.New("unable to upgrade node version, found empty image and version, must provide either a new image or a new version") + return fmt.Errorf("unable to upgrade node version, found empty image and version, must provide either a new image or a new version") } for _, node := range nodes { if err := node.UpgradeVersion(testEnvironment, newImage, newVersion); err != nil { @@ -455,7 +455,7 @@ func GenerateWallet() (common.Address, error) { publicKey := privateKey.Public() publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) if !ok { - return common.Address{}, errors.New("cannot assert type: publicKey is not of type *ecdsa.PublicKey") + return common.Address{}, fmt.Errorf("cannot assert type: publicKey is not of type *ecdsa.PublicKey") } return crypto.PubkeyToAddress(*publicKeyECDSA), nil } diff --git a/integration-tests/actions/actions_local.go b/integration-tests/actions/actions_local.go index b65bac43bb1..f5d2a9035f5 100644 --- a/integration-tests/actions/actions_local.go +++ b/integration-tests/actions/actions_local.go @@ -2,7 +2,8 @@ package actions import ( - "github.com/pkg/errors" + "fmt" + "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" ) @@ -13,7 +14,7 @@ func UpgradeChainlinkNodeVersionsLocal( nodes ...*test_env.ClNode, ) error { if newImage == "" && newVersion == "" { - return errors.New("unable to upgrade node version, found empty image and version, must provide either a new image or a new version") + return fmt.Errorf("unable to upgrade node version, found empty image and version, must provide either a new image or a new version") } for _, node := range nodes { if err := node.UpgradeVersion(node.NodeConfig, newImage, newVersion); err != nil { diff --git a/integration-tests/actions/automation_ocr_helpers_local.go b/integration-tests/actions/automation_ocr_helpers_local.go index ccc2eea99d8..f541594c4d2 100644 --- a/integration-tests/actions/automation_ocr_helpers_local.go +++ b/integration-tests/actions/automation_ocr_helpers_local.go @@ -8,7 +8,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/lib/pq" - "github.com/pkg/errors" "github.com/rs/zerolog" ocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" ocr3 "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper" @@ -187,7 +186,7 @@ func CreateOCRKeeperJobsLocal( } else if registryVersion == ethereum.RegistryVersion_2_0 { contractVersion = "v2.0" } else { - return errors.New("v2.0 and v2.1 are the only supported versions") + return fmt.Errorf("v2.0 and v2.1 are the only supported versions") } bootstrapSpec := &client.OCR2TaskJobSpec{ diff --git a/integration-tests/actions/ocr_helpers_local.go b/integration-tests/actions/ocr_helpers_local.go index 8bb4e834794..5836ee7945c 100644 --- a/integration-tests/actions/ocr_helpers_local.go +++ b/integration-tests/actions/ocr_helpers_local.go @@ -9,7 +9,6 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" - "github.com/pkg/errors" "github.com/rs/zerolog" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" @@ -280,7 +279,7 @@ func TrackForwarderLocal( chainID := chainClient.GetChainID() _, _, err := node.TrackForwarder(chainID, authorizedForwarder) if err != nil { - return errors.Wrap(err, "failed to track forwarder") + return fmt.Errorf("failed to track forwarder, err: %w", err) } logger.Info().Str("NodeURL", node.Config.URL). Str("ForwarderAddress", authorizedForwarder.Hex()). @@ -305,7 +304,7 @@ func DeployOCRContractsForwarderFlowLocal( contracts.DefaultOffChainAggregatorOptions(), ) if err != nil { - return nil, errors.Wrap(err, "failed to deploy offchain aggregator") + return nil, fmt.Errorf("failed to deploy offchain aggregator, err: %w", err) } ocrInstances = append(ocrInstances, ocrInstance) err = client.WaitForEvents() @@ -329,7 +328,7 @@ func DeployOCRContractsForwarderFlowLocal( for _, ocrInstance := range ocrInstances { err := ocrInstance.SetPayees(transmitters, payees) if err != nil { - return nil, errors.Wrap(err, "failed to set OCR payees") + return nil, fmt.Errorf("failed to set OCR payees, err: %w", err) } if err := client.WaitForEvents(); err != nil { return nil, err @@ -348,7 +347,7 @@ func DeployOCRContractsForwarderFlowLocal( forwarderAddresses, ) if err != nil { - return nil, errors.Wrap(err, "failed to set on-chain config") + return nil, fmt.Errorf("failed to set on-chain config, err: %w", err) } if err = client.WaitForEvents(); err != nil { return nil, err diff --git a/integration-tests/actions/vrfv1/actions.go b/integration-tests/actions/vrfv1/actions.go index 68d3e584cee..f8d7190709f 100644 --- a/integration-tests/actions/vrfv1/actions.go +++ b/integration-tests/actions/vrfv1/actions.go @@ -1,7 +1,8 @@ package vrfv1 import ( - "github.com/pkg/errors" + "fmt" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink/integration-tests/contracts" ) @@ -21,15 +22,15 @@ type Contracts struct { func DeployVRFContracts(cd contracts.ContractDeployer, bc blockchain.EVMClient, lt contracts.LinkToken) (*Contracts, error) { bhs, err := cd.DeployBlockhashStore() if err != nil { - return nil, errors.Wrap(err, ErrDeployBHSV1) + return nil, fmt.Errorf("%s, err %w", ErrDeployBHSV1, err) } coordinator, err := cd.DeployVRFCoordinator(lt.Address(), bhs.Address()) if err != nil { - return nil, errors.Wrap(err, ErrDeployVRFCootrinatorV1) + return nil, fmt.Errorf("%s, err %w", ErrDeployVRFCootrinatorV1, err) } consumer, err := cd.DeployVRFConsumer(lt.Address(), coordinator.Address()) if err != nil { - return nil, errors.Wrap(err, ErrDeployVRFConsumerV1) + return nil, fmt.Errorf("%s, err %w", ErrDeployVRFConsumerV1, err) } if err := bc.WaitForEvents(); err != nil { return nil, err diff --git a/integration-tests/actions/vrfv2_actions/vrfv2_steps.go b/integration-tests/actions/vrfv2_actions/vrfv2_steps.go index 24ac217a334..a832d020b0f 100644 --- a/integration-tests/actions/vrfv2_actions/vrfv2_steps.go +++ b/integration-tests/actions/vrfv2_actions/vrfv2_steps.go @@ -6,7 +6,6 @@ import ( "math/big" "github.com/google/uuid" - "github.com/pkg/errors" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" chainlinkutils "github.com/smartcontractkit/chainlink/v2/core/utils" @@ -43,15 +42,15 @@ func DeployVRFV2Contracts( ) (*VRFV2Contracts, error) { bhs, err := contractDeployer.DeployBlockhashStore() if err != nil { - return nil, errors.Wrap(err, ErrDeployBlockHashStore) + return nil, fmt.Errorf("%s, err %w", ErrDeployBlockHashStore, err) } coordinator, err := contractDeployer.DeployVRFCoordinatorV2(linkTokenContract.Address(), bhs.Address(), linkEthFeedContract.Address()) if err != nil { - return nil, errors.Wrap(err, ErrDeployCoordinator) + return nil, fmt.Errorf("%s, err %w", ErrDeployCoordinator, err) } loadTestConsumer, err := contractDeployer.DeployVRFv2LoadTestConsumer(coordinator.Address()) if err != nil { - return nil, errors.Wrap(err, ErrAdvancedConsumer) + return nil, fmt.Errorf("%s, err %w", ErrAdvancedConsumer, err) } err = chainClient.WaitForEvents() if err != nil { @@ -70,7 +69,7 @@ func CreateVRFV2Jobs( for _, chainlinkNode := range chainlinkNodes { vrfKey, err := chainlinkNode.MustCreateVRFKey() if err != nil { - return nil, errors.Wrap(err, ErrCreatingVRFv2Key) + return nil, fmt.Errorf("%s, err %w", ErrCreatingVRFv2Key, err) } pubKeyCompressed := vrfKey.Data.ID jobUUID := uuid.New() @@ -79,11 +78,11 @@ func CreateVRFV2Jobs( } ost, err := os.String() if err != nil { - return nil, errors.Wrap(err, ErrParseJob) + return nil, fmt.Errorf("%s, err %w", ErrParseJob, err) } nativeTokenPrimaryKeyAddress, err := chainlinkNode.PrimaryEthAddress() if err != nil { - return nil, errors.Wrap(err, ErrNodePrimaryKey) + return nil, fmt.Errorf("%s, err %w", ErrNodePrimaryKey, err) } job, err := chainlinkNode.MustCreateJob(&client.VRFV2JobSpec{ Name: fmt.Sprintf("vrf-%s", jobUUID), @@ -97,15 +96,15 @@ func CreateVRFV2Jobs( BatchFulfillmentEnabled: false, }) if err != nil { - return nil, errors.Wrap(err, ErrCreatingVRFv2Job) + return nil, fmt.Errorf("%s, err %w", ErrCreatingVRFv2Job, err) } provingKey, err := VRFV2RegisterProvingKey(vrfKey, nativeTokenPrimaryKeyAddress, coordinator) if err != nil { - return nil, errors.Wrap(err, ErrCreatingProvingKey) + return nil, fmt.Errorf("%s, err %w", ErrCreatingProvingKey, err) } keyHash, err := coordinator.HashOfKey(context.Background(), provingKey) if err != nil { - return nil, errors.Wrap(err, ErrCreatingProvingKeyHash) + return nil, fmt.Errorf("%s, err %w", ErrCreatingProvingKeyHash, err) } ji := VRFV2JobInfo{ Job: job, @@ -125,14 +124,14 @@ func VRFV2RegisterProvingKey( ) (VRFV2EncodedProvingKey, error) { provingKey, err := actions.EncodeOnChainVRFProvingKey(*vrfKey) if err != nil { - return VRFV2EncodedProvingKey{}, errors.Wrap(err, ErrEncodingProvingKey) + return VRFV2EncodedProvingKey{}, fmt.Errorf("%s, err %w", ErrEncodingProvingKey, err) } err = coordinator.RegisterProvingKey( oracleAddress, provingKey, ) if err != nil { - return VRFV2EncodedProvingKey{}, errors.Wrap(err, ErrRegisterProvingKey) + return VRFV2EncodedProvingKey{}, fmt.Errorf("%s, err %w", ErrRegisterProvingKey, err) } return provingKey, nil } @@ -140,11 +139,11 @@ func VRFV2RegisterProvingKey( func FundVRFCoordinatorV2Subscription(linkToken contracts.LinkToken, coordinator contracts.VRFCoordinatorV2, chainClient blockchain.EVMClient, subscriptionID uint64, linkFundingAmount *big.Int) error { encodedSubId, err := chainlinkutils.ABIEncode(`[{"type":"uint64"}]`, subscriptionID) if err != nil { - return errors.Wrap(err, ErrABIEncodingFunding) + return fmt.Errorf("%s, err %w", ErrABIEncodingFunding, err) } _, err = linkToken.TransferAndCall(coordinator.Address(), big.NewInt(0).Mul(linkFundingAmount, big.NewInt(1e18)), encodedSubId) if err != nil { - return errors.Wrap(err, ErrSendingLinkToken) + return fmt.Errorf("%s, err %w", ErrSendingLinkToken, err) } return chainClient.WaitForEvents() } diff --git a/integration-tests/actions/vrfv2plus/vrfv2plus_steps.go b/integration-tests/actions/vrfv2plus/vrfv2plus_steps.go index e720116c210..e964623fb2e 100644 --- a/integration-tests/actions/vrfv2plus/vrfv2plus_steps.go +++ b/integration-tests/actions/vrfv2plus/vrfv2plus_steps.go @@ -3,17 +3,17 @@ package vrfv2plus import ( "context" "fmt" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "math/big" "sync" "time" + "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/v2/core/assets" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrfv2plus_wrapper_load_test_consumer" "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" - "github.com/pkg/errors" "github.com/rs/zerolog" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink/integration-tests/actions" @@ -71,19 +71,19 @@ func DeployVRFV2_5Contracts( ) (*VRFV2_5Contracts, error) { bhs, err := contractDeployer.DeployBlockhashStore() if err != nil { - return nil, errors.Wrap(err, ErrDeployBlockHashStore) + return nil, fmt.Errorf("%s, err %w", ErrDeployBlockHashStore, err) } err = chainClient.WaitForEvents() if err != nil { - return nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } coordinator, err := contractDeployer.DeployVRFCoordinatorV2_5(bhs.Address()) if err != nil { - return nil, errors.Wrap(err, ErrDeployCoordinator) + return nil, fmt.Errorf("%s, err %w", ErrDeployCoordinator, err) } err = chainClient.WaitForEvents() if err != nil { - return nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } consumers, err := DeployVRFV2PlusConsumers(contractDeployer, coordinator, consumerContractsAmount) if err != nil { @@ -91,7 +91,7 @@ func DeployVRFV2_5Contracts( } err = chainClient.WaitForEvents() if err != nil { - return nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } return &VRFV2_5Contracts{coordinator, bhs, consumers}, nil } @@ -107,11 +107,11 @@ func DeployVRFV2PlusDirectFundingContracts( vrfv2PlusWrapper, err := contractDeployer.DeployVRFV2PlusWrapper(linkTokenAddress, linkEthFeedAddress, coordinator.Address()) if err != nil { - return nil, errors.Wrap(err, ErrDeployWrapper) + return nil, fmt.Errorf("%s, err %w", ErrDeployWrapper, err) } err = chainClient.WaitForEvents() if err != nil { - return nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } consumers, err := DeployVRFV2PlusWrapperConsumers(contractDeployer, linkTokenAddress, vrfv2PlusWrapper, consumerContractsAmount) @@ -120,7 +120,7 @@ func DeployVRFV2PlusDirectFundingContracts( } err = chainClient.WaitForEvents() if err != nil { - return nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } return &VRFV2PlusWrapperContracts{vrfv2PlusWrapper, consumers}, nil } @@ -130,7 +130,7 @@ func DeployVRFV2PlusConsumers(contractDeployer contracts.ContractDeployer, coord for i := 1; i <= consumerContractsAmount; i++ { loadTestConsumer, err := contractDeployer.DeployVRFv2PlusLoadTestConsumer(coordinator.Address()) if err != nil { - return nil, errors.Wrap(err, ErrAdvancedConsumer) + return nil, fmt.Errorf("%s, err %w", ErrAdvancedConsumer, err) } consumers = append(consumers, loadTestConsumer) } @@ -142,7 +142,7 @@ func DeployVRFV2PlusWrapperConsumers(contractDeployer contracts.ContractDeployer for i := 1; i <= consumerContractsAmount; i++ { loadTestConsumer, err := contractDeployer.DeployVRFV2PlusWrapperLoadTestConsumer(linkTokenAddress, vrfV2PlusWrapper.Address()) if err != nil { - return nil, errors.Wrap(err, ErrAdvancedConsumer) + return nil, fmt.Errorf("%s, err %w", ErrAdvancedConsumer, err) } consumers = append(consumers, loadTestConsumer) } @@ -163,7 +163,7 @@ func CreateVRFV2PlusJob( } ost, err := os.String() if err != nil { - return nil, errors.Wrap(err, ErrParseJob) + return nil, fmt.Errorf("%s, err %w", ErrParseJob, err) } job, err := chainlinkNode.MustCreateJob(&client.VRFV2PlusJobSpec{ @@ -178,7 +178,7 @@ func CreateVRFV2PlusJob( BatchFulfillmentEnabled: false, }) if err != nil { - return nil, errors.Wrap(err, ErrCreatingVRFv2PlusJob) + return nil, fmt.Errorf("%s, err %w", ErrCreatingVRFv2PlusJob, err) } return job, nil @@ -191,14 +191,14 @@ func VRFV2_5RegisterProvingKey( ) (VRFV2PlusEncodedProvingKey, error) { provingKey, err := actions.EncodeOnChainVRFProvingKey(*vrfKey) if err != nil { - return VRFV2PlusEncodedProvingKey{}, errors.Wrap(err, ErrEncodingProvingKey) + return VRFV2PlusEncodedProvingKey{}, fmt.Errorf("%s, err %w", ErrEncodingProvingKey, err) } err = coordinator.RegisterProvingKey( oracleAddress, provingKey, ) if err != nil { - return VRFV2PlusEncodedProvingKey{}, errors.Wrap(err, ErrRegisterProvingKey) + return VRFV2PlusEncodedProvingKey{}, fmt.Errorf("%s, err %w", ErrRegisterProvingKey, err) } return provingKey, nil } @@ -210,14 +210,14 @@ func VRFV2PlusUpgradedVersionRegisterProvingKey( ) (VRFV2PlusEncodedProvingKey, error) { provingKey, err := actions.EncodeOnChainVRFProvingKey(*vrfKey) if err != nil { - return VRFV2PlusEncodedProvingKey{}, errors.Wrap(err, ErrEncodingProvingKey) + return VRFV2PlusEncodedProvingKey{}, fmt.Errorf("%s, err %w", ErrEncodingProvingKey, err) } err = coordinator.RegisterProvingKey( oracleAddress, provingKey, ) if err != nil { - return VRFV2PlusEncodedProvingKey{}, errors.Wrap(err, ErrRegisterProvingKey) + return VRFV2PlusEncodedProvingKey{}, fmt.Errorf("%s, err %w", ErrRegisterProvingKey, err) } return provingKey, nil } @@ -231,11 +231,11 @@ func FundVRFCoordinatorV2_5Subscription( ) error { encodedSubId, err := chainlinkutils.ABIEncode(`[{"type":"uint256"}]`, subscriptionID) if err != nil { - return errors.Wrap(err, ErrABIEncodingFunding) + return fmt.Errorf("%s, err %w", ErrABIEncodingFunding, err) } _, err = linkToken.TransferAndCall(coordinator.Address(), linkFundingAmountJuels, encodedSubId) if err != nil { - return errors.Wrap(err, ErrSendingLinkToken) + return fmt.Errorf("%s, err %w", ErrSendingLinkToken, err) } return chainClient.WaitForEvents() } @@ -255,7 +255,7 @@ func SetupVRFV2_5Environment( l.Info().Msg("Deploying VRFV2 Plus contracts") vrfv2_5Contracts, err := DeployVRFV2_5Contracts(env.ContractDeployer, env.EVMClient, numberOfConsumers) if err != nil { - return nil, nil, nil, errors.Wrap(err, ErrDeployVRFV2_5Contracts) + return nil, nil, nil, fmt.Errorf("%s, err %w", ErrDeployVRFV2_5Contracts, err) } l.Info().Str("Coordinator", vrfv2_5Contracts.Coordinator.Address()).Msg("Setting Coordinator Config") @@ -271,17 +271,17 @@ func SetupVRFV2_5Environment( }, ) if err != nil { - return nil, nil, nil, errors.Wrap(err, ErrSetVRFCoordinatorConfig) + return nil, nil, nil, fmt.Errorf("%s, err %w", ErrSetVRFCoordinatorConfig, err) } l.Info().Str("Coordinator", vrfv2_5Contracts.Coordinator.Address()).Msg("Setting Link and ETH/LINK feed") err = vrfv2_5Contracts.Coordinator.SetLINKAndLINKNativeFeed(linkToken.Address(), mockNativeLINKFeed.Address()) if err != nil { - return nil, nil, nil, errors.Wrap(err, ErrSetLinkNativeLinkFeed) + return nil, nil, nil, fmt.Errorf("%s, err %w", ErrSetLinkNativeLinkFeed, err) } err = env.EVMClient.WaitForEvents() if err != nil { - return nil, nil, nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, nil, nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } l.Info().Str("Coordinator", vrfv2_5Contracts.Coordinator.Address()).Int("Number of Subs to create", numberOfSubToCreate).Msg("Creating and funding subscriptions, adding consumers") subIDs, err := CreateFundSubsAndAddConsumers( @@ -295,25 +295,25 @@ func SetupVRFV2_5Environment( l.Info().Str("Node URL", env.ClCluster.NodeAPIs()[0].URL()).Msg("Creating VRF Key on the Node") vrfKey, err := env.ClCluster.NodeAPIs()[0].MustCreateVRFKey() if err != nil { - return nil, nil, nil, errors.Wrap(err, ErrCreatingVRFv2PlusKey) + return nil, nil, nil, fmt.Errorf("%s, err %w", ErrCreatingVRFv2PlusKey, err) } pubKeyCompressed := vrfKey.Data.ID l.Info().Str("Coordinator", vrfv2_5Contracts.Coordinator.Address()).Msg("Registering Proving Key") provingKey, err := VRFV2_5RegisterProvingKey(vrfKey, registerProvingKeyAgainstAddress, vrfv2_5Contracts.Coordinator) if err != nil { - return nil, nil, nil, errors.Wrap(err, ErrRegisteringProvingKey) + return nil, nil, nil, fmt.Errorf("%s, err %w", ErrRegisteringProvingKey, err) } keyHash, err := vrfv2_5Contracts.Coordinator.HashOfKey(context.Background(), provingKey) if err != nil { - return nil, nil, nil, errors.Wrap(err, ErrCreatingProvingKeyHash) + return nil, nil, nil, fmt.Errorf("%s, err %w", ErrCreatingProvingKeyHash, err) } chainID := env.EVMClient.GetChainID() nativeTokenPrimaryKeyAddress, err := env.ClCluster.NodeAPIs()[0].PrimaryEthAddress() if err != nil { - return nil, nil, nil, errors.Wrap(err, ErrNodePrimaryKey) + return nil, nil, nil, fmt.Errorf("%s, err %w", ErrNodePrimaryKey, err) } l.Info().Msg("Creating VRFV2 Plus Job") @@ -326,7 +326,7 @@ func SetupVRFV2_5Environment( vrfv2PlusConfig.MinimumConfirmations, ) if err != nil { - return nil, nil, nil, errors.Wrap(err, ErrCreateVRFV2PlusJobs) + return nil, nil, nil, fmt.Errorf("%s, err %w", ErrCreateVRFV2PlusJobs, err) } // this part is here because VRFv2 can work with only a specific key @@ -334,7 +334,7 @@ func SetupVRFV2_5Environment( // Key = '...' addr, err := env.ClCluster.Nodes[0].API.PrimaryEthAddress() if err != nil { - return nil, nil, nil, errors.Wrap(err, ErrGetPrimaryKey) + return nil, nil, nil, fmt.Errorf("%s, err %w", ErrGetPrimaryKey, err) } nodeConfig := node.NewConfig(env.ClCluster.Nodes[0].NodeConfig, node.WithVRFv2EVMEstimator(addr), @@ -342,7 +342,7 @@ func SetupVRFV2_5Environment( l.Info().Msg("Restarting Node with new sending key PriceMax configuration") err = env.ClCluster.Nodes[0].Restart(nodeConfig) if err != nil { - return nil, nil, nil, errors.Wrap(err, ErrRestartCLNode) + return nil, nil, nil, fmt.Errorf("%s, err %w", ErrRestartCLNode, err) } vrfv2PlusKeyData := VRFV2PlusKeyData{ @@ -391,7 +391,7 @@ func CreateFundSubsAndAddConsumers( err = env.EVMClient.WaitForEvents() if err != nil { - return nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } return subIDs, nil } @@ -409,7 +409,7 @@ func CreateSubsAndFund( } err = env.EVMClient.WaitForEvents() if err != nil { - return nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } err = FundSubscriptions(env, vrfv2PlusConfig, linkToken, coordinator, subs) if err != nil { @@ -443,7 +443,7 @@ func AddConsumersToSubs( for _, consumer := range consumers { err := coordinator.AddConsumer(subID, consumer.Address()) if err != nil { - return errors.Wrap(err, ErrAddConsumerToSub) + return fmt.Errorf("%s, err %w", ErrAddConsumerToSub, err) } } } @@ -475,7 +475,7 @@ func SetupVRFV2PlusWrapperEnvironment( err = env.EVMClient.WaitForEvents() if err != nil { - return nil, nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } err = wrapperContracts.VRFV2PlusWrapper.SetConfig( vrfv2PlusConfig.WrapperGasOverhead, @@ -494,7 +494,7 @@ func SetupVRFV2PlusWrapperEnvironment( err = env.EVMClient.WaitForEvents() if err != nil { - return nil, nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } //fund sub @@ -505,7 +505,7 @@ func SetupVRFV2PlusWrapperEnvironment( err = env.EVMClient.WaitForEvents() if err != nil { - return nil, nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } err = FundSubscriptions(env, vrfv2PlusConfig, linkToken, coordinator, []*big.Int{wrapperSubID}) @@ -523,7 +523,7 @@ func SetupVRFV2PlusWrapperEnvironment( } err = env.EVMClient.WaitForEvents() if err != nil { - return nil, nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } //fund consumer with Eth @@ -533,21 +533,24 @@ func SetupVRFV2PlusWrapperEnvironment( } err = env.EVMClient.WaitForEvents() if err != nil { - return nil, nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } return wrapperContracts, wrapperSubID, nil } func CreateSubAndFindSubID(env *test_env.CLClusterTestEnv, coordinator contracts.VRFCoordinatorV2_5) (*big.Int, error) { tx, err := coordinator.CreateSubscription() if err != nil { - return nil, errors.Wrap(err, ErrCreateVRFSubscription) + return nil, fmt.Errorf("%s, err %w", ErrCreateVRFSubscription, err) } err = env.EVMClient.WaitForEvents() if err != nil { - return nil, errors.Wrap(err, ErrWaitTXsComplete) + return nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } receipt, err := env.EVMClient.GetTxReceipt(tx.Hash()) + if err != nil { + return nil, fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) + } //SubscriptionsCreated Log should be emitted with the subscription ID subID := receipt.Logs[0].Topics[1].Big() @@ -555,7 +558,7 @@ func CreateSubAndFindSubID(env *test_env.CLClusterTestEnv, coordinator contracts //verify that the subscription was created _, err = coordinator.FindSubscriptionID(subID) if err != nil { - return nil, errors.Wrap(err, ErrFindSubID) + return nil, fmt.Errorf("%s, err %w", ErrFindSubID, err) } return subID, nil @@ -564,11 +567,11 @@ func CreateSubAndFindSubID(env *test_env.CLClusterTestEnv, coordinator contracts func GetUpgradedCoordinatorTotalBalance(coordinator contracts.VRFCoordinatorV2PlusUpgradedVersion) (linkTotalBalance *big.Int, nativeTokenTotalBalance *big.Int, err error) { linkTotalBalance, err = coordinator.GetLinkTotalBalance(context.Background()) if err != nil { - return nil, nil, errors.Wrap(err, ErrLinkTotalBalance) + return nil, nil, fmt.Errorf("%s, err %w", ErrLinkTotalBalance, err) } nativeTokenTotalBalance, err = coordinator.GetNativeTokenTotalBalance(context.Background()) if err != nil { - return nil, nil, errors.Wrap(err, ErrNativeTokenBalance) + return nil, nil, fmt.Errorf("%s, err %w", ErrNativeTokenBalance, err) } return } @@ -576,11 +579,11 @@ func GetUpgradedCoordinatorTotalBalance(coordinator contracts.VRFCoordinatorV2Pl func GetCoordinatorTotalBalance(coordinator contracts.VRFCoordinatorV2_5) (linkTotalBalance *big.Int, nativeTokenTotalBalance *big.Int, err error) { linkTotalBalance, err = coordinator.GetLinkTotalBalance(context.Background()) if err != nil { - return nil, nil, errors.Wrap(err, ErrLinkTotalBalance) + return nil, nil, fmt.Errorf("%s, err %w", ErrLinkTotalBalance, err) } nativeTokenTotalBalance, err = coordinator.GetNativeTokenTotalBalance(context.Background()) if err != nil { - return nil, nil, errors.Wrap(err, ErrNativeTokenBalance) + return nil, nil, fmt.Errorf("%s, err %w", ErrNativeTokenBalance, err) } return } @@ -600,18 +603,18 @@ func FundSubscriptions( amountWei, ) if err != nil { - return errors.Wrap(err, ErrFundSubWithNativeToken) + return fmt.Errorf("%s, err %w", ErrFundSubWithNativeToken, err) } //Link Billing amountJuels := utils.EtherToWei(big.NewFloat(vrfv2PlusConfig.SubscriptionFundingAmountLink)) err = FundVRFCoordinatorV2_5Subscription(linkAddress, coordinator, env.EVMClient, subID, amountJuels) if err != nil { - return errors.Wrap(err, ErrFundSubWithLinkToken) + return fmt.Errorf("%s, err %w", ErrFundSubWithLinkToken, err) } } err := env.EVMClient.WaitForEvents() if err != nil { - return errors.Wrap(err, ErrWaitTXsComplete) + return fmt.Errorf("%s, err %w", ErrWaitTXsComplete, err) } return nil } @@ -638,7 +641,7 @@ func RequestRandomnessAndWaitForFulfillment( randomnessRequestCountPerRequest, ) if err != nil { - return nil, errors.Wrap(err, ErrRequestRandomness) + return nil, fmt.Errorf("%s, err %w", ErrRequestRandomness, err) } return WaitForRequestAndFulfillmentEvents( @@ -672,7 +675,7 @@ func RequestRandomnessAndWaitForFulfillmentUpgraded( vrfv2PlusConfig.RandomnessRequestCountPerRequest, ) if err != nil { - return nil, errors.Wrap(err, ErrRequestRandomness) + return nil, fmt.Errorf("%s, err %w", ErrRequestRandomness, err) } randomWordsRequestedEvent, err := coordinator.WaitForRandomWordsRequestedEvent( @@ -682,7 +685,7 @@ func RequestRandomnessAndWaitForFulfillmentUpgraded( time.Minute*1, ) if err != nil { - return nil, errors.Wrap(err, ErrWaitRandomWordsRequestedEvent) + return nil, fmt.Errorf("%s, err %w", ErrWaitRandomWordsRequestedEvent, err) } LogRandomnessRequestedEventUpgraded(l, coordinator, randomWordsRequestedEvent) @@ -693,7 +696,7 @@ func RequestRandomnessAndWaitForFulfillmentUpgraded( time.Minute*2, ) if err != nil { - return nil, errors.Wrap(err, ErrWaitRandomWordsFulfilledEvent) + return nil, fmt.Errorf("%s, err %w", ErrWaitRandomWordsFulfilledEvent, err) } LogRandomWordsFulfilledEventUpgraded(l, coordinator, randomWordsFulfilledEvent) @@ -719,7 +722,7 @@ func DirectFundingRequestRandomnessAndWaitForFulfillment( vrfv2PlusConfig.RandomnessRequestCountPerRequest, ) if err != nil { - return nil, errors.Wrap(err, ErrRequestRandomnessDirectFundingNativePayment) + return nil, fmt.Errorf("%s, err %w", ErrRequestRandomnessDirectFundingNativePayment, err) } } else { _, err := consumer.RequestRandomness( @@ -729,12 +732,12 @@ func DirectFundingRequestRandomnessAndWaitForFulfillment( vrfv2PlusConfig.RandomnessRequestCountPerRequest, ) if err != nil { - return nil, errors.Wrap(err, ErrRequestRandomnessDirectFundingLinkPayment) + return nil, fmt.Errorf("%s, err %w", ErrRequestRandomnessDirectFundingLinkPayment, err) } } wrapperAddress, err := consumer.GetWrapper(context.Background()) if err != nil { - return nil, errors.Wrap(err, "error getting wrapper address") + return nil, fmt.Errorf("error getting wrapper address, err: %w", err) } return WaitForRequestAndFulfillmentEvents( wrapperAddress.String(), @@ -763,7 +766,7 @@ func WaitForRequestAndFulfillmentEvents( time.Minute*1, ) if err != nil { - return nil, errors.Wrap(err, ErrWaitRandomWordsRequestedEvent) + return nil, fmt.Errorf("%s, err %w", ErrWaitRandomWordsRequestedEvent, err) } LogRandomnessRequestedEvent(l, coordinator, randomWordsRequestedEvent, isNativeBilling) @@ -774,7 +777,7 @@ func WaitForRequestAndFulfillmentEvents( randomWordsFulfilledEventTimeout, ) if err != nil { - return nil, errors.Wrap(err, ErrWaitRandomWordsFulfilledEvent) + return nil, fmt.Errorf("%s, err %w", ErrWaitRandomWordsFulfilledEvent, err) } LogRandomWordsFulfilledEvent(l, coordinator, randomWordsFulfilledEvent, isNativeBilling) @@ -817,7 +820,7 @@ func WaitForRequestCountEqualToFulfilmentCount(consumer contracts.VRFv2PlusLoadT func ReturnFundsForFulfilledRequests(client blockchain.EVMClient, coordinator contracts.VRFCoordinatorV2_5, l zerolog.Logger) error { linkTotalBalance, err := coordinator.GetLinkTotalBalance(context.Background()) if err != nil { - return errors.Wrap(err, "Error getting LINK total balance") + return fmt.Errorf("Error getting LINK total balance, err: %w", err) } defaultWallet := client.GetDefaultWallet().Address() l.Info(). @@ -829,11 +832,11 @@ func ReturnFundsForFulfilledRequests(client blockchain.EVMClient, coordinator co linkTotalBalance, ) if err != nil { - return errors.Wrap(err, "Error withdrawing LINK from coordinator to default wallet") + return fmt.Errorf("Error withdrawing LINK from coordinator to default wallet, err: %w", err) } nativeTotalBalance, err := coordinator.GetNativeTokenTotalBalance(context.Background()) if err != nil { - return errors.Wrap(err, "Error getting NATIVE total balance") + return fmt.Errorf("Error getting NATIVE total balance, err: %w", err) } l.Info(). Str("Native Token amount", linkTotalBalance.String()). @@ -844,7 +847,7 @@ func ReturnFundsForFulfilledRequests(client blockchain.EVMClient, coordinator co nativeTotalBalance, ) if err != nil { - return errors.Wrap(err, "Error withdrawing NATIVE from coordinator to default wallet") + return fmt.Errorf("Error withdrawing NATIVE from coordinator to default wallet, err: %w", err) } return nil } diff --git a/integration-tests/contracts/ethereum_contracts.go b/integration-tests/contracts/ethereum_contracts.go index 5b3a93fe0c2..cde6e325f2a 100644 --- a/integration-tests/contracts/ethereum_contracts.go +++ b/integration-tests/contracts/ethereum_contracts.go @@ -13,7 +13,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/pkg/errors" "github.com/rs/zerolog" "github.com/rs/zerolog/log" @@ -2162,11 +2161,11 @@ func (e *EthereumFunctionsRouter) CreateSubscriptionWithConsumer(consumer string 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") + return 0, fmt.Errorf("failed to decode topic value, err: %w", err) } e.l.Info().Interface("NewTopicsDecoded", topicsMap).Send() if topicsMap["subscriptionId"] == 0 { - return 0, errors.New("failed to decode subscription ID after creation") + return 0, fmt.Errorf("failed to decode subscription ID after creation") } return topicsMap["subscriptionId"].(uint64), nil } diff --git a/integration-tests/contracts/ethereum_ocr2vrf_contracts.go b/integration-tests/contracts/ethereum_ocr2vrf_contracts.go index e8149b21251..cb52d1941a8 100644 --- a/integration-tests/contracts/ethereum_ocr2vrf_contracts.go +++ b/integration-tests/contracts/ethereum_ocr2vrf_contracts.go @@ -10,7 +10,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" @@ -230,7 +229,7 @@ func (dkgContract *EthereumDKG) WaitForTransmittedEvent(timeout time.Duration) ( case err = <-subscription.Err(): return nil, err case <-time.After(timeout): - return nil, errors.New("timeout waiting for DKGTransmitted event") + return nil, fmt.Errorf("timeout waiting for DKGTransmitted event") case transmittedEvent := <-transmittedEventsChannel: return transmittedEvent, nil } @@ -250,7 +249,7 @@ func (dkgContract *EthereumDKG) WaitForConfigSetEvent(timeout time.Duration) (*d case err = <-subscription.Err(): return nil, err case <-time.After(timeout): - return nil, errors.New("timeout waiting for DKGConfigSet event") + return nil, fmt.Errorf("timeout waiting for DKGConfigSet event") case configSetEvent := <-configSetEventsChannel: return configSetEvent, nil } @@ -451,7 +450,7 @@ func (consumer *EthereumVRFBeaconConsumer) RequestRandomness( ) (*types.Receipt, error) { opts, err := consumer.client.TransactionOpts(consumer.client.GetDefaultWallet()) if err != nil { - return nil, errors.Wrap(err, "TransactionOpts failed") + return nil, fmt.Errorf("TransactionOpts failed, err: %w", err) } tx, err := consumer.vrfBeaconConsumer.TestRequestRandomness( opts, @@ -460,20 +459,20 @@ func (consumer *EthereumVRFBeaconConsumer) RequestRandomness( confirmationDelayArg, ) if err != nil { - return nil, errors.Wrap(err, "TestRequestRandomness failed") + return nil, fmt.Errorf("TestRequestRandomness failed, err: %w", err) } err = consumer.client.ProcessTransaction(tx) if err != nil { - return nil, errors.Wrap(err, "ProcessTransaction failed") + return nil, fmt.Errorf("ProcessTransaction failed, err: %w", err) } err = consumer.client.WaitForEvents() if err != nil { - return nil, errors.Wrap(err, "WaitForEvents failed") + return nil, fmt.Errorf("WaitForEvents failed, err: %w", err) } receipt, err := consumer.client.GetTxReceipt(tx.Hash()) if err != nil { - return nil, errors.Wrap(err, "GetTxReceipt failed") + return nil, fmt.Errorf("GetTxReceipt failed, err: %w", err) } log.Info().Interface("Sub ID", subID). Interface("Number of Words", numWords). @@ -526,20 +525,20 @@ func (consumer *EthereumVRFBeaconConsumer) RequestRandomnessFulfillment( arguments, ) if err != nil { - return nil, errors.Wrap(err, "TestRequestRandomnessFulfillment failed") + return nil, fmt.Errorf("TestRequestRandomnessFulfillment failed, err: %w", err) } err = consumer.client.ProcessTransaction(tx) if err != nil { - return nil, errors.Wrap(err, "ProcessTransaction failed") + return nil, fmt.Errorf("ProcessTransaction failed, err: %w", err) } err = consumer.client.WaitForEvents() if err != nil { - return nil, errors.Wrap(err, "WaitForEvents failed") + return nil, fmt.Errorf("WaitForEvents failed, err: %w", err) } receipt, err := consumer.client.GetTxReceipt(tx.Hash()) if err != nil { - return nil, errors.Wrap(err, "GetTxReceipt failed") + return nil, fmt.Errorf("GetTxReceipt failed, err: %w", err) } log.Info().Interface("Sub ID", subID). Interface("Number of Words", numWords). diff --git a/integration-tests/docker/test_env/cl_node.go b/integration-tests/docker/test_env/cl_node.go index 4c40e641210..4de3d27d754 100644 --- a/integration-tests/docker/test_env/cl_node.go +++ b/integration-tests/docker/test_env/cl_node.go @@ -17,7 +17,6 @@ import ( "github.com/ethereum/go-ethereum/common" "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" @@ -282,7 +281,7 @@ func (n *ClNode) StartContainer() error { Logger: l, }) if err != nil { - return errors.Wrap(err, ErrStartCLNodeContainer) + return fmt.Errorf("%s err: %w", ErrStartCLNodeContainer, err) } if n.lw != nil { if err := n.lw.ConnectContainer(context.Background(), container, "cl-node", true); err != nil { @@ -314,7 +313,7 @@ func (n *ClNode) StartContainer() error { }, n.l) if err != nil { - return errors.Wrap(err, ErrConnectNodeClient) + return fmt.Errorf("%s err: %w", ErrConnectNodeClient, err) } clClient.Config.InternalIP = n.ContainerName n.Container = container diff --git a/integration-tests/docker/test_env/cl_node_cluster.go b/integration-tests/docker/test_env/cl_node_cluster.go index 5ae90bb982b..08122b5744d 100644 --- a/integration-tests/docker/test_env/cl_node_cluster.go +++ b/integration-tests/docker/test_env/cl_node_cluster.go @@ -1,8 +1,9 @@ package test_env import ( + "fmt" + "github.com/ethereum/go-ethereum/common" - "github.com/pkg/errors" "golang.org/x/sync/errgroup" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -61,7 +62,7 @@ func (c *ClCluster) NodeCSAKeys() ([]string, error) { for _, n := range c.Nodes { csaKeys, err := n.GetNodeCSAKeys() if err != nil { - return nil, errors.Wrap(err, ErrGetNodeCSAKeys) + return nil, fmt.Errorf("%s, err: %w", ErrGetNodeCSAKeys, err) } keys = append(keys, csaKeys.Data[0].ID) } diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index e067e46090d..a6495bed540 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -8,11 +8,11 @@ import ( "math/big" "os" "path/filepath" + "runtime/debug" "testing" "time" "github.com/ethereum/go-ethereum/accounts/keystore" - "github.com/pkg/errors" "github.com/rs/zerolog" "github.com/rs/zerolog/log" tc "github.com/testcontainers/testcontainers-go" @@ -114,7 +114,7 @@ func (te *CLClusterTestEnv) StartPrivateChain() error { for _, chain := range te.PrivateChain { primaryNode := chain.GetPrimaryNode() if primaryNode == nil { - return errors.WithStack(fmt.Errorf("primary node is nil in PrivateChain interface")) + return fmt.Errorf("primary node is nil in PrivateChain interface, stack: %s", string(debug.Stack())) } err := primaryNode.Start() if err != nil { @@ -164,7 +164,7 @@ func (te *CLClusterTestEnv) StartClCluster(nodeConfig *chainlink.Config, count i func (te *CLClusterTestEnv) FundChainlinkNodes(amount *big.Float) error { for _, cl := range te.ClCluster.Nodes { if err := cl.Fund(te.EVMClient, amount); err != nil { - return errors.Wrap(err, ErrFundCLNode) + return fmt.Errorf("%s, err: %w", ErrFundCLNode, err) } time.Sleep(5 * time.Second) } @@ -181,10 +181,10 @@ func (te *CLClusterTestEnv) Terminate() error { func (te *CLClusterTestEnv) Cleanup() error { te.l.Info().Msg("Cleaning up test environment") if te.t == nil { - return errors.New("cannot cleanup test environment without a testing.T") + return fmt.Errorf("cannot cleanup test environment without a testing.T") } if te.ClCluster == nil || len(te.ClCluster.Nodes) == 0 { - return errors.New("chainlink nodes are nil, unable cleanup chainlink nodes") + return fmt.Errorf("chainlink nodes are nil, unable cleanup chainlink nodes") } // TODO: This is an imperfect and temporary solution, see TT-590 for a more sustainable solution @@ -196,7 +196,7 @@ func (te *CLClusterTestEnv) Cleanup() error { } if te.EVMClient == nil { - return errors.New("evm client is nil, unable to return funds from chainlink nodes during cleanup") + return fmt.Errorf("evm client is nil, unable to return funds from chainlink nodes during cleanup") } else if te.EVMClient.NetworkSimulated() { te.l.Info(). Str("Network Name", te.EVMClient.GetNetworkName()). diff --git a/integration-tests/docker/test_env/test_env_builder.go b/integration-tests/docker/test_env/test_env_builder.go index c07ea762623..9f64ab64c98 100644 --- a/integration-tests/docker/test_env/test_env_builder.go +++ b/integration-tests/docker/test_env/test_env_builder.go @@ -4,9 +4,9 @@ import ( "fmt" "math/big" "os" + "runtime/debug" "testing" - "github.com/pkg/errors" "github.com/rs/zerolog" "github.com/rs/zerolog/log" @@ -230,7 +230,7 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { case CleanUpTypeNone: b.l.Warn().Msg("test environment won't be cleaned up") case "": - return b.te, errors.WithMessage(errors.New("explicit cleanup type must be set when building test environment"), "test environment builder failed") + return b.te, fmt.Errorf("test environment builder failed: %w", fmt.Errorf("explicit cleanup type must be set when building test environment")) } if b.nonDevGethNetworks != nil { @@ -243,14 +243,14 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { for i, n := range b.te.PrivateChain { primaryNode := n.GetPrimaryNode() if primaryNode == nil { - return b.te, errors.WithStack(fmt.Errorf("primary node is nil in PrivateChain interface")) + return b.te, fmt.Errorf("primary node is nil in PrivateChain interface, stack: %s", string(debug.Stack())) } nonDevNetworks = append(nonDevNetworks, *n.GetNetworkConfig()) nonDevNetworks[i].URLs = []string{primaryNode.GetInternalWsUrl()} nonDevNetworks[i].HTTPURLs = []string{primaryNode.GetInternalHttpUrl()} } if nonDevNetworks == nil { - return nil, errors.New("cannot create nodes with custom config without nonDevNetworks") + return nil, fmt.Errorf("cannot create nodes with custom config without nonDevNetworks") } err = b.te.StartClCluster(b.clNodeConfig, b.clNodesCount, b.secretsConfig) diff --git a/integration-tests/go.mod b/integration-tests/go.mod index eb542651b56..2ac3c38a719 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -17,12 +17,11 @@ require ( github.com/manifoldco/promptui v0.9.0 github.com/onsi/gomega v1.27.8 github.com/pelletier/go-toml/v2 v2.1.0 - github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.30.0 github.com/scylladb/go-reflectx v1.0.1 github.com/segmentio/ksuid v1.0.4 github.com/slack-go/slack v0.12.2 - github.com/smartcontractkit/chainlink-testing-framework v1.18.5-0.20231107092923-3aa655167f65 + github.com/smartcontractkit/chainlink-testing-framework v1.18.5 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20231107151413-13e0202ae8d7 github.com/smartcontractkit/ocr2keepers v0.7.28 @@ -364,6 +363,7 @@ require ( github.com/pelletier/go-toml v1.9.5 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/prometheus/alertmanager v0.25.1 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index ecafa2706e2..ce5e51a5681 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -2376,8 +2376,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231023133638-72f4e799ab0 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231023133638-72f4e799ab05/go.mod h1:o0Pn1pbaUluboaK6/yhf8xf7TiFCkyFl6WUOdwqamuU= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231024133459-1ef3a11319eb h1:HiluOfEVGOQTM6BTDImOqYdMZZ7qq7fkZ3TJdmItNr8= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231024133459-1ef3a11319eb/go.mod h1:/30flFG4L/iCYAFeA3DUzR0xuHSxAMONiWTzyzvsNwo= -github.com/smartcontractkit/chainlink-testing-framework v1.18.5-0.20231107092923-3aa655167f65 h1:/iRhwYy5KFsaS9Zo1T64QxAd11HGZB5p/LHI5oVc4BU= -github.com/smartcontractkit/chainlink-testing-framework v1.18.5-0.20231107092923-3aa655167f65/go.mod h1:zScXRqmvbyTFUooyLYrOp4+V/sFPUbFJNRc72YmnuIk= +github.com/smartcontractkit/chainlink-testing-framework v1.18.5 h1:R0f13AUbon1ltHE/vudkyUnLRGaoeocIDVv+FsHZjno= +github.com/smartcontractkit/chainlink-testing-framework v1.18.5/go.mod h1:zScXRqmvbyTFUooyLYrOp4+V/sFPUbFJNRc72YmnuIk= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= diff --git a/integration-tests/load/functions/config.go b/integration-tests/load/functions/config.go index 5c622401aba..451d01a6c89 100644 --- a/integration-tests/load/functions/config.go +++ b/integration-tests/load/functions/config.go @@ -1,12 +1,13 @@ package loadfunctions import ( + "fmt" + "math/big" + "os" + "github.com/pelletier/go-toml/v2" - "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink/v2/core/store/models" - "math/big" - "os" ) const ( @@ -103,18 +104,18 @@ func ReadConfig() (*PerformanceConfig, error) { var cfg *PerformanceConfig d, err := os.ReadFile(DefaultConfigFilename) if err != nil { - return nil, errors.Wrap(err, ErrReadPerfConfig) + return nil, fmt.Errorf("%s, err: %w", ErrReadPerfConfig, err) } err = toml.Unmarshal(d, &cfg) if err != nil { - return nil, errors.Wrap(err, ErrUnmarshalPerfConfig) + return nil, fmt.Errorf("%s, err: %w", ErrUnmarshalPerfConfig, err) } log.Debug().Interface("PerformanceConfig", cfg).Msg("Parsed performance config") mpk := os.Getenv("MUMBAI_KEYS") murls := os.Getenv("MUMBAI_URLS") snet := os.Getenv("SELECTED_NETWORKS") if mpk == "" || murls == "" || snet == "" { - return nil, errors.New( + return nil, fmt.Errorf( "ensure variables are set:\nMUMBAI_KEYS variable, private keys, comma separated\nSELECTED_NETWORKS=MUMBAI\nMUMBAI_URLS variable, websocket urls, comma separated", ) } else { diff --git a/integration-tests/load/functions/gateway.go b/integration-tests/load/functions/gateway.go index aefe4fbedc2..78b0f14cf18 100644 --- a/integration-tests/load/functions/gateway.go +++ b/integration-tests/load/functions/gateway.go @@ -8,16 +8,16 @@ import ( "encoding/hex" "encoding/json" "fmt" + "time" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/ecies" "github.com/go-resty/resty/v2" - "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink/v2/core/services/gateway/api" "github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers/functions" "github.com/smartcontractkit/chainlink/v2/core/services/s4" "github.com/smartcontractkit/tdh2/go/tdh2/tdh2easy" - "time" ) type RPCResponse struct { @@ -182,12 +182,12 @@ func EncryptS4Secrets(deployerPk *ecdsa.PrivateKey, tdh2Pk *tdh2easy.PublicKey, donKey = bytes.Join([][]byte{b, donKey}, nil) donPubKey, err := crypto.UnmarshalPubkey(donKey) if err != nil { - return "", errors.Wrap(err, "failed to unmarshal DON key") + return "", fmt.Errorf("failed to unmarshal DON key: %w", err) } eciesDONPubKey := ecies.ImportECDSAPublic(donPubKey) signature, err := deployerPk.Sign(rand.Reader, []byte(msgJSON), nil) if err != nil { - return "", errors.Wrap(err, "failed to sign the msg with Ethereum key") + return "", fmt.Errorf("failed to sign the msg with Ethereum key: %w", err) } signedSecrets, err := json.Marshal(struct { Signature []byte `json:"signature"` @@ -197,29 +197,29 @@ func EncryptS4Secrets(deployerPk *ecdsa.PrivateKey, tdh2Pk *tdh2easy.PublicKey, Message: msgJSON, }) if err != nil { - return "", errors.Wrap(err, "failed to marshal signed secrets") + return "", fmt.Errorf("failed to marshal signed secrets: %w", err) } ct, err := ecies.Encrypt(rand.Reader, eciesDONPubKey, signedSecrets, nil, nil) if err != nil { - return "", errors.Wrap(err, "failed to encrypt with DON key") + return "", fmt.Errorf("failed to encrypt with DON key: %w", err) } ct0xFormat, err := json.Marshal(map[string]interface{}{"0x0": base64.StdEncoding.EncodeToString(ct)}) if err != nil { - return "", errors.Wrap(err, "failed to marshal DON key encrypted format") + return "", fmt.Errorf("failed to marshal DON key encrypted format: %w", err) } ctTDH2Format, err := tdh2easy.Encrypt(tdh2Pk, ct0xFormat) if err != nil { - return "", errors.Wrap(err, "failed to encrypt with TDH2 public key") + return "", fmt.Errorf("failed to encrypt with TDH2 public key: %w", err) } tdh2Message, err := ctTDH2Format.Marshal() if err != nil { - return "", errors.Wrap(err, "failed to marshal TDH2 encrypted msg") + return "", fmt.Errorf("failed to marshal TDH2 encrypted msg: %w", err) } finalMsg, err := json.Marshal(map[string]interface{}{ "encryptedSecrets": "0x" + hex.EncodeToString(tdh2Message), }) if err != nil { - return "", errors.Wrap(err, "failed to marshal secrets msg") + return "", fmt.Errorf("failed to marshal secrets msg: %w", err) } return string(finalMsg), nil } diff --git a/integration-tests/load/functions/setup.go b/integration-tests/load/functions/setup.go index 5253c531eee..81bc660b35e 100644 --- a/integration-tests/load/functions/setup.go +++ b/integration-tests/load/functions/setup.go @@ -2,6 +2,7 @@ package loadfunctions import ( "crypto/ecdsa" + "fmt" "math/big" mrand "math/rand" "os" @@ -10,7 +11,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/go-resty/resty/v2" - "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/networks" @@ -91,41 +91,41 @@ func SetupLocalLoadTestEnv(cfg *PerformanceConfig) (*FunctionsTest, error) { log.Info().Msg("Creating new subscription") subID, err := router.CreateSubscriptionWithConsumer(loadTestClient.Address()) if err != nil { - return nil, errors.Wrap(err, "failed to create a new subscription") + return nil, fmt.Errorf("failed to create a new subscription: %w", err) } encodedSubId, err := chainlinkutils.ABIEncode(`[{"type":"uint64"}]`, subID) if err != nil { - return nil, errors.Wrap(err, "failed to encode subscription ID for funding") + return nil, fmt.Errorf("failed to encode subscription ID for funding: %w", err) } _, err = lt.TransferAndCall(router.Address(), big.NewInt(0).Mul(cfg.Common.Funding.SubFunds, big.NewInt(1e18)), encodedSubId) if err != nil { - return nil, errors.Wrap(err, "failed to transferAndCall router, LINK funding") + return nil, fmt.Errorf("failed to transferAndCall router, LINK funding: %w", err) } cfg.Common.SubscriptionID = subID } pKey, pubKey, err := parseEthereumPrivateKey(os.Getenv("MUMBAI_KEYS")) if err != nil { - return nil, errors.Wrap(err, "failed to load Ethereum private key") + return nil, fmt.Errorf("failed to load Ethereum private key: %w", err) } tpk, err := coord.GetThresholdPublicKey() if err != nil { - return nil, errors.Wrap(err, "failed to get Threshold public key") + return nil, fmt.Errorf("failed to get Threshold public key: %w", err) } log.Info().Hex("ThresholdPublicKeyBytesHex", tpk).Msg("Loaded coordinator keys") donPubKey, err := coord.GetDONPublicKey() if err != nil { - return nil, errors.Wrap(err, "failed to get DON public key") + return nil, fmt.Errorf("failed to get DON public key: %w", err) } log.Info().Hex("DONPublicKeyHex", donPubKey).Msg("Loaded DON key") tdh2pk, err := ParseTDH2Key(tpk) if err != nil { - return nil, errors.Wrap(err, "failed to unmarshal tdh2 public key") + return nil, fmt.Errorf("failed to unmarshal tdh2 public key: %w", err) } var encryptedSecrets string if cfg.Common.Secrets != "" { encryptedSecrets, err = EncryptS4Secrets(pKey, tdh2pk, donPubKey, cfg.Common.Secrets) if err != nil { - return nil, errors.Wrap(err, "failed to generate tdh2 secrets") + return nil, fmt.Errorf("failed to generate tdh2 secrets: %w", err) } slotID, slotVersion, err := UploadS4Secrets(resty.New(), &S4SecretsCfg{ GatewayURL: cfg.Common.GatewayURL, @@ -139,7 +139,7 @@ func SetupLocalLoadTestEnv(cfg *PerformanceConfig) (*FunctionsTest, error) { S4SetPayload: encryptedSecrets, }) if err != nil { - return nil, errors.Wrap(err, "failed to upload secrets to S4") + return nil, fmt.Errorf("failed to upload secrets to S4: %w", err) } cfg.Common.SecretsSlotID = slotID cfg.Common.SecretsVersionID = slotVersion @@ -168,13 +168,13 @@ func SetupLocalLoadTestEnv(cfg *PerformanceConfig) (*FunctionsTest, error) { func parseEthereumPrivateKey(pk string) (*ecdsa.PrivateKey, *ecdsa.PublicKey, error) { pKey, err := crypto.HexToECDSA(pk) if err != nil { - return nil, nil, errors.Wrap(err, "failed to convert Ethereum key from hex") + return nil, nil, fmt.Errorf("failed to convert Ethereum key from hex: %w", err) } publicKey := pKey.Public() pubKey, ok := publicKey.(*ecdsa.PublicKey) if !ok { - return nil, nil, errors.Wrap(err, "failed to get public key from Ethereum private key") + return nil, nil, fmt.Errorf("failed to get public key from Ethereum private key: %w", err) } log.Info().Str("Address", crypto.PubkeyToAddress(*pubKey).Hex()).Msg("Parsed private key for address") return pKey, pubKey, nil diff --git a/integration-tests/load/vrfv2/config.go b/integration-tests/load/vrfv2/config.go index ee5f3ff80dd..0c62cc351b4 100644 --- a/integration-tests/load/vrfv2/config.go +++ b/integration-tests/load/vrfv2/config.go @@ -1,12 +1,13 @@ package loadvrfv2 import ( + "fmt" + "math/big" + "os" + "github.com/pelletier/go-toml/v2" - "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink/v2/core/store/models" - "math/big" - "os" ) const ( @@ -63,11 +64,11 @@ func ReadConfig() (*PerformanceConfig, error) { var cfg *PerformanceConfig d, err := os.ReadFile(DefaultConfigFilename) if err != nil { - return nil, errors.Wrap(err, ErrReadPerfConfig) + return nil, fmt.Errorf("%s, err: %w", ErrReadPerfConfig, err) } err = toml.Unmarshal(d, &cfg) if err != nil { - return nil, errors.Wrap(err, ErrUnmarshalPerfConfig) + return nil, fmt.Errorf("%s, err: %w", ErrUnmarshalPerfConfig, err) } log.Debug().Interface("PerformanceConfig", cfg).Msg("Parsed performance config") return cfg, nil diff --git a/integration-tests/load/vrfv2/vu.go b/integration-tests/load/vrfv2/vu.go index df05a9168e2..4658388d400 100644 --- a/integration-tests/load/vrfv2/vu.go +++ b/integration-tests/load/vrfv2/vu.go @@ -1,13 +1,14 @@ package loadvrfv2 import ( - "github.com/pkg/errors" + "fmt" + "time" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions" vrfConst "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions/vrfv2_constants" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/wasp" - "time" ) /* JobVolumeVU is a "virtual user" that creates a VRFv2 job and constantly requesting new randomness only for this job instance */ @@ -54,7 +55,7 @@ func (m *JobVolumeVU) Clone(_ *wasp.Generator) wasp.VirtualUser { func (m *JobVolumeVU) Setup(_ *wasp.Generator) error { jobs, err := vrfv2_actions.CreateVRFV2Jobs(m.nodes, m.contracts.Coordinator, m.bc, m.minIncomingConfirmations) if err != nil { - return errors.Wrap(err, "failed to create VRFv2 jobs in setup") + return fmt.Errorf("failed to create VRFv2 jobs in setup: %w", err) } m.jobs = jobs m.keyHash = jobs[0].KeyHash diff --git a/integration-tests/load/vrfv2plus/config.go b/integration-tests/load/vrfv2plus/config.go index a5439210c2d..cba3fdcde59 100644 --- a/integration-tests/load/vrfv2plus/config.go +++ b/integration-tests/load/vrfv2plus/config.go @@ -2,12 +2,13 @@ package loadvrfv2plus import ( "encoding/base64" + "fmt" + "os" + "github.com/pelletier/go-toml/v2" - "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_config" "github.com/smartcontractkit/chainlink/v2/core/store/models" - "os" ) const ( @@ -95,18 +96,18 @@ func ReadConfig() (*PerformanceConfig, error) { if rawConfig == "" { d, err = os.ReadFile(DefaultConfigFilename) if err != nil { - return nil, errors.Wrap(err, ErrReadPerfConfig) + return nil, fmt.Errorf("%s, err: %w", ErrReadPerfConfig, err) } } else { d, err = base64.StdEncoding.DecodeString(rawConfig) } err = toml.Unmarshal(d, &cfg) if err != nil { - return nil, errors.Wrap(err, ErrUnmarshalPerfConfig) + return nil, fmt.Errorf("%s, err: %w", ErrUnmarshalPerfConfig, err) } if cfg.Soak.RandomnessRequestCountPerRequest <= cfg.Soak.RandomnessRequestCountPerRequestDeviation { - return nil, errors.Wrap(err, ErrDeviationShouldBeLessThanOriginal) + return nil, fmt.Errorf("%s, err: %w", ErrDeviationShouldBeLessThanOriginal, err) } log.Debug().Interface("Config", cfg).Msg("Parsed config") diff --git a/integration-tests/reorg/reorg_confirmer.go b/integration-tests/reorg/reorg_confirmer.go index 885bed2ad45..2193131680a 100644 --- a/integration-tests/reorg/reorg_confirmer.go +++ b/integration-tests/reorg/reorg_confirmer.go @@ -2,13 +2,13 @@ package reorg import ( "context" + "fmt" "math/big" "sync" "sync/atomic" "time" "github.com/ethereum/go-ethereum/common" - "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" @@ -70,7 +70,7 @@ type ReorgController struct { // NewReorgController creates a type that can create reorg chaos and confirm reorg has happened func NewReorgController(cfg *ReorgConfig) (*ReorgController, error) { if len(cfg.Network.GetClients()) == 1 { - return nil, errors.New("need at least 3 nodes to re-org") + return nil, fmt.Errorf("need at least 3 nodes to re-org") } ctx, ctxCancel := context.WithTimeout(context.Background(), cfg.Timeout) rc := &ReorgController{ @@ -165,7 +165,7 @@ func (rc *ReorgController) VerifyReorgComplete() error { } } if rc.currentVerifiedBlocks+1 < rc.ReorgDepth { - return errors.New("Reorg depth has not met") + return fmt.Errorf("Reorg depth has not met") } return nil } @@ -217,7 +217,7 @@ func (rc *ReorgController) Wait() error { if rc.complete { return nil } - return errors.New("timeout waiting for reorg to complete") + return fmt.Errorf("timeout waiting for reorg to complete") } // forkNetwork stomp the network between target reorged node and the rest diff --git a/integration-tests/smoke/ocr2_test.go b/integration-tests/smoke/ocr2_test.go index 1b33cdce769..a6dcdcd139d 100644 --- a/integration-tests/smoke/ocr2_test.go +++ b/integration-tests/smoke/ocr2_test.go @@ -5,24 +5,14 @@ import ( "fmt" "math/big" "net/http" - "strings" "testing" "time" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/chainlink" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/ethereum" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver" - mockservercfg "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/logging" - "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink/integration-tests/actions" - "github.com/smartcontractkit/chainlink/integration-tests/client" - "github.com/smartcontractkit/chainlink/integration-tests/config" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" @@ -102,42 +92,3 @@ func TestOCRv2Basic(t *testing.T) { roundData.Answer.Int64(), ) } - -func setupOCR2Test(t *testing.T, forwardersEnabled bool) ( - testEnvironment *environment.Environment, - testNetwork blockchain.EVMNetwork, -) { - testNetwork = networks.MustGetSelectedNetworksFromEnv()[0] - evmConfig := ethereum.New(nil) - if !testNetwork.Simulated { - evmConfig = ethereum.New(ðereum.Props{ - NetworkName: testNetwork.Name, - Simulated: testNetwork.Simulated, - WsURLs: testNetwork.URLs, - }) - } - - var toml string - if forwardersEnabled { - toml = client.AddNetworkDetailedConfig(config.BaseOCR2Config, config.ForwarderNetworkDetailConfig, testNetwork) - } else { - toml = client.AddNetworksConfig(config.BaseOCR2Config, testNetwork) - } - - chainlinkChart := chainlink.New(0, map[string]interface{}{ - "replicas": 6, - "toml": toml, - }) - - testEnvironment = environment.New(&environment.Config{ - NamespacePrefix: fmt.Sprintf("smoke-ocr2-%s", strings.ReplaceAll(strings.ToLower(testNetwork.Name), " ", "-")), - Test: t, - }). - AddHelm(mockservercfg.New(nil)). - AddHelm(mockserver.New(nil)). - AddHelm(evmConfig). - AddHelm(chainlinkChart) - err := testEnvironment.Run() - require.NoError(t, err, "Error running test environment") - return testEnvironment, testNetwork -} diff --git a/integration-tests/smoke/ocr2vrf_test.go b/integration-tests/smoke/ocr2vrf_test.go index 0d6a77a1157..912c121d075 100644 --- a/integration-tests/smoke/ocr2vrf_test.go +++ b/integration-tests/smoke/ocr2vrf_test.go @@ -1,6 +1,7 @@ package smoke import ( + "context" "fmt" "math/big" "strings" @@ -80,7 +81,7 @@ func TestOCR2VRFRedeemModel(t *testing.T) { ) for i := uint16(0); i < ocr2vrf_constants.NumberOfRandomWordsToRequest; i++ { - randomness, err := consumerContract.GetRandomnessByRequestId(nil, requestID, big.NewInt(int64(i))) + randomness, err := consumerContract.GetRandomnessByRequestId(context.Background(), requestID, big.NewInt(int64(i))) require.NoError(t, err) l.Info().Interface("Random Number", randomness).Interface("Randomness Number Index", i).Msg("Randomness retrieved from Consumer contract") require.NotEqual(t, 0, randomness.Uint64(), "Randomness retrieved from Consumer contract give an answer other than 0") @@ -141,7 +142,7 @@ func TestOCR2VRFFulfillmentModel(t *testing.T) { ) for i := uint16(0); i < ocr2vrf_constants.NumberOfRandomWordsToRequest; i++ { - randomness, err := consumerContract.GetRandomnessByRequestId(nil, requestID, big.NewInt(int64(i))) + randomness, err := consumerContract.GetRandomnessByRequestId(context.Background(), requestID, big.NewInt(int64(i))) require.NoError(t, err, "Error getting Randomness result from Consumer Contract") l.Info().Interface("Random Number", randomness).Interface("Randomness Number Index", i).Msg("Randomness Fulfillment retrieved from Consumer contract") require.NotEqual(t, 0, randomness.Uint64(), "Randomness Fulfillment retrieved from Consumer contract give an answer other than 0") diff --git a/integration-tests/smoke/vrfv2plus_test.go b/integration-tests/smoke/vrfv2plus_test.go index acd548c88e2..3510a1505a7 100644 --- a/integration-tests/smoke/vrfv2plus_test.go +++ b/integration-tests/smoke/vrfv2plus_test.go @@ -3,14 +3,14 @@ package smoke import ( "context" "fmt" - "github.com/smartcontractkit/chainlink/integration-tests/utils" "math/big" "testing" "time" + "github.com/smartcontractkit/chainlink/integration-tests/utils" + "github.com/ethereum/go-ethereum/common" "github.com/kelseyhightower/envconfig" - "github.com/pkg/errors" "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-testing-framework/logging" @@ -271,6 +271,7 @@ func TestVRFv2Plus(t *testing.T) { subIDForCancelling := subIDsForCancelling[0] testWalletAddress, err := actions.GenerateWallet() + require.NoError(t, err) testWalletBalanceNativeBeforeSubCancelling, err := env.EVMClient.BalanceAt(context.Background(), testWalletAddress) require.NoError(t, err) @@ -638,7 +639,7 @@ func TestVRFv2PlusMigration(t *testing.T) { require.NoError(t, err, vrfv2plus.ErrWaitTXsComplete) _, err = vrfv2plus.VRFV2PlusUpgradedVersionRegisterProvingKey(vrfv2PlusData.VRFKey, vrfv2PlusData.PrimaryEthAddress, newCoordinator) - require.NoError(t, err, errors.Wrap(err, vrfv2plus.ErrRegisteringProvingKey)) + require.NoError(t, err, fmt.Errorf("%s, err: %w", vrfv2plus.ErrRegisteringProvingKey, err)) err = newCoordinator.SetConfig( vrfv2PlusConfig.MinimumConfirmations, @@ -651,6 +652,7 @@ func TestVRFv2PlusMigration(t *testing.T) { FulfillmentFlatFeeNativePPM: vrfv2PlusConfig.FulfillmentFlatFeeNativePPM, }, ) + require.NoError(t, err) err = newCoordinator.SetLINKAndLINKNativeFeed(linkAddress.Address(), mockETHLinkFeedAddress.Address()) require.NoError(t, err, vrfv2plus.ErrSetLinkNativeLinkFeed)