diff --git a/.changeset/chilled-papayas-swim.md b/.changeset/chilled-papayas-swim.md new file mode 100644 index 00000000000..e2f2b536514 --- /dev/null +++ b/.changeset/chilled-papayas-swim.md @@ -0,0 +1,5 @@ +--- +"chainlink": minor +--- + +#removed Remove duplicated testing util for p2p_key only. diff --git a/core/internal/features/features_test.go b/core/internal/features/features_test.go index 919b01f3364..2d0d046857c 100644 --- a/core/internal/features/features_test.go +++ b/core/internal/features/features_test.go @@ -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" @@ -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. @@ -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. diff --git a/core/internal/features/ocr2/features_ocr2_test.go b/core/internal/features/ocr2/features_ocr2_test.go index 2d8f55fcc9d..cbde866c6a4 100644 --- a/core/internal/features/ocr2/features_ocr2_test.go +++ b/core/internal/features/ocr2/features_ocr2_test.go @@ -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" @@ -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. diff --git a/core/services/feeds/service_test.go b/core/services/feeds/service_test.go index 115695d8514..5369d645c4e 100644 --- a/core/services/feeds/service_test.go +++ b/core/services/feeds/service_test.go @@ -5,6 +5,7 @@ import ( "database/sql" "encoding/hex" "fmt" + "math/big" "testing" "time" @@ -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" @@ -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" @@ -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() diff --git a/core/services/keystore/keys/keystest/keystest.go b/core/services/keystore/keys/keystest/keystest.go deleted file mode 100644 index 9265dc6e189..00000000000 --- a/core/services/keystore/keys/keystest/keystest.go +++ /dev/null @@ -1,15 +0,0 @@ -package keystest - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" -) - -func NewP2PKeyV2(t *testing.T) p2pkey.KeyV2 { - k, err := p2pkey.NewV2() - require.NoError(t, err) - return k -} diff --git a/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go b/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go index a42997add2d..98aea240134 100644 --- a/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go +++ b/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go @@ -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" @@ -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) diff --git a/core/services/ocr2/plugins/ocr2keeper/integration_test.go b/core/services/ocr2/plugins/ocr2keeper/integration_test.go index c08cc3265e8..66112756370 100644 --- a/core/services/ocr2/plugins/ocr2keeper/integration_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/integration_test.go @@ -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(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) diff --git a/core/web/presenters/p2p_key_test.go b/core/web/presenters/p2p_key_test.go index 4e7b4e954fd..2d6d307f207 100644 --- a/core/web/presenters/p2p_key_test.go +++ b/core/web/presenters/p2p_key_test.go @@ -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()