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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update test usage.
pavel-raykov committed Nov 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 42c8d47f38d27236c3517ba7f06440890297d4c9
6 changes: 3 additions & 3 deletions core/internal/features/features_test.go
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ import (
"github.com/google/uuid"
"github.com/hashicorp/consul/sdk/freeport"
"github.com/onsi/gomega"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
@@ -64,7 +65,6 @@ 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/ocr"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
@@ -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(1))
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.

@@ -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(1))
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.

4 changes: 2 additions & 2 deletions core/internal/features/ocr2/features_ocr2_test.go
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import (
"github.com/ethereum/go-ethereum/ethclient/simulated"
"github.com/hashicorp/consul/sdk/freeport"
"github.com/onsi/gomega"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

@@ -45,7 +46,6 @@ 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/ocr2/testhelpers"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate"
@@ -112,7 +112,7 @@ func setupNodeOCR2(
p2pV2Bootstrappers []commontypes.BootstrapperLocator,
) *ocr2Node {
ctx := testutils.Context(t)
p2pKey := keystest.NewP2PKeyV2(t)
p2pKey := p2pkey.MustNewV2XXXTestingOnly(big.NewInt(1))
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.

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

"github.com/ethereum/go-ethereum/common"
"github.com/google/uuid"
"github.com/lib/pq"
"github.com/pkg/errors"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
@@ -22,7 +24,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"
@@ -36,7 +38,6 @@ 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"
ksmocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
@@ -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)
@@ -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()

Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ import (
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/hashicorp/consul/sdk/freeport"
"github.com/onsi/gomega"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/libocr/commontypes"
@@ -45,7 +46,6 @@ 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"
functionsConfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/functions/config"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate"
@@ -321,7 +321,7 @@ func StartNewNode(
thresholdKeyShare string,
) *Node {
ctx := testutils.Context(t)
p2pKey := keystest.NewP2PKeyV2(t)
p2pKey := p2pkey.MustNewV2XXXTestingOnly(big.NewInt(1))
config, _ := heavyweight.FullTestDBV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Insecure.OCRDevelopmentMode = ptr(true)

4 changes: 2 additions & 2 deletions core/services/ocr2/plugins/ocr2keeper/integration_test.go
Original file line number Diff line number Diff line change
@@ -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"
@@ -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(1))
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)
6 changes: 3 additions & 3 deletions core/web/presenters/p2p_key_test.go
Original file line number Diff line number Diff line change
@@ -2,17 +2,17 @@ package presenters

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

"github.com/manyminds/api2go/jsonapi"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

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

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