|
|
@ -482,6 +482,8 @@ func MakeConnectedSwitches(n int, initSwitch func(int, *Switch) *Switch, connect |
|
|
|
return switches |
|
|
|
} |
|
|
|
|
|
|
|
var PanicOnAddPeerErr = false |
|
|
|
|
|
|
|
// Will connect switches i and j via net.Pipe()
|
|
|
|
// Blocks until a conection is established.
|
|
|
|
// NOTE: caller ensures i and j are within bounds
|
|
|
@ -492,14 +494,14 @@ func Connect2Switches(switches []*Switch, i, j int) { |
|
|
|
doneCh := make(chan struct{}) |
|
|
|
go func() { |
|
|
|
_, err := switchI.AddPeerWithConnection(c1, false) // AddPeer is blocking, requires handshake.
|
|
|
|
if err != nil { |
|
|
|
if PanicOnAddPeerErr && err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
doneCh <- struct{}{} |
|
|
|
}() |
|
|
|
go func() { |
|
|
|
_, err := switchJ.AddPeerWithConnection(c2, true) |
|
|
|
if err != nil { |
|
|
|
if PanicOnAddPeerErr && err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
doneCh <- struct{}{} |
|
|
|