MCPcopy Create free account
hub / github.com/DNAProject/DNA / TestOutConnAPI

Function TestOutConnAPI

p2pserver/net/netserver/netserver_test.go:173–190  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

171}
172
173func TestOutConnAPI(t *testing.T) {
174 a := require.New(t)
175 si := NewNetServer()
176 server, ok := si.(*NetServer)
177 a.True(ok, "fail to case P2PServer")
178
179 a.Equal(server.GetOutConnRecordLen(), int(0), "fail to test GetOutConnRecordLen")
180 server.AddOutConnRecord("192.168.1.1:200")
181 a.Equal(server.GetOutConnRecordLen(), int(1), "fail to test AddOutConnRecord")
182 server.AddOutConnRecord("192.168.1.1:200")
183 a.Equal(server.GetOutConnRecordLen(), int(1), "fail to test AddOutConnRecord")
184 server.AddOutConnRecord("192.168.1.1:300")
185 a.Equal(server.GetOutConnRecordLen(), int(2), "fail to test AddOutConnRecord")
186 server.RemoveFromOutConnRecord("192.168.1.1:300")
187 a.Equal(server.GetOutConnRecordLen(), int(1), "fail to test RemoveFromOutConnRecord")
188 a.Equal(server.IsAddrInOutConnRecord("192.168.1.1:300"), false, "fail to test IsAddrInOutConnRecord")
189 a.Equal(server.IsAddrInOutConnRecord("192.168.1.1:200"), true, "fail to test IsAddrInOutConnRecord")
190}

Callers

nothing calls this directly

Calls 5

NewNetServerFunction · 0.85
AddOutConnRecordMethod · 0.80
IsAddrInOutConnRecordMethod · 0.80
GetOutConnRecordLenMethod · 0.65

Tested by

no test coverage detected