agentlistener tested.

This commit is contained in:
Erik Brakkee 2024-08-22 00:04:49 +02:00
parent 80488fa7c8
commit 0bc3548354

View File

@ -0,0 +1,28 @@
package comms
import "git.wamblee.org/converge/pkg/testsupport"
func (s *AgentServerTestSuite) Test_clientIdPassedAsLocalAddr() {
agentChannel, serverChannel := s.createCommChannel()
clientId := "myid"
testsupport.RunAndWait(
&s.Suite,
func() any {
listener := NewAgentListener(agentChannel.Session)
connection, err := listener.Accept()
s.Nil(err)
// clientId identifyable as remote addr
s.Equal(clientId, connection.LocalAddr().String())
return nil
},
func() any {
connection, err := serverChannel.Session.OpenStream()
s.Nil(err)
gobChannel := NewGOBChannel(connection)
clientInfo := ClientInfo{ClientId: clientId}
err = SendWithTimeout(gobChannel, clientInfo)
s.Nil(err)
return nil
})
}