mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
change MakeConnectedSwitches to not connect to itself
and a test for it
This commit is contained in:
parent
e785697a64
commit
7869e541f6
@ -509,8 +509,10 @@ func MakeConnectedSwitches(cfg *cfg.P2PConfig, n int, initSwitch func(int, *Swit
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 1; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
connect(switches, 0, i)
|
for j := i + 1; j < n; j++ {
|
||||||
|
connect(switches, i, j)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return switches
|
return switches
|
||||||
|
@ -286,6 +286,21 @@ func TestSwitchReconnectsToPersistentPeer(t *testing.T) {
|
|||||||
assert.False(peer.IsRunning())
|
assert.False(peer.IsRunning())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSwitchFullConnectivity(t *testing.T) {
|
||||||
|
switches := MakeConnectedSwitches(config, 3, initSwitchFunc, Connect2Switches)
|
||||||
|
defer func() {
|
||||||
|
for _, sw := range switches {
|
||||||
|
sw.Stop()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
for i, sw := range switches {
|
||||||
|
if sw.Peers().Size() != 2 {
|
||||||
|
t.Fatalf("Expected each switch to be connected to 2 other, but %d switch only connected to %d", sw.Peers().Size(), i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkSwitches(b *testing.B) {
|
func BenchmarkSwitches(b *testing.B) {
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user