Skip to content

Commit

Permalink
[TT-695] Deprecate P2Pv1 in Tests (#11305)
Browse files Browse the repository at this point in the history
* Deprecating P2Pv1 in Tests

* P2Pv2 Swap

* Lint

* Stupid typose
  • Loading branch information
kalverra authored Nov 16, 2023
1 parent e030073 commit 96498b6
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions integration-tests/actions/ocr_helpers_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
}
Expand Down Expand Up @@ -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,
Expand All @@ -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)
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion integration-tests/client/chainlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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 {
Expand Down
14 changes: 5 additions & 9 deletions integration-tests/client/chainlink_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"`
Expand Down Expand Up @@ -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}}
"""`
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/docker/test_env/test_env_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -324,7 +325,7 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) {
} else {
cfg = node.NewConfig(node.NewBaseConfig(),
node.WithOCR1(),
node.WithP2Pv1(),
node.WithP2Pv2(),
)
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/smoke/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/smoke/ocr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions integration-tests/types/config/node/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/universal/log_poller/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)

Expand Down

0 comments on commit 96498b6

Please sign in to comment.