MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / initSwitchFunc

Function initSwitchFunc

p2p/switch_test.go:116–133  ·  view source on GitHub ↗
(i int, sw *Switch)

Source from the content-addressed store, hash-verified

114}
115
116func initSwitchFunc(i int, sw *Switch) *Switch {
117 sw.SetAddrBook(&AddrBookMock{
118 Addrs: make(map[string]struct{}),
119 OurAddrs: make(map[string]struct{}),
120 })
121
122 // Make two reactors of two channels each
123 sw.AddReactor("foo", NewTestReactor([]*conn.ChannelDescriptor{
124 {ID: byte(0x00), Priority: 10, MessageType: &p2pproto.Message{}},
125 {ID: byte(0x01), Priority: 10, MessageType: &p2pproto.Message{}},
126 }, true))
127 sw.AddReactor("bar", NewTestReactor([]*conn.ChannelDescriptor{
128 {ID: byte(0x02), Priority: 10, MessageType: &p2pproto.Message{}},
129 {ID: byte(0x03), Priority: 10, MessageType: &p2pproto.Message{}},
130 }, true))
131
132 return sw
133}
134
135func TestSwitches(t *testing.T) {
136 s1, s2 := MakeSwitchPair(t, initSwitchFunc)

Callers 2

TestSwitchRemovalErrFunction · 0.85

Calls 3

NewTestReactorFunction · 0.85
SetAddrBookMethod · 0.80
AddReactorMethod · 0.80

Tested by

no test coverage detected