@cryptotaxi247 / kubo / commits / 7648a8b55

swarm tests: dont send to self

Juan Batiz-Benet committed Dec 16, 2014 at 14:45 UTC 7648a8b55c32f0998ef2bbba09e31b770e462e0b
1 file changed +7 -3
net/swarm2/swarm_test.go
+7 -3
@@ -127,7 +127,7 @@ func SubtestSwarm(t *testing.T, addrs []string, MsgNum int) {
127 wg.Wait()
128
129 for _, s := range swarms {
130 - log.Infof("%s swarm routing table: %s", s.local, s.GetPeerList())
130 + log.Infof("%s swarm routing table: %s", s.local, s.Peers())
131 }
132 }
133
@@ -174,6 +174,10 @@ func SubtestSwarm(t *testing.T, addrs []string, MsgNum int) {
174 }
175
176 for _, p := range *peers {
177 + if p == s1.local {
178 + continue // dont send to self...
179 + }
180 +
181 wg.Add(1)
182 go send(p)
183 }
@@ -184,7 +188,7 @@ func SubtestSwarm(t *testing.T, addrs []string, MsgNum int) {
188 go func() {
189 defer close(errChan)
190 count := 0
187 - countShouldBe := (MsgNum * len(*peers))
191 + countShouldBe := MsgNum * (len(*peers) - 1)
192 for stream := range streamChan { // one per peer
193 defer stream.Close()
194
@@ -228,7 +232,7 @@ func SubtestSwarm(t *testing.T, addrs []string, MsgNum int) {
232 }
233
234 log.Debugf("%s got pongs", s1.local)
231 - if len(*peers) != len(got) {
235 + if (len(*peers) - 1) != len(got) {
236 t.Error("got less messages than sent")
237 }
238