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

Function TestInConnAPI

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

Source from the content-addressed store, hash-verified

149}
150
151func TestInConnAPI(t *testing.T) {
152 a := require.New(t)
153 si := NewNetServer()
154 server, ok := si.(*NetServer)
155 a.True(ok, "fail to cast P2PServer")
156
157 a.Equal(server.GetInConnRecordLen(), int(0), "fail to test GetInConnRecordLen")
158 server.AddInConnRecord("192.168.1.1:1024")
159 a.Equal(server.GetInConnRecordLen(), int(1), "fail to test AddInConnRecord")
160 server.AddInConnRecord("192.168.1.1:1024")
161 a.Equal(server.GetInConnRecordLen(), int(1), "fail to test GetInConnRecordLen")
162 server.AddInConnRecord("192.168.1.2:2048")
163 a.Equal(server.GetInConnRecordLen(), int(2), "fail to test AddInConnRecord")
164 server.RemoveFromInConnRecord("192.168.1.2:2048")
165 a.Equal(server.GetInConnRecordLen(), int(1), "fail to test RemoveFromInConnRecord")
166 // same IP, different port
167 server.AddInConnRecord("192.168.1.1:2048")
168 a.Equal(server.GetInConnRecordLen(), int(2), "fail to test RemoveFromInConnRecord")
169
170 a.Equal(server.GetIpCountInInConnRecord("192.168.1.1"), uint(2), "fail to test GetIpCountInInConnRecord")
171}
172
173func TestOutConnAPI(t *testing.T) {
174 a := require.New(t)

Callers

nothing calls this directly

Calls 5

NewNetServerFunction · 0.85
GetInConnRecordLenMethod · 0.80
AddInConnRecordMethod · 0.80

Tested by

no test coverage detected