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

use real keys in tests instead of go-libp2p-testing/netutil fake keys #1475

Merged
merged 1 commit into from
May 4, 2022
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
4 changes: 2 additions & 2 deletions p2p/net/mock/mock_net.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mocknet

import (
"context"
"crypto/rand"
"fmt"
"net"
"sort"
Expand All @@ -16,7 +17,6 @@ import (
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"

"github.com/libp2p/go-libp2p-peerstore/pstoremem"
p2putil "github.com/libp2p/go-libp2p-testing/netutil"
ma "github.com/multiformats/go-multiaddr"
)

Expand Down Expand Up @@ -64,7 +64,7 @@ func (mn *mocknet) Close() error {
}

func (mn *mocknet) GenPeer() (host.Host, error) {
sk, err := p2putil.RandTestBogusPrivateKey()
sk, _, err := ic.GenerateECDSAKeyPair(rand.Reader)
if err != nil {
return nil, err
}
Expand Down
7 changes: 4 additions & 3 deletions p2p/protocol/identify/obsaddr_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package identify_test

import (
"crypto/rand"
"testing"
"time"

mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/libp2p/go-libp2p/p2p/protocol/identify"

ic "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/event"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"

"github.com/libp2p/go-eventbus"
p2putil "github.com/libp2p/go-libp2p-testing/netutil"
ma "github.com/multiformats/go-multiaddr"
"github.com/stretchr/testify/require"
)
Expand All @@ -29,7 +30,7 @@ type harness struct {

func (h *harness) add(observer ma.Multiaddr) peer.ID {
// create a new fake peer.
sk, err := p2putil.RandTestBogusPrivateKey()
sk, _, err := ic.GenerateECDSAKeyPair(rand.Reader)
if err != nil {
h.t.Fatal(err)
}
Expand Down Expand Up @@ -84,7 +85,7 @@ func (h *harness) observeInbound(observed ma.Multiaddr, observer peer.ID) networ

func newHarness(t *testing.T) harness {
mn := mocknet.New()
sk, err := p2putil.RandTestBogusPrivateKey()
sk, _, err := ic.GenerateECDSAKeyPair(rand.Reader)
require.NoError(t, err)
h, err := mn.AddPeer(sk, ma.StringCast("/ip4/127.0.0.1/tcp/10086"))
require.NoError(t, err)
Expand Down