Skip to content

Commit

Permalink
p2p: add test for NewPeer
Browse files Browse the repository at this point in the history
  • Loading branch information
fjl committed Nov 26, 2014
1 parent 3a09459 commit cfd7e74
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions p2p/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/hex"
"io/ioutil"
"net"
"reflect"
"testing"
"time"
)
Expand Down Expand Up @@ -222,3 +223,17 @@ func TestPeerActivity(t *testing.T) {
t.Fatal("peer error", err)
}
}

func TestNewPeer(t *testing.T) {
id := NewSimpleClientIdentity("clientid", "version", "customid", "pubkey")
caps := []Cap{{"foo", 2}, {"bar", 3}}
p := NewPeer(id, caps)
if !reflect.DeepEqual(p.Caps(), caps) {
t.Errorf("Caps mismatch: got %v, expected %v", p.Caps(), caps)
}
if p.Identity() != id {
t.Errorf("Identity mismatch: got %v, expected %v", p.Identity(), id)
}
// Should not hang.
p.Disconnect(DiscAlreadyConnected)
}

0 comments on commit cfd7e74

Please sign in to comment.