aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2014-11-27 05:49:40 +0800
committerFelix Lange <fjl@twurst.com>2014-11-27 05:49:40 +0800
commitcfd7e74c25fa7d1b443f8527fca8afad14ef4419 (patch)
treee10c3628546d59089694d2dbe904c585a24267d1
parent3a09459c4c3c6d4edefa57a9b245402003ae191e (diff)
downloadgo-tangerine-cfd7e74c25fa7d1b443f8527fca8afad14ef4419.tar
go-tangerine-cfd7e74c25fa7d1b443f8527fca8afad14ef4419.tar.gz
go-tangerine-cfd7e74c25fa7d1b443f8527fca8afad14ef4419.tar.bz2
go-tangerine-cfd7e74c25fa7d1b443f8527fca8afad14ef4419.tar.lz
go-tangerine-cfd7e74c25fa7d1b443f8527fca8afad14ef4419.tar.xz
go-tangerine-cfd7e74c25fa7d1b443f8527fca8afad14ef4419.tar.zst
go-tangerine-cfd7e74c25fa7d1b443f8527fca8afad14ef4419.zip
p2p: add test for NewPeer
-rw-r--r--p2p/peer_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/p2p/peer_test.go b/p2p/peer_test.go
index 0994683a2..d9640292f 100644
--- a/p2p/peer_test.go
+++ b/p2p/peer_test.go
@@ -6,6 +6,7 @@ import (
"encoding/hex"
"io/ioutil"
"net"
+ "reflect"
"testing"
"time"
)
@@ -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)
+}