diff --git a/internal/api/syncapi/cmdstreamutil.go b/internal/api/syncapi/cmdstreamutil.go index 6e98483e..feb4b5e0 100644 --- a/internal/api/syncapi/cmdstreamutil.go +++ b/internal/api/syncapi/cmdstreamutil.go @@ -136,13 +136,13 @@ func establishEncryption(stream syncCommandStreamTrait) (syncCommandStreamTrait, }, }, }); err != nil { - return nil, NewSyncErrorProtocol(fmt.Errorf("sending ECDH public key: %w", err)) + return nil, NewSyncErrorDisconnected(fmt.Errorf("sending ECDH public key: %w", err)) } // Receive the peer's ephemeral ECDH public key peerMsg, err := stream.Receive() if err != nil { - return nil, NewSyncErrorProtocol(fmt.Errorf("receiving ECDH public key: %w", err)) + return nil, NewSyncErrorDisconnected(fmt.Errorf("receiving ECDH public key: %w", err)) } peerSecret := peerMsg.GetEstablishSharedSecret() if peerSecret == nil { diff --git a/internal/api/syncapi/encryption_test.go b/internal/api/syncapi/encryption_test.go index 306caaab..15a6f57d 100644 --- a/internal/api/syncapi/encryption_test.go +++ b/internal/api/syncapi/encryption_test.go @@ -6,6 +6,7 @@ import ( "github.com/garethgeorge/backrest/gen/go/v1sync" "github.com/garethgeorge/backrest/internal/cryptoutil" + "github.com/garethgeorge/backrest/internal/testutil" ) // fakeStream is a pair of in-memory channels simulating a bidirectional transport. @@ -135,6 +136,7 @@ func TestEncryptedStream_BidirectionalMultiMessage(t *testing.T) { } func TestEstablishEncryption_Integration(t *testing.T) { + testutil.InstallZapLogger(t) transportA, transportB := newFakeStreamPair() var encA, encB syncCommandStreamTrait diff --git a/internal/api/syncapi/syncapi_test.go b/internal/api/syncapi/syncapi_test.go index 01ab300f..d0a4939e 100644 --- a/internal/api/syncapi/syncapi_test.go +++ b/internal/api/syncapi/syncapi_test.go @@ -74,7 +74,7 @@ var ( func TestConnectionSucceeds(t *testing.T) { testutil.InstallZapLogger(t) - ctx, _ := context.WithTimeout(context.Background(), 5*time.Second) + ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) peerHostAddr := testutil.AllocOpenBindAddr(t) peerClientAddr := testutil.AllocOpenBindAddr(t) @@ -121,7 +121,7 @@ func TestConnectionSucceeds(t *testing.T) { func TestConnectionBadKeyRejected(t *testing.T) { testutil.InstallZapLogger(t) - ctx, _ := context.WithTimeout(context.Background(), 5*time.Second) + ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) peerHostAddr := testutil.AllocOpenBindAddr(t) peerClientAddr := testutil.AllocOpenBindAddr(t) @@ -270,7 +270,7 @@ func TestSyncConfigChange(t *testing.T) { func TestSimpleOperationSync(t *testing.T) { testutil.InstallZapLogger(t) - ctx, _ := context.WithTimeout(context.Background(), 5*time.Second) + ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) peerHostAddr := testutil.AllocOpenBindAddr(t) peerClientAddr := testutil.AllocOpenBindAddr(t)