Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicated testing util for p2p_key only. #15330

Merged
merged 8 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilled-papayas-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#removed Remove duplicated testing util for p2p_key only.
6 changes: 3 additions & 3 deletions core/internal/features/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/keystest"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocrkey"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
"github.com/smartcontractkit/chainlink/v2/core/services/webhook"
Expand Down Expand Up @@ -693,7 +693,7 @@ func setupNode(t *testing.T, owner *bind.TransactOpts, portV2 int,
b evmtypes.Backend, overrides func(c *chainlink.Config, s *chainlink.Secrets),
) (*cltest.TestApplication, string, common.Address, ocrkey.KeyV2) {
ctx := testutils.Context(t)
p2pKey := keystest.NewP2PKeyV2(t)
p2pKey := p2pkey.MustNewV2XXXTestingOnly(big.NewInt(int64(portV2)))
config, _ := heavyweight.FullTestDBV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Insecure.OCRDevelopmentMode = ptr(true) // Disables ocr spec validation so we can have fast polling for the test.

Expand Down Expand Up @@ -738,7 +738,7 @@ func setupNode(t *testing.T, owner *bind.TransactOpts, portV2 int,

func setupForwarderEnabledNode(t *testing.T, owner *bind.TransactOpts, portV2 int, b evmtypes.Backend, overrides func(c *chainlink.Config, s *chainlink.Secrets)) (*cltest.TestApplication, string, common.Address, common.Address, ocrkey.KeyV2) {
ctx := testutils.Context(t)
p2pKey := keystest.NewP2PKeyV2(t)
p2pKey := p2pkey.MustNewV2XXXTestingOnly(big.NewInt(int64(portV2)))
config, _ := heavyweight.FullTestDBV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Insecure.OCRDevelopmentMode = ptr(true) // Disables ocr spec validation so we can have fast polling for the test.

Expand Down
4 changes: 2 additions & 2 deletions core/internal/features/ocr2/features_ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/keystest"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/testhelpers"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate"
"github.com/smartcontractkit/chainlink/v2/core/services/ocrbootstrap"
Expand Down Expand Up @@ -112,7 +112,7 @@ func setupNodeOCR2(
p2pV2Bootstrappers []commontypes.BootstrapperLocator,
) *ocr2Node {
ctx := testutils.Context(t)
p2pKey := keystest.NewP2PKeyV2(t)
p2pKey := p2pkey.MustNewV2XXXTestingOnly(big.NewInt(int64(port)))
config, _ := heavyweight.FullTestDBV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Insecure.OCRDevelopmentMode = ptr(true) // Disables ocr spec validation so we can have fast polling for the test.

Expand Down
9 changes: 5 additions & 4 deletions core/services/feeds/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"encoding/hex"
"fmt"
"math/big"
"testing"
"time"

Expand All @@ -22,7 +23,7 @@ import (
proto "github.com/smartcontractkit/chainlink-protos/orchestrator/feedsmanager"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big"
evmbig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big"
"github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm"
"github.com/smartcontractkit/chainlink/v2/core/internal/cltest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
Expand All @@ -36,8 +37,8 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/job"
jobmocks "github.com/smartcontractkit/chainlink/v2/core/services/job/mocks"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/csakey"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/keystest"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocrkey"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
ksmocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
"github.com/smartcontractkit/chainlink/v2/core/services/versioning"
Expand Down Expand Up @@ -1620,7 +1621,7 @@ func Test_Service_SyncNodeInfo(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p2pKey := keystest.NewP2PKeyV2(t)
p2pKey := p2pkey.MustNewV2XXXTestingOnly(big.NewInt(1))

ocrKey, err := ocrkey.NewV2()
require.NoError(t, err)
Expand Down Expand Up @@ -2046,7 +2047,7 @@ func Test_Service_ListSpecsByJobProposalIDs(t *testing.T) {
}

func Test_Service_ApproveSpec(t *testing.T) {
var evmChainID *big.Big
var evmChainID *evmbig.Big
address := types.EIP55AddressFromAddress(common.Address{})
externalJobID := uuid.New()

Expand Down
15 changes: 0 additions & 15 deletions core/services/keystore/keys/keystest/keystest.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
"github.com/smartcontractkit/chainlink/v2/core/services/functions"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/keystest"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
functionsConfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/functions/config"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate"
"github.com/smartcontractkit/chainlink/v2/core/services/ocrbootstrap"
Expand Down Expand Up @@ -321,7 +321,7 @@ func StartNewNode(
thresholdKeyShare string,
) *Node {
ctx := testutils.Context(t)
p2pKey := keystest.NewP2PKeyV2(t)
p2pKey := p2pkey.MustNewV2XXXTestingOnly(big.NewInt(int64(port)))
config, _ := heavyweight.FullTestDBV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Insecure.OCRDevelopmentMode = ptr(true)

Expand Down
4 changes: 2 additions & 2 deletions core/services/ocr2/plugins/ocr2keeper/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/keystest"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate"
Expand Down Expand Up @@ -112,7 +112,7 @@ func setupNode(
mercury mercury.MercuryEndpointMock,
) (chainlink.Application, string, common.Address, ocr2key.KeyBundle) {
ctx := testutils.Context(t)
p2pKey := keystest.NewP2PKeyV2(t)
p2pKey := p2pkey.MustNewV2XXXTestingOnly(big.NewInt(int64(port)))
p2paddresses := []string{fmt.Sprintf("127.0.0.1:%d", port)}
cfg, _ := heavyweight.FullTestDBV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Feature.LogPoller = ptr(true)
Expand Down
5 changes: 3 additions & 2 deletions core/web/presenters/p2p_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ package presenters

import (
"fmt"
"math/big"
"testing"

"github.com/manyminds/api2go/jsonapi"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/keystest"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
)

func TestP2PKeyResource(t *testing.T) {
key := keystest.NewP2PKeyV2(t)
key := p2pkey.MustNewV2XXXTestingOnly(big.NewInt(1))
peerID := key.PeerID()
peerIDStr := peerID.String()

Expand Down
Loading