diff --git a/p2p/test_util.go b/p2p/test_util.go index 1d352eefd..2736d7f74 100644 --- a/p2p/test_util.go +++ b/p2p/test_util.go @@ -169,15 +169,15 @@ func MakeSwitch( logger := log.TestingLogger().With("switch", i) t := NewMConnTransport(logger, nodeInfo, nodeKey.PrivKey, MConnConfig(cfg)) - if err := t.Listen(addr.Endpoint()); err != nil { - panic(err) - } - // TODO: let the config be passed in? sw := initSwitch(i, NewSwitch(cfg, t, opts...)) sw.SetLogger(log.TestingLogger().With("switch", i)) sw.SetNodeKey(nodeKey) + if err := t.Listen(addr.Endpoint()); err != nil { + panic(err) + } + ni := nodeInfo ni.Channels = []byte{} for ch := range sw.reactorsByCh { diff --git a/p2p/transport_mconn.go b/p2p/transport_mconn.go index a55ca4403..7baabb2eb 100644 --- a/p2p/transport_mconn.go +++ b/p2p/transport_mconn.go @@ -129,6 +129,11 @@ func NewMConnTransport( } // SetChannelDescriptors implements Transport. +// +// This is not concurrency-safe, and must be called before listening. +// +// FIXME: This is here for compatibility with existing switch code, +// it should be passed via the constructor instead. func (m *MConnTransport) SetChannelDescriptors(chDescs []*conn.ChannelDescriptor) { m.channelDescs = chDescs }