@@ -78,8 +78,6 @@ func TestHostGetPrompt(t *testing.T) {
7878}
7979
8080func TestHostNameCollision (t * testing.T ) {
81- t .Skip ("Test is flakey on CI. :(" )
82-
8381 key , err := sshd .NewRandomSigner (512 )
8482 if err != nil {
8583 t .Fatal (err )
@@ -93,9 +91,13 @@ func TestHostNameCollision(t *testing.T) {
9391 }
9492 defer s .Close ()
9593 host := NewHost (s , nil )
94+
95+ newUsers := make (chan * message.User )
96+ host .OnUserJoined = func (u * message.User ) {
97+ newUsers <- u
98+ }
9699 go host .Serve ()
97100
98- ready := make (chan struct {})
99101 g := errgroup.Group {}
100102
101103 // First client
@@ -111,8 +113,8 @@ func TestHostNameCollision(t *testing.T) {
111113 t .Errorf ("Got %q; expected %q" , actual , expected )
112114 }
113115
114- // Ready for second client
115- ready <- struct {}{}
116+ // wait for the second client
117+ <- newUsers
116118
117119 scanner .Scan ()
118120 actual = scanner .Text ()
@@ -127,20 +129,16 @@ func TestHostNameCollision(t *testing.T) {
127129 t .Errorf ("Got %q; expected %q" , actual , expected )
128130 }
129131
130- // Wrap it up.
131- close (ready )
132132 return nil
133133 })
134134 })
135135
136- // Wait for first client
137- <- ready
138-
139136 // Second client
140137 g .Go (func () error {
138+ // wait for the first client
139+ <- newUsers
141140 return sshd .ConnectShell (s .Addr ().String (), "foo" , func (r io.Reader , w io.WriteCloser ) error {
142141 scanner := bufio .NewScanner (r )
143-
144142 // Consume the initial buffer
145143 scanner .Scan ()
146144 scanner .Scan ()
0 commit comments