aboutsummaryrefslogtreecommitdiff
path: root/peer/messages_test.go
blob: a21e4e0ac8212a1c074818021ae4c107e6a1734b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package peer

import (
	"bytes"
	"testing"
)

func TestHandshake(t *testing.T) {
	h := Handshake{
		Proto:  Proto,
		PeerID: NewIDFixed(),
	}
	b := &bytes.Buffer{}
	h.Encode(b)
	t.Log(b.Bytes())
	if len(b.Bytes()) != len(Proto)+49 {
		t.Error("expexted X+49 len")
	}
	r := bytes.NewReader(b.Bytes())
	hh, ok := DecodeHandshake(r)
	if !ok {
		t.Error("not ok")
	}
	t.Log(hh)
}