From 96498b692963bbea6b9b1d1e7d5bcaf6f0786542 Mon Sep 17 00:00:00 2001 From: Adam Hamrick Date: Thu, 16 Nov 2023 15:10:14 -0500 Subject: [PATCH] [TT-695] Deprecate P2Pv1 in Tests (#11305) * Deprecating P2Pv1 in Tests * P2Pv2 Swap * Lint * Stupid typose --- integration-tests/actions/ocr_helpers_local.go | 8 ++++---- integration-tests/client/chainlink.go | 5 ++++- integration-tests/client/chainlink_models.go | 14 +++++--------- .../docker/test_env/test_env_builder.go | 5 +++-- integration-tests/smoke/keeper_test.go | 2 +- integration-tests/smoke/ocr_test.go | 7 ++++--- integration-tests/types/config/node/core.go | 2 ++ integration-tests/universal/log_poller/helpers.go | 3 --- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/integration-tests/actions/ocr_helpers_local.go b/integration-tests/actions/ocr_helpers_local.go index e6dd5ae77f6..fb0fd0bd47d 100644 --- a/integration-tests/actions/ocr_helpers_local.go +++ b/integration-tests/actions/ocr_helpers_local.go @@ -146,7 +146,7 @@ func CreateOCRJobsLocal( workerNodes []*client.ChainlinkClient, mockValue int, mockAdapter *test_env.Killgrave, - evmChainID string, + evmChainID *big.Int, ) error { for _, ocrInstance := range ocrInstances { bootstrapP2PIds, err := bootstrapNode.MustReadP2PKeys() @@ -157,7 +157,7 @@ func CreateOCRJobsLocal( bootstrapSpec := &client.OCRBootstrapJobSpec{ Name: fmt.Sprintf("bootstrap-%s", uuid.New().String()), ContractAddress: ocrInstance.Address(), - EVMChainID: evmChainID, + EVMChainID: evmChainID.String(), P2PPeerID: bootstrapP2PId, IsBootstrapPeer: true, } @@ -202,7 +202,7 @@ func CreateOCRJobsLocal( bootstrapPeers := []*client.ChainlinkClient{bootstrapNode} ocrSpec := &client.OCRTaskJobSpec{ ContractAddress: ocrInstance.Address(), - EVMChainID: evmChainID, + EVMChainID: evmChainID.String(), P2PPeerID: nodeP2PId, P2PBootstrapPeers: bootstrapPeers, KeyBundleID: nodeOCRKeyId, @@ -211,7 +211,7 @@ func CreateOCRJobsLocal( } _, err = node.MustCreateJob(ocrSpec) if err != nil { - return fmt.Errorf("creating OCR task job on OCR node have failed: %w", err) + return fmt.Errorf("creating OCR job on OCR node failed: %w", err) } } } diff --git a/integration-tests/client/chainlink.go b/integration-tests/client/chainlink.go index 4603679ff85..16299a1ac8a 100644 --- a/integration-tests/client/chainlink.go +++ b/integration-tests/client/chainlink.go @@ -116,7 +116,7 @@ func (c *ChainlinkClient) MustCreateJob(spec JobSpec) (*Job, error) { if err != nil { return nil, err } - return job, VerifyStatusCode(resp.RawResponse.StatusCode, http.StatusOK) + return job, VerifyStatusCodeWithResponse(resp, http.StatusOK) } // CreateJob creates a Chainlink job based on the provided spec struct @@ -1114,6 +1114,7 @@ func (c *ChainlinkClient) SetPageSize(size int) { c.pageSize = size } +// VerifyStatusCode verifies the status code of the response. Favor VerifyStatusCodeWithResponse over this for better errors func VerifyStatusCode(actStatusCd, expStatusCd int) error { if actStatusCd != expStatusCd { return fmt.Errorf( @@ -1125,6 +1126,8 @@ func VerifyStatusCode(actStatusCd, expStatusCd int) error { return nil } +// VerifyStatusCodeWithResponse verifies the status code of the response and returns the response as part of the error. +// Favor this over VerifyStatusCode func VerifyStatusCodeWithResponse(res *resty.Response, expStatusCd int) error { actStatusCd := res.RawResponse.StatusCode if actStatusCd != expStatusCd { diff --git a/integration-tests/client/chainlink_models.go b/integration-tests/client/chainlink_models.go index 17a0a50845b..8ff8494155b 100644 --- a/integration-tests/client/chainlink_models.go +++ b/integration-tests/client/chainlink_models.go @@ -889,7 +889,7 @@ contractConfigConfirmations ={{if not .ContractConfirmations}} 3 {{el contractConfigTrackerPollInterval ={{if not .TrackerPollInterval}} "1m" {{else}} {{.TrackerPollInterval}} {{end}} contractConfigTrackerSubscribeInterval ={{if not .TrackerSubscribeInterval}} "2m" {{else}} {{.TrackerSubscribeInterval}} {{end}} contractAddress = "{{.ContractAddress}}" -evmChainID = "{{.EVMChainID}}" +evmChainID = "{{.EVMChainID}}" p2pBootstrapPeers = [] isBootstrapPeer = {{.IsBootstrapPeer}} p2pPeerID = "{{.P2PPeerID}}"` @@ -988,22 +988,18 @@ contractConfigConfirmations ={{if not .ContractConfirmations}} 3 {{el contractConfigTrackerPollInterval ={{if not .TrackerPollInterval}} "1m" {{else}} {{.TrackerPollInterval}} {{end}} contractConfigTrackerSubscribeInterval ={{if not .TrackerSubscribeInterval}} "2m" {{else}} {{.TrackerSubscribeInterval}} {{end}} contractAddress = "{{.ContractAddress}}" -evmChainID = "{{.EVMChainID}}" +evmChainID = "{{.EVMChainID}}" {{if .P2PBootstrapPeers}} -p2pBootstrapPeers = [ - {{range $peer := .P2PBootstrapPeers}} - "/dns4/{{$peer.InternalIP}}/tcp/6690/p2p/{{$peer.PeerID}}", - {{end}} -] +p2pv2Bootstrappers = [{{range $peer := .P2PBootstrapPeers}}"{{$peer.PeerID}}@{{$peer.InternalIP}}:6690",{{end}}] {{else}} -p2pBootstrapPeers = [] +p2pv2Bootstrappers = [] {{end}} isBootstrapPeer = {{.IsBootstrapPeer}} p2pPeerID = "{{.P2PPeerID}}" keyBundleID = "{{.KeyBundleID}}" monitoringEndpoint ={{if not .MonitoringEndpoint}} "chain.link:4321" {{else}} "{{.MonitoringEndpoint}}" {{end}} transmitterAddress = "{{.TransmitterAddress}}" -forwardingAllowed = {{.ForwardingAllowed}} +forwardingAllowed = {{.ForwardingAllowed}} observationSource = """ {{.ObservationSource}} """` diff --git a/integration-tests/docker/test_env/test_env_builder.go b/integration-tests/docker/test_env/test_env_builder.go index 77c56690155..32f84991eef 100644 --- a/integration-tests/docker/test_env/test_env_builder.go +++ b/integration-tests/docker/test_env/test_env_builder.go @@ -17,9 +17,10 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" + evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" + "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" - evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" ) type CleanUpType string @@ -324,7 +325,7 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { } else { cfg = node.NewConfig(node.NewBaseConfig(), node.WithOCR1(), - node.WithP2Pv1(), + node.WithP2Pv2(), ) } diff --git a/integration-tests/smoke/keeper_test.go b/integration-tests/smoke/keeper_test.go index 29a819af136..6f892e60aca 100644 --- a/integration-tests/smoke/keeper_test.go +++ b/integration-tests/smoke/keeper_test.go @@ -1098,7 +1098,7 @@ func setupKeeperTest(t *testing.T) ( contracts.LinkToken, *test_env.CLClusterTestEnv, ) { - clNodeConfig := node.NewConfig(node.NewBaseConfig(), node.WithP2Pv1()) + clNodeConfig := node.NewConfig(node.NewBaseConfig(), node.WithP2Pv2()) turnLookBack := int64(0) syncInterval := models.MustMakeDuration(5 * time.Second) performGasOverhead := uint32(150000) diff --git a/integration-tests/smoke/ocr_test.go b/integration-tests/smoke/ocr_test.go index 8fbc1109e2b..a078b8ca419 100644 --- a/integration-tests/smoke/ocr_test.go +++ b/integration-tests/smoke/ocr_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-testing-framework/logging" + "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/utils" @@ -39,7 +40,7 @@ func TestOCRBasic(t *testing.T) { err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") - err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID().String()) + err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID()) require.NoError(t, err) err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l) @@ -86,7 +87,7 @@ func TestOCRJobReplacement(t *testing.T) { err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") - err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID().String()) + err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID()) require.NoError(t, err) err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l) @@ -112,7 +113,7 @@ func TestOCRJobReplacement(t *testing.T) { require.NoError(t, err) //Recreate job - err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID().String()) + err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID()) require.NoError(t, err) err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l) diff --git a/integration-tests/types/config/node/core.go b/integration-tests/types/config/node/core.go index 7ddddafdd5f..e044d1ba32a 100644 --- a/integration-tests/types/config/node/core.go +++ b/integration-tests/types/config/node/core.go @@ -109,6 +109,8 @@ func WithOCR2() NodeConfigOpt { } } +// Deprecated: P2Pv1 is soon to be fully deprecated +// WithP2Pv1 enables P2Pv1 and disables P2Pv2 func WithP2Pv1() NodeConfigOpt { return func(c *chainlink.Config) { c.P2P.V1 = toml.P2PV1{ diff --git a/integration-tests/universal/log_poller/helpers.go b/integration-tests/universal/log_poller/helpers.go index 08ceb4a7be4..505337f0324 100644 --- a/integration-tests/universal/log_poller/helpers.go +++ b/integration-tests/universal/log_poller/helpers.go @@ -27,7 +27,6 @@ import ( ctf_test_env "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" - evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" cltypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -39,12 +38,10 @@ import ( "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" )