39 lines
1.5 KiB
Go
39 lines
1.5 KiB
Go
|
|
package notify
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"net"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func newStartedClientConnForTest(t *testing.T, id string, server Server, conn net.Conn, stopCtx context.Context, stopFn context.CancelFunc) (*ClientConn, context.Context, context.CancelFunc) {
|
||
|
|
t.Helper()
|
||
|
|
client := &ClientConn{
|
||
|
|
ClientID: id,
|
||
|
|
server: server,
|
||
|
|
}
|
||
|
|
stopCtx, stopFn = client.startClientConnSession(conn, stopCtx, stopFn)
|
||
|
|
return client, stopCtx, stopFn
|
||
|
|
}
|
||
|
|
|
||
|
|
func newRegisteredServerClientForTest(t *testing.T, server *ServerCommon, id string, conn net.Conn, stopCtx context.Context, stopFn context.CancelFunc) (*ClientConn, context.Context, context.CancelFunc) {
|
||
|
|
t.Helper()
|
||
|
|
client, stopCtx, stopFn := newStartedClientConnForTest(t, id, server, conn, stopCtx, stopFn)
|
||
|
|
server.getPeerRegistry().registerClient(client)
|
||
|
|
return client, stopCtx, stopFn
|
||
|
|
}
|
||
|
|
|
||
|
|
func newRegisteredServerLogicalForTest(t *testing.T, server *ServerCommon, id string, conn net.Conn, stopCtx context.Context, stopFn context.CancelFunc) (*LogicalConn, context.Context, context.CancelFunc) {
|
||
|
|
t.Helper()
|
||
|
|
client, stopCtx, stopFn := newStartedClientConnForTest(t, id, server, conn, stopCtx, stopFn)
|
||
|
|
logical := logicalConnFromClient(client)
|
||
|
|
server.getPeerRegistry().registerLogical(logical)
|
||
|
|
return logical, stopCtx, stopFn
|
||
|
|
}
|
||
|
|
|
||
|
|
func newServerCodecClientConnForTest(server *ServerCommon) *ClientConn {
|
||
|
|
client := &ClientConn{server: server}
|
||
|
|
client.applyClientConnAttachmentProfile(0, 0, server.defaultMsgEn, server.defaultMsgDe, server.handshakeRsaKey, server.SecretKey)
|
||
|
|
return client
|
||
|
|
}
|