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

Function TestConnectingNodeAPI

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

Source from the content-addressed store, hash-verified

122}
123
124func TestConnectingNodeAPI(t *testing.T) {
125 a := require.New(t)
126 server := NewNetServer()
127
128 a.Equal(server.GetOutConnectingListLen(), uint(0), "fail to test GetOutConnectingListLen")
129
130 addOK := server.AddOutConnectingList("192.168.1.1:28339")
131 a.Equal(server.GetOutConnectingListLen(), uint(1), "fail to test AddOutConnectingList")
132 a.Equal(addOK, true, "fail to test AddOutConnectingList")
133
134 // add same
135 addOK = server.AddOutConnectingList("192.168.1.1:28339")
136 a.Equal(server.GetOutConnectingListLen(), uint(1), "fail to test AddOutConnectingList")
137 a.Equal(addOK, false, "fail to test AddOutConnectingList")
138
139 // add new
140 server.AddOutConnectingList("192.168.2.2:2")
141 a.Equal(server.GetOutConnectingListLen(), uint(2), "fail to test AddOutConnectingList")
142
143 // test exist
144 a.Equal(server.IsAddrFromConnecting("192.168.2.2:2"), true, "fail to test IsAddrFromConnecting")
145 a.Equal(server.IsAddrFromConnecting("192.168.2.3:3"), false, "fail to test IsAddrFromConnecting")
146
147 server.RemoveFromConnectingList("192.168.2.2:2")
148 a.Equal(server.GetOutConnectingListLen(), uint(1), "fail to test RemoveFromConnectingList")
149}
150
151func TestInConnAPI(t *testing.T) {
152 a := require.New(t)

Callers

nothing calls this directly

Calls 5

AddOutConnectingListMethod · 0.95
IsAddrFromConnectingMethod · 0.95
NewNetServerFunction · 0.85

Tested by

no test coverage detected