ssh: fix call to Fatalf from a non-test goroutine

Also fix some redundant type declarations.

Change-Id: Iad2950b67b1ec2e2590c59393b8ad15421ed3add
GitHub-Last-Rev: 41cf552f11387208491dee7b867050475043b25e
GitHub-Pull-Request: golang/crypto#263
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/505798
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
This commit is contained in:
Nicola Murino
2023-07-31 18:14:41 +00:00
committed by Gopher Robot
parent eab9315960
commit edc325d13a
8 changed files with 141 additions and 74 deletions
+16 -3
View File
@@ -36,7 +36,8 @@ func dial(handler serverType, t *testing.T) *Client {
conn, chans, reqs, err := NewServerConn(c1, &conf)
if err != nil {
t.Fatalf("Unable to handshake: %v", err)
t.Errorf("Unable to handshake: %v", err)
return
}
go DiscardRequests(reqs)
@@ -647,10 +648,12 @@ func TestSessionID(t *testing.T) {
User: "user",
}
srvErrCh := make(chan error, 1)
go func() {
conn, chans, reqs, err := NewServerConn(c1, serverConf)
srvErrCh <- err
if err != nil {
t.Fatalf("server handshake: %v", err)
return
}
serverID <- conn.SessionID()
go DiscardRequests(reqs)
@@ -659,10 +662,12 @@ func TestSessionID(t *testing.T) {
}
}()
cliErrCh := make(chan error, 1)
go func() {
conn, chans, reqs, err := NewClientConn(c2, "", clientConf)
cliErrCh <- err
if err != nil {
t.Fatalf("client handshake: %v", err)
return
}
clientID <- conn.SessionID()
go DiscardRequests(reqs)
@@ -671,6 +676,14 @@ func TestSessionID(t *testing.T) {
}
}()
if err := <-srvErrCh; err != nil {
t.Fatalf("server handshake: %v", err)
}
if err := <-cliErrCh; err != nil {
t.Fatalf("client handshake: %v", err)
}
s := <-serverID
c := <-clientID
if bytes.Compare(s, c) != 0 {