Merge pull request #812 from tendermint/808-make-connected-switches

MakeConnectedSwitches: connect first switch to others
This commit is contained in:
Ethan Buchman 2017-11-08 00:54:23 +00:00 committed by GitHub
commit 9f6a09277e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -499,7 +499,7 @@ func MakeConnectedSwitches(cfg *cfg.P2PConfig, n int, initSwitch func(int, *Swit
}
for i := 0; i < n; i++ {
for j := i; j < n; j++ {
for j := i + 1; j < n; j++ {
connect(switches, i, j)
}
}

View File

@ -268,6 +268,21 @@ func TestSwitchReconnectsToPersistentPeer(t *testing.T) {
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) {
b.StopTimer()