[NOD-608] Make the user agent read the version from the version package. (#566)

This commit is contained in:
stasatdaglabs 2020-01-05 16:47:58 +02:00 committed by Dan Aharoni
parent ebf635e6ff
commit df91643976
3 changed files with 7 additions and 6 deletions

View File

@ -241,8 +241,8 @@ func TestPeerConnection(t *testing.T) {
wantLastPingNonce: uint64(0), wantLastPingNonce: uint64(0),
wantLastPingMicros: int64(0), wantLastPingMicros: int64(0),
wantTimeOffset: int64(0), wantTimeOffset: int64(0),
wantBytesSent: 198, // 174 version + 24 verack wantBytesSent: 201, // 177 version + 24 verack
wantBytesReceived: 198, wantBytesReceived: 201,
} }
wantStats2 := peerStats{ wantStats2 := peerStats{
wantUserAgent: wire.DefaultUserAgent + "peer:1.0(comment)/", wantUserAgent: wire.DefaultUserAgent + "peer:1.0(comment)/",
@ -255,8 +255,8 @@ func TestPeerConnection(t *testing.T) {
wantLastPingNonce: uint64(0), wantLastPingNonce: uint64(0),
wantLastPingMicros: int64(0), wantLastPingMicros: int64(0),
wantTimeOffset: int64(0), wantTimeOffset: int64(0),
wantBytesSent: 198, // 174 version + 24 verack wantBytesSent: 201, // 177 version + 24 verack
wantBytesReceived: 198, wantBytesReceived: 201,
} }
tests := []struct { tests := []struct {

View File

@ -79,7 +79,7 @@ func TestMessage(t *testing.T) {
kaspaNet KaspaNet // Network to use for wire encoding kaspaNet KaspaNet // Network to use for wire encoding
bytes int // Expected num bytes read/written bytes int // Expected num bytes read/written
}{ }{
{msgVersion, msgVersion, pver, MainNet, 156}, {msgVersion, msgVersion, pver, MainNet, 159},
{msgVerack, msgVerack, pver, MainNet, 24}, {msgVerack, msgVerack, pver, MainNet, 24},
{msgGetAddr, msgGetAddr, pver, MainNet, 26}, {msgGetAddr, msgGetAddr, pver, MainNet, 26},
{msgAddr, msgAddr, pver, MainNet, 27}, {msgAddr, msgAddr, pver, MainNet, 27},

View File

@ -7,6 +7,7 @@ package wire
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/kaspanet/kaspad/version"
"github.com/pkg/errors" "github.com/pkg/errors"
"io" "io"
"strings" "strings"
@ -21,7 +22,7 @@ import (
const MaxUserAgentLen = 256 const MaxUserAgentLen = 256
// DefaultUserAgent for wire in the stack // DefaultUserAgent for wire in the stack
const DefaultUserAgent = "/kaspawire:0.1.0/" var DefaultUserAgent = fmt.Sprintf("/kaspad:%s/", version.Version())
// MsgVersion implements the Message interface and represents a kaspa version // MsgVersion implements the Message interface and represents a kaspa version
// message. It is used for a peer to advertise itself as soon as an outbound // message. It is used for a peer to advertise itself as soon as an outbound