@cryptotaxi247 / kubo / commits / 87567645f

p2p: test for double-registering listeners

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Sep 3, 2018 at 18:29 UTC 87567645f4c39e7d36ebbb604839279eaf948048
2 files changed +6 -3
p2p/listener.go
-2
@@ -26,7 +26,6 @@ type Listener interface {
26 type listenerKey struct {
27 proto string
28 listen string
29 - target string
29 }
30
31 // ListenerRegistry is a collection of local application proto listeners.
@@ -119,6 +118,5 @@ func getListenerKey(l Listener) listenerKey {
118 return listenerKey{
119 proto: string(l.Protocol()),
120 listen: l.ListenAddress().String(),
122 - target: l.TargetAddress().String(),
121 }
122 }
test/sharness/t0180-p2p.sh
+6 -1
@@ -23,7 +23,8 @@ test_expect_success 'peer ids' '
23 check_test_ports() {
24 test_expect_success "test ports are closed" '
25 (! (netstat -lnp | grep "LISTEN" | grep ":10101 ")) &&
26 - (! (netstat -lnp | grep "LISTEN" | grep ":10102 "))
26 + (! (netstat -lnp | grep "LISTEN" | grep ":10102 "))&&
27 + (! (netstat -lnp | grep "LISTEN" | grep ":10103 "))
28 '
29 }
30 check_test_ports
@@ -41,6 +42,10 @@ test_expect_success 'start p2p listener' '
42 ipfsi 0 p2p listen /x/p2p-test /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log
43 '
44
45 +test_expect_success 'cannot re-register p2p listener' '
46 + test_must_fail ipfsi 0 p2p listen /x/p2p-test /ip4/127.0.0.1/tcp/10103 2>&1 > listener-stdouterr.log
47 +'
48 +
49 # Server to client communications
50
51 spawn_sending_server() {