MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestETLSBug

Function TestETLSBug

rpc/mux/server_test.go:222–270  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

220}
221
222func TestETLSBug(t *testing.T) {
223 defer utils.RemoveAll(PubKeyStorePath + "*")
224 log.SetLevel(log.FatalLevel)
225 addr := "127.0.0.1:0"
226 masterKey := []byte("abc")
227 server, err := NewServerWithService(ServiceMap{"Test": NewTestService()})
228 if err != nil {
229 log.Fatal(err)
230 }
231
232 _, _ = route.NewDHTService(PubKeyStorePath, new(consistent.KMSStorage), true)
233 _ = server.InitRPCServer(addr, "../keys/test.key", masterKey)
234 go server.Serve()
235 defer server.Stop()
236
237 // This should not block listener
238 var rawConn net.Conn
239 rawConn, err = net.Dial("tcp", server.Listener.Addr().String())
240 if err != nil {
241 log.Fatal(err)
242 }
243 defer func() { _ = rawConn.Close() }()
244
245 publicKey, err := kms.GetLocalPublicKey()
246 nonce := asymmetric.GetPubKeyNonce(publicKey, 10, 100*time.Millisecond, nil)
247 serverNodeID := proto.NodeID(nonce.Hash.String())
248 _ = kms.SetPublicKey(serverNodeID, nonce.Nonce, publicKey)
249 kms.SetLocalNodeIDNonce(nonce.Hash.CloneBytes(), &nonce.Nonce)
250 _ = route.SetNodeAddrCache(&proto.RawNodeID{Hash: nonce.Hash}, server.Listener.Addr().String())
251
252 cryptoConn, err := rpc.Dial(serverNodeID)
253 if err != nil {
254 log.Fatal(err)
255 }
256 stream, err := NewOneOffMuxConn(cryptoConn)
257 if err != nil {
258 log.Fatal(err)
259 }
260 _ = stream.SetDeadline(time.Now().Add(3 * time.Second))
261 client := rpc.NewClient(stream)
262 defer func() { _ = client.Close() }()
263
264 repSimple := new(int32)
265 err = client.Call("Test.IncCounterSimpleArgs", 10, repSimple)
266 if err != nil {
267 log.Fatal(err)
268 }
269 CheckNum(*repSimple, 10, t)
270}
271
272func TestEncPingFindNeighbor(t *testing.T) {
273 utils.RemoveAll(PubKeyStorePath + "*")

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
CallMethod · 0.95
RemoveAllFunction · 0.92
SetLevelFunction · 0.92
FatalFunction · 0.92
NewDHTServiceFunction · 0.92
GetLocalPublicKeyFunction · 0.92
GetPubKeyNonceFunction · 0.92
NodeIDTypeAlias · 0.92
SetPublicKeyFunction · 0.92
SetLocalNodeIDNonceFunction · 0.92
SetNodeAddrCacheFunction · 0.92

Tested by

no test coverage detected