msgversion_test.go raw

   1  package wire
   2  
   3  import (
   4  	"net"
   5  	"reflect"
   6  	"strings"
   7  	"testing"
   8  	
   9  	"github.com/davecgh/go-spew/spew"
  10  )
  11  
  12  // TestVersion tests the MsgVersion API.
  13  func TestVersion(t *testing.T) {
  14  	pver := ProtocolVersion
  15  	// Create version message data.
  16  	lastBlock := int32(234234)
  17  	tcpAddrMe := &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 11047}
  18  	me := NewNetAddress(tcpAddrMe, SFNodeNetwork)
  19  	tcpAddrYou := &net.TCPAddr{IP: net.ParseIP("192.168.0.1"), Port: 11047}
  20  	you := NewNetAddress(tcpAddrYou, SFNodeNetwork)
  21  	nonce, e := RandomUint64()
  22  	if e != nil {
  23  		t.Errorf("RandomUint64: error generating nonce: %v", e)
  24  	}
  25  	// Ensure we get the correct data back out.
  26  	msg := NewMsgVersion(me, you, nonce, lastBlock)
  27  	if msg.ProtocolVersion != int32(pver) {
  28  		t.Errorf("NewMsgVersion: wrong protocol version - got %v, want %v",
  29  			msg.ProtocolVersion, pver,
  30  		)
  31  	}
  32  	if !reflect.DeepEqual(&msg.AddrMe, me) {
  33  		t.Errorf("NewMsgVersion: wrong me address - got %v, want %v",
  34  			spew.Sdump(&msg.AddrMe), spew.Sdump(me),
  35  		)
  36  	}
  37  	if !reflect.DeepEqual(&msg.AddrYou, you) {
  38  		t.Errorf("NewMsgVersion: wrong you address - got %v, want %v",
  39  			spew.Sdump(&msg.AddrYou), spew.Sdump(you),
  40  		)
  41  	}
  42  	if msg.Nonce != nonce {
  43  		t.Errorf("NewMsgVersion: wrong nonce - got %v, want %v",
  44  			msg.Nonce, nonce,
  45  		)
  46  	}
  47  	if msg.UserAgent != DefaultUserAgent {
  48  		t.Errorf("NewMsgVersion: wrong user agent - got %v, want %v",
  49  			msg.UserAgent, DefaultUserAgent,
  50  		)
  51  	}
  52  	if msg.LastBlock != lastBlock {
  53  		t.Errorf("NewMsgVersion: wrong last block - got %v, want %v",
  54  			msg.LastBlock, lastBlock,
  55  		)
  56  	}
  57  	if msg.DisableRelayTx {
  58  		t.Errorf("NewMsgVersion: disable relay tx is not false by "+
  59  			"default - got %v, want %v", msg.DisableRelayTx, false,
  60  		)
  61  	}
  62  	e = msg.AddUserAgent("myclient", "1.2.3", "optional", "comments")
  63  	if e != nil {
  64  		t.Log(e)
  65  	}
  66  	customUserAgent := DefaultUserAgent + "myclient:1.2.3(optional; comments)/"
  67  	if msg.UserAgent != customUserAgent {
  68  		t.Errorf("AddUserAgent: wrong user agent - got %s, want %s",
  69  			msg.UserAgent, customUserAgent,
  70  		)
  71  	}
  72  	e = msg.AddUserAgent("mygui", "3.4.5")
  73  	if e != nil {
  74  		t.Log(e)
  75  	}
  76  	customUserAgent += "mygui:3.4.5/"
  77  	if msg.UserAgent != customUserAgent {
  78  		t.Errorf("AddUserAgent: wrong user agent - got %s, want %s",
  79  			msg.UserAgent, customUserAgent,
  80  		)
  81  	}
  82  	// accounting for ":", "/"
  83  	e = msg.AddUserAgent(strings.Repeat("t",
  84  		MaxUserAgentLen-len(customUserAgent)-2+1,
  85  	), "",
  86  	)
  87  	if _, ok := e.(*MessageError); !ok {
  88  		t.Errorf("AddUserAgent: expected error not received "+
  89  			"- got %v, want %T", e, MessageError{},
  90  		)
  91  	}
  92  	// Version message should not have any services set by default.
  93  	if msg.Services != 0 {
  94  		t.Errorf("NewMsgVersion: wrong default services - got %v, want %v",
  95  			msg.Services, 0,
  96  		)
  97  	}
  98  	if msg.HasService(SFNodeNetwork) {
  99  		t.Errorf("HasService: SFNodeNetwork service is set")
 100  	}
 101  	// Ensure the command is expected value.
 102  	wantCmd := "version"
 103  	if cmd := msg.Command(); cmd != wantCmd {
 104  		t.Errorf("NewMsgVersion: wrong command - got %v want %v",
 105  			cmd, wantCmd,
 106  		)
 107  	}
 108  	// Ensure max payload is expected value. Protocol version 4 bytes + services 8 bytes + timestamp 8 bytes + remote
 109  	// and local net addresses + nonce 8 bytes + length of user agent (varInt) + max allowed user agent length + last
 110  	// block 4 bytes + relay transactions flag 1 byte.
 111  	wantPayload := uint32(358)
 112  	maxPayload := msg.MaxPayloadLength(pver)
 113  	if maxPayload != wantPayload {
 114  		t.Errorf("MaxPayloadLength: wrong max payload length for "+
 115  			"protocol version %d - got %v, want %v", pver,
 116  			maxPayload, wantPayload,
 117  		)
 118  	}
 119  	// Ensure adding the full service node flag works.
 120  	msg.AddService(SFNodeNetwork)
 121  	if msg.Services != SFNodeNetwork {
 122  		t.Errorf("AddService: wrong services - got %v, want %v",
 123  			msg.Services, SFNodeNetwork,
 124  		)
 125  	}
 126  	if !msg.HasService(SFNodeNetwork) {
 127  		t.Errorf("HasService: SFNodeNetwork service not set")
 128  	}
 129  }
 130  
 131  // // TestVersionWire tests the MsgVersion wire encode and decode for various protocol versions.
 132  // func TestVersionWire(// 	t *testing.T) {
 133  // 	// verRelayTxFalse and verRelayTxFalseEncoded is a version message as of BIP0037Version with the transaction relay disabled.
 134  // 	baseVersionBIP0037Copy := *baseVersionBIP0037
 135  // 	verRelayTxFalse := &baseVersionBIP0037Copy
 136  // 	verRelayTxFalse.DisableRelayTx = true
 137  // 	verRelayTxFalseEncoded := make([]byte, len(baseVersionBIP0037Encoded))
 138  // 	copy(verRelayTxFalseEncoded, baseVersionBIP0037Encoded)
 139  // 	verRelayTxFalseEncoded[len(verRelayTxFalseEncoded)-1] = 0
 140  // 	tests := []struct {
 141  // 		in   *MsgVersion     // Message to encode
 142  // 		out  *MsgVersion     // Expected decoded message
 143  // 		buf  []byte          // Wire encoding
 144  // 		pver uint32          // Protocol version for wire encoding
 145  // 		enc  MessageEncoding // Message encoding format
 146  // 	}{
 147  // 		// Latest protocol version.
 148  // 		{
 149  // 			baseVersionBIP0037,
 150  // 			baseVersionBIP0037,
 151  // 			baseVersionBIP0037Encoded,
 152  // 			ProtocolVersion,
 153  // 			BaseEncoding,
 154  // 		},
 155  // 		// Protocol version BIP0037Version with relay transactions field true.
 156  // 		{
 157  // 			baseVersionBIP0037,
 158  // 			baseVersionBIP0037,
 159  // 			baseVersionBIP0037Encoded,
 160  // 			BIP0037Version,
 161  // 			BaseEncoding,
 162  // 		},
 163  // 		// Protocol version BIP0037Version with relay transactions field false.
 164  // 		{
 165  // 			verRelayTxFalse,
 166  // 			verRelayTxFalse,
 167  // 			verRelayTxFalseEncoded,
 168  // 			BIP0037Version,
 169  // 			BaseEncoding,
 170  // 		},
 171  // 		// Protocol version BIP0035Version.
 172  // 		{
 173  // 			baseVersion,
 174  // 			baseVersion,
 175  // 			baseVersionEncoded,
 176  // 			BIP0035Version,
 177  // 			BaseEncoding,
 178  // 		},
 179  // 		// Protocol version BIP0031Version.
 180  // 		{
 181  // 			baseVersion,
 182  // 			baseVersion,
 183  // 			baseVersionEncoded,
 184  // 			BIP0031Version,
 185  // 			BaseEncoding,
 186  // 		},
 187  // 		// Protocol version NetAddressTimeVersion.
 188  // 		{
 189  // 			baseVersion,
 190  // 			baseVersion,
 191  // 			baseVersionEncoded,
 192  // 			NetAddressTimeVersion,
 193  // 			BaseEncoding,
 194  // 		},
 195  // 		// Protocol version MultipleAddressVersion.
 196  // 		{
 197  // 			baseVersion,
 198  // 			baseVersion,
 199  // 			baseVersionEncoded,
 200  // 			MultipleAddressVersion,
 201  // 			BaseEncoding,
 202  // 		},
 203  // 	}
 204  // 	t.Logf("Running %d tests", len(tests))
 205  // 	for i, test := range tests {
 206  // 		// Encode the message to wire format.
 207  // 		var buf bytes.Buffer
 208  // 		e := test.in.BtcEncode(&buf, test.pver, test.enc)
 209  // 		if e != nil  {
 210  // 			t.Errorf("BtcEncode #%d error %v", i, err)
 211  // 			continue
 212  // 		}
 213  // 		if !bytes.Equal(buf.Hash(), test.buf) {
 214  // 			t.Errorf("BtcEncode #%d\n got: %s want: %s", i,
 215  // 				spew.Sdump(buf.Hash()), spew.Sdump(test.buf))
 216  // 			continue
 217  // 		}
 218  // 		// Decode the message from wire format.
 219  // 		var msg MsgVersion
 220  // 		rbuf := bytes.NewBuffer(test.buf)
 221  // 		e = msg.BtcDecode(rbuf, test.pver, test.enc)
 222  // 		if e != nil  {
 223  // 			t.Errorf("BtcDecode #%d error %v", i, err)
 224  // 			continue
 225  // 		}
 226  // 		if !reflect.DeepEqual(&msg, test.out) {
 227  // 			t.Errorf("BtcDecode #%d\n got: %s want: %s", i,
 228  // 				spew.Sdump(msg), spew.Sdump(test.out))
 229  // 			continue
 230  // 		}
 231  // 	}
 232  // }
 233  
 234  // // TestVersionWireErrors performs negative tests against wire encode and decode of MsgGetHeaders to confirm error paths work correctly.
 235  // func TestVersionWireErrors(// 	t *testing.T) {
 236  // 	// Use protocol version 60002 specifically here instead of the latest because the test data is using bytes encoded with that protocol version.
 237  // 	pver := uint32(60002)
 238  // 	enc := BaseEncoding
 239  // 	wireErr := &MessageError{}
 240  // 	// Ensure calling MsgVersion.BtcDecode with a non *bytes.Buffer returns error.
 241  // 	fr := newFixedReader(0, []byte{})
 242  // 	if e := baseVersion.BtcDecode(fr, pver, enc); e ==  nil {
 243  // 		t.Errorf("Did not received error when calling " +
 244  // 			"MsgVersion.BtcDecode with non *bytes.Buffer")
 245  // 	}
 246  // 	// Copy the base version and change the user agent to exceed max limits.
 247  // 	bvc := *baseVersion
 248  // 	exceedUAVer := &bvc
 249  // 	newUA := "/" + strings.Repeat("t", MaxUserAgentLen-8+1) + ":0.0.1/"
 250  // 	exceedUAVer.UserAgent = newUA
 251  // 	// Encode the new UA length as a varint.
 252  // 	var newUAVarIntBuf bytes.Buffer
 253  // 	e := WriteVarInt(&newUAVarIntBuf, pver, uint64(len(newUA)))
 254  // 	if e != nil  {
 255  // 		t.Errorf("WriteVarInt: error %v", err)
 256  // 	}
 257  // 	// Make a new buffer big enough to hold the base version plus the new bytes for the bigger varint to hold the new size of the user agent and the new user agent string.  Then stich it all together.
 258  // 	newLen := len(baseVersionEncoded) - len(baseVersion.UserAgent)
 259  // 	newLen = newLen + len(newUAVarIntBuf.Hash()) - 1 + len(newUA)
 260  // 	exceedUAVerEncoded := make([]byte, newLen)
 261  // 	copy(exceedUAVerEncoded, baseVersionEncoded[0:80])
 262  // 	copy(exceedUAVerEncoded[80:], newUAVarIntBuf.Hash())
 263  // 	copy(exceedUAVerEncoded[83:], []byte(newUA))
 264  // 	copy(exceedUAVerEncoded[83+len(newUA):], baseVersionEncoded[97:100])
 265  // 	tests := []struct {
 266  // 		in       *MsgVersion     // value to encode
 267  // 		buf      []byte          // Wire encoding
 268  // 		pver     uint32          // Protocol version for wire encoding
 269  // 		enc      MessageEncoding // Message encoding format
 270  // 		max      int             // Max size of fixed buffer to induce errors
 271  // 		writeErr error           // Expected write error
 272  // 		readErr  error           // Expected read error
 273  // 	}{
 274  // 		// Force error in protocol version.
 275  // 		{baseVersion, baseVersionEncoded, pver, BaseEncoding, 0, io.ErrShortWrite, io.EOF},
 276  // 		// Force error in services.
 277  // 		{baseVersion, baseVersionEncoded, pver, BaseEncoding, 4, io.ErrShortWrite, io.EOF},
 278  // 		// Force error in timestamp.
 279  // 		{baseVersion, baseVersionEncoded, pver, BaseEncoding, 12, io.ErrShortWrite, io.EOF},
 280  // 		// Force error in remote address.
 281  // 		{baseVersion, baseVersionEncoded, pver, BaseEncoding, 20, io.ErrShortWrite, io.EOF},
 282  // 		// Force error in local address.
 283  // 		{baseVersion, baseVersionEncoded, pver, BaseEncoding, 47, io.ErrShortWrite, io.ErrUnexpectedEOF},
 284  // 		// Force error in nonce.
 285  // 		{baseVersion, baseVersionEncoded, pver, BaseEncoding, 73, io.ErrShortWrite, io.ErrUnexpectedEOF},
 286  // 		// Force error in user agent length.
 287  // 		{baseVersion, baseVersionEncoded, pver, BaseEncoding, 81, io.ErrShortWrite, io.EOF},
 288  // 		// Force error in user agent.
 289  // 		{baseVersion, baseVersionEncoded, pver, BaseEncoding, 82, io.ErrShortWrite, io.ErrUnexpectedEOF},
 290  // 		// Force error in last block.
 291  // 		{baseVersion, baseVersionEncoded, pver, BaseEncoding, 98, io.ErrShortWrite, io.ErrUnexpectedEOF},
 292  // 		// Force error in relay tx - no read error should happen since it's optional.
 293  // 		{
 294  // 			baseVersionBIP0037, baseVersionBIP0037Encoded,
 295  // 			BIP0037Version, BaseEncoding, 101, io.ErrShortWrite, nil,
 296  // 		},
 297  // 		// Force error due to user agent too big
 298  // 		{exceedUAVer, exceedUAVerEncoded, pver, BaseEncoding, newLen, wireErr, wireErr},
 299  // 	}
 300  // 	t.Logf("Running %d tests", len(tests))
 301  // 	for i, test := range tests {
 302  // 		// Encode to wire format.
 303  // 		w := newFixedWriter(test.max)
 304  // 		e := test.in.BtcEncode(w, test.pver, test.enc)
 305  // 		if reflect.TypeOf(err) != reflect.TypeOf(test.writeErr) {
 306  // 			t.Errorf("BtcEncode #%d wrong error got: %v, want: %v",
 307  // 				i, e, test.writeErr)
 308  // 			continue
 309  // 		}
 310  // 		// For errors which are not of type MessageError, check them for equality.
 311  // 		if _, ok := err.(*MessageError); !ok {
 312  // 			if err != test.writeErr {
 313  // 				t.Errorf("BtcEncode #%d wrong error got: %v, "+
 314  // 					"want: %v", i, e, test.writeErr)
 315  // 				continue
 316  // 			}
 317  // 		}
 318  // 		// Decode from wire format.
 319  // 		var msg MsgVersion
 320  // 		buf := bytes.NewBuffer(test.buf[0:test.max])
 321  // 		e = msg.BtcDecode(buf, test.pver, test.enc)
 322  // 		if reflect.TypeOf(err) != reflect.TypeOf(test.readErr) {
 323  // 			t.Errorf("BtcDecode #%d wrong error got: %v, want: %v",
 324  // 				i, e, test.readErr)
 325  // 			continue
 326  // 		}
 327  // 		// For errors which are not of type MessageError, check them for equality.
 328  // 		if _, ok := err.(*MessageError); !ok {
 329  // 			if err != test.readErr {
 330  // 				t.Errorf("BtcDecode #%d wrong error got: %v, "+
 331  // 					"want: %v", i, e, test.readErr)
 332  // 				continue
 333  // 			}
 334  // 		}
 335  // 	}
 336  // }
 337  
 338  // // TestVersionOptionalFields performs tests to ensure that an encoded version messages that omit optional fields are handled correctly.
 339  // func TestVersionOptionalFields(// 	t *testing.T) {
 340  // 	// onlyRequiredVersion is a version message that only contains the required versions and all other values set to their default values.
 341  // 	onlyRequiredVersion := MsgVersion{
 342  // 		ProtocolVersion: 60002,
 343  // 		Services:        SFNodeNetwork,
 344  // 		Timestamp:       time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST)
 345  // 		AddrYou: NetAddress{
 346  // 			Timestamp: time.Time{}, // Zero value -- no timestamp in version
 347  // 			Services:  SFNodeNetwork,
 348  // 			IP:        net.ParseIP("192.168.0.1"),
 349  // 			Port:      11047,
 350  // 		},
 351  // 	}
 352  // 	onlyRequiredVersionEncoded := make([]byte, len(baseVersionEncoded)-55)
 353  // 	copy(onlyRequiredVersionEncoded, baseVersionEncoded)
 354  // 	// addrMeVersion is a version message that contains all fields through the AddrMe field.
 355  // 	addrMeVersion := onlyRequiredVersion
 356  // 	addrMeVersion.AddrMe = NetAddress{
 357  // 		Timestamp: time.Time{}, // Zero value -- no timestamp in version
 358  // 		Services:  SFNodeNetwork,
 359  // 		IP:        net.ParseIP("127.0.0.1"),
 360  // 		Port:      11047,
 361  // 	}
 362  // 	addrMeVersionEncoded := make([]byte, len(baseVersionEncoded)-29)
 363  // 	copy(addrMeVersionEncoded, baseVersionEncoded)
 364  // 	// nonceVersion is a version message that contains all fields through the Nonce field.
 365  // 	nonceVersion := addrMeVersion
 366  // 	nonceVersion.Nonce = 123123 // 0x1e0f3
 367  // 	nonceVersionEncoded := make([]byte, len(baseVersionEncoded)-21)
 368  // 	copy(nonceVersionEncoded, baseVersionEncoded)
 369  // 	// uaVersion is a version message that contains all fields through the UserAgent field.
 370  // 	uaVersion := nonceVersion
 371  // 	uaVersion.UserAgent = "/podtest:0.0.1/"
 372  // 	uaVersionEncoded := make([]byte, len(baseVersionEncoded)-4)
 373  // 	copy(uaVersionEncoded, baseVersionEncoded)
 374  // 	// lastBlockVersion is a version message that contains all fields through the LastBlock field.
 375  // 	lastBlockVersion := uaVersion
 376  // 	lastBlockVersion.LastBlock = 234234 // 0x392fa
 377  // 	lastBlockVersionEncoded := make([]byte, len(baseVersionEncoded))
 378  // 	copy(lastBlockVersionEncoded, baseVersionEncoded)
 379  // 	tests := []struct {
 380  // 		msg  *MsgVersion     // Expected message
 381  // 		buf  []byte          // Wire encoding
 382  // 		pver uint32          // Protocol version for wire encoding
 383  // 		enc  MessageEncoding // Message encoding format
 384  // 	}{
 385  // 		{
 386  // 			&onlyRequiredVersion,
 387  // 			onlyRequiredVersionEncoded,
 388  // 			ProtocolVersion,
 389  // 			BaseEncoding,
 390  // 		},
 391  // 		{
 392  // 			&addrMeVersion,
 393  // 			addrMeVersionEncoded,
 394  // 			ProtocolVersion,
 395  // 			BaseEncoding,
 396  // 		},
 397  // 		{
 398  // 			&nonceVersion,
 399  // 			nonceVersionEncoded,
 400  // 			ProtocolVersion,
 401  // 			BaseEncoding,
 402  // 		},
 403  // 		{
 404  // 			&uaVersion,
 405  // 			uaVersionEncoded,
 406  // 			ProtocolVersion,
 407  // 			BaseEncoding,
 408  // 		},
 409  // 		{
 410  // 			&lastBlockVersion,
 411  // 			lastBlockVersionEncoded,
 412  // 			ProtocolVersion,
 413  // 			BaseEncoding,
 414  // 		},
 415  // 	}
 416  // 	for i, test := range tests {
 417  // 		// Decode the message from wire format.
 418  // 		var msg MsgVersion
 419  // 		rbuf := bytes.NewBuffer(test.buf)
 420  // 		e := msg.BtcDecode(rbuf, test.pver, test.enc)
 421  // 		if e != nil  {
 422  // 			t.Errorf("BtcDecode #%d error %v", i, err)
 423  // 			continue
 424  // 		}
 425  // 		if !reflect.DeepEqual(&msg, test.msg) {
 426  // 			t.Errorf("BtcDecode #%d\n got: %s want: %s", i,
 427  // 				spew.Sdump(msg), spew.Sdump(test.msg))
 428  // 			continue
 429  // 		}
 430  // 	}
 431  // }
 432  
 433  // // baseVersion is used in the various tests as a baseline MsgVersion.
 434  // var baseVersion = &MsgVersion{
 435  // 	ProtocolVersion: 60002,
 436  // 	Services:        SFNodeNetwork,
 437  // 	Timestamp:       time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST)
 438  // 	AddrYou: NetAddress{
 439  // 		Timestamp: time.Time{}, // Zero value -- no timestamp in version
 440  // 		Services:  SFNodeNetwork,
 441  // 		IP:        net.ParseIP("192.168.0.1"),
 442  // 		Port:      11047,
 443  // 	},
 444  // 	AddrMe: NetAddress{
 445  // 		Timestamp: time.Time{}, // Zero value -- no timestamp in version
 446  // 		Services:  SFNodeNetwork,
 447  // 		IP:        net.ParseIP("127.0.0.1"),
 448  // 		Port:      11047,
 449  // 	},
 450  // 	Nonce:     123123, // 0x1e0f3
 451  // 	UserAgent: "/podtest:0.0.1/",
 452  // 	LastBlock: 234234, // 0x392fa
 453  // }
 454  
 455  // // baseVersionEncoded is the wire encoded bytes for baseVersion using protocol version 60002 and is used in the various tests.
 456  // var baseVersionEncoded = []byte{
 457  // 	0x62, 0xea, 0x00, 0x00, // Protocol version 60002
 458  // 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SFNodeNetwork
 459  // 	0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // 64-bit Timestamp
 460  // 	// AddrYou -- No timestamp for NetAddress in version message
 461  // 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SFNodeNetwork
 462  // 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 463  // 	0x00, 0x00, 0xff, 0xff, 0xc0, 0xa8, 0x00, 0x01, // IP 192.168.0.1
 464  // 	0x20, 0x8d, // Port 11047 in big-endian
 465  // 	// AddrMe -- No timestamp for NetAddress in version message
 466  // 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SFNodeNetwork
 467  // 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 468  // 	0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x01, // IP 127.0.0.1
 469  // 	0x20, 0x8d, // Port 11047 in big-endian
 470  // 	0xf3, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // Nonce
 471  // 	0x10, // Varint for user agent length
 472  // 	0x2f, 0x62, 0x74, 0x63, 0x64, 0x74, 0x65, 0x73,
 473  // 	0x74, 0x3a, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x2f, // User agent
 474  // 	0xfa, 0x92, 0x03, 0x00, // Last block
 475  // }
 476  
 477  // // baseVersionBIP0037 is used in the various tests as a baseline MsgVersion for BIP0037.
 478  // var baseVersionBIP0037 = &MsgVersion{
 479  // 	ProtocolVersion: 70001,
 480  // 	Services:        SFNodeNetwork,
 481  // 	Timestamp:       time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST)
 482  // 	AddrYou: NetAddress{
 483  // 		Timestamp: time.Time{}, // Zero value -- no timestamp in version
 484  // 		Services:  SFNodeNetwork,
 485  // 		IP:        net.ParseIP("192.168.0.1"),
 486  // 		Port:      11047,
 487  // 	},
 488  // 	AddrMe: NetAddress{
 489  // 		Timestamp: time.Time{}, // Zero value -- no timestamp in version
 490  // 		Services:  SFNodeNetwork,
 491  // 		IP:        net.ParseIP("127.0.0.1"),
 492  // 		Port:      11047,
 493  // 	},
 494  // 	Nonce:     123123, // 0x1e0f3
 495  // 	UserAgent: "/podtest:0.0.1/",
 496  // 	LastBlock: 234234, // 0x392fa
 497  // }
 498  
 499  // // baseVersionBIP0037Encoded is the wire encoded bytes for baseVersionBIP0037 using protocol version BIP0037Version and is used in the various tests.
 500  // var baseVersionBIP0037Encoded = []byte{
 501  // 	0x71, 0x11, 0x01, 0x00, // Protocol version 70001
 502  // 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SFNodeNetwork
 503  // 	0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // 64-bit Timestamp
 504  // 	// AddrYou -- No timestamp for NetAddress in version message
 505  // 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SFNodeNetwork
 506  // 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 507  // 	0x00, 0x00, 0xff, 0xff, 0xc0, 0xa8, 0x00, 0x01, // IP 192.168.0.1
 508  // 	0x20, 0x8d, // Port 11047 in big-endian
 509  // 	// AddrMe -- No timestamp for NetAddress in version message
 510  // 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SFNodeNetwork
 511  // 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 512  // 	0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x01, // IP 127.0.0.1
 513  // 	0x20, 0x8d, // Port 11047 in big-endian
 514  // 	0xf3, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // Nonce
 515  // 	0x10, // Varint for user agent length
 516  // 	0x2f, 0x62, 0x74, 0x63, 0x64, 0x74, 0x65, 0x73,
 517  // 	0x74, 0x3a, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x2f, // User agent
 518  // 	0xfa, 0x92, 0x03, 0x00, // Last block
 519  // 	0x01, // Relay tx
 520  // }
 521