Skip to content

Commit cfd7e74

Browse files
committed
p2p: add test for NewPeer
1 parent 3a09459 commit cfd7e74

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎p2p/peer_test.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/hex"
77
"io/ioutil"
88
"net"
9+
"reflect"
910
"testing"
1011
"time"
1112
)
@@ -222,3 +223,17 @@ func TestPeerActivity(t *testing.T) {
222223
t.Fatal("peer error", err)
223224
}
224225
}
226+
227+
func TestNewPeer(t *testing.T) {
228+
id := NewSimpleClientIdentity("clientid", "version", "customid", "pubkey")
229+
caps := []Cap{{"foo", 2}, {"bar", 3}}
230+
p := NewPeer(id, caps)
231+
if !reflect.DeepEqual(p.Caps(), caps) {
232+
t.Errorf("Caps mismatch: got %v, expected %v", p.Caps(), caps)
233+
}
234+
if p.Identity() != id {
235+
t.Errorf("Identity mismatch: got %v, expected %v", p.Identity(), id)
236+
}
237+
// Should not hang.
238+
p.Disconnect(DiscAlreadyConnected)
239+
}

0 commit comments

Comments
 (0)