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 unneeeded build info function in Identify #1378

Closed
wants to merge 2 commits into from
Closed
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
14 changes: 0 additions & 14 deletions p2p/protocol/identify/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"runtime/debug"
"sync"
"time"

Expand Down Expand Up @@ -55,19 +54,6 @@ var (
defaultUserAgent = "github.com/libp2p/go-libp2p"
)

func init() {
bi, ok := debug.ReadBuildInfo()
if !ok {
return
}
version := bi.Main.Version
if version == "(devel)" {
defaultUserAgent = bi.Main.Path
} else {
defaultUserAgent = fmt.Sprintf("%s@%s", bi.Main.Path, bi.Main.Version)
}
}

type addPeerHandlerReq struct {
rp peer.ID
resp chan *peerHandler
Expand Down
19 changes: 8 additions & 11 deletions p2p/protocol/identify/id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,18 @@ func testHasCertifiedAddrs(t *testing.T, h host.Host, p peer.ID, expected []ma.M
}

func testHasProtocolVersions(t *testing.T, h host.Host, p peer.ID) {
t.Helper()
v, err := h.Peerstore().Get(p, "ProtocolVersion")
if v == nil {
t.Error("no protocol version")
return
}
if v.(string) != identify.LibP2PVersion {
t.Error("protocol mismatch", err)
}
require.NoError(t, err)
require.NotNil(t, v, "no protocol version")
require.Equal(t, identify.LibP2PVersion, v.(string), "protocol mismatch")
v, err = h.Peerstore().Get(p, "AgentVersion")
if v.(string) != "github.com/libp2p/go-libp2p" { // this is the default user agent
t.Error("agent version mismatch", err)
}
require.NoError(t, err)
require.Equal(t, "github.com/libp2p/go-libp2p", v.(string), "agent version mismatch")
}

func testHasPublicKey(t *testing.T, h host.Host, p peer.ID, shouldBe ic.PubKey) {
t.Helper()
k := h.Peerstore().PubKey(p)
if k == nil {
t.Error("no public key")
Expand Down Expand Up @@ -191,7 +188,7 @@ func TestIDService(t *testing.T) {
ids1.IdentifyConn(h1t2c[0])

// the idService should be opened automatically, by the network.
// what we should see now is that both peers know about each others listen addresses.
// what we should see now is that both peers know about each other's listen addresses.
t.Log("test peer1 has peer2 addrs correctly")
testKnowsAddrs(t, h1, h2p, h2.Addrs()) // has them
testHasCertifiedAddrs(t, h1, h2p, h2.Peerstore().Addrs(h2p)) // should have signed addrs also
Expand Down