WIP: Morph: Add unit tests #2

Closed
dstepanov-yadro wants to merge 233 commits from TrueCloudLab/frostfs-node:master into object-3608-morph-unit-tests
5 changed files with 6 additions and 8 deletions
Showing only changes of commit 4f413fe86e - Show all commits

View file

@ -47,7 +47,7 @@ func (a Address) URIAddr() string {
panic(fmt.Errorf("could not get host addr: %w", err)) panic(fmt.Errorf("could not get host addr: %w", err))
} }
if !a.isTLSEnabled() { if !a.IsTLSEnabled() {
return host return host
} }

View file

@ -57,7 +57,7 @@ func (x AddressGroup) Len() int {
// Less returns true if i-th address in AddressGroup supports TLS // Less returns true if i-th address in AddressGroup supports TLS
// and j-th one doesn't. // and j-th one doesn't.
func (x AddressGroup) Less(i, j int) bool { func (x AddressGroup) Less(i, j int) bool {
return x[i].isTLSEnabled() && !x[j].isTLSEnabled() return x[i].IsTLSEnabled() && !x[j].IsTLSEnabled()
} }
// Swap swaps i-th and j-th addresses in AddressGroup. // Swap swaps i-th and j-th addresses in AddressGroup.

View file

@ -11,8 +11,8 @@ const (
// tls var is used for (un)wrapping other multiaddrs around TLS multiaddr. // tls var is used for (un)wrapping other multiaddrs around TLS multiaddr.
var tls, _ = multiaddr.NewMultiaddr("/" + tlsProtocolName) var tls, _ = multiaddr.NewMultiaddr("/" + tlsProtocolName)
// isTLSEnabled searches for wrapped TLS protocol in multiaddr. // IsTLSEnabled searches for wrapped TLS protocol in multiaddr.
func (a Address) isTLSEnabled() bool { func (a Address) IsTLSEnabled() bool {
for _, protoc := range a.ma.Protocols() { for _, protoc := range a.ma.Protocols() {
if protoc.Code == multiaddr.P_TLS { if protoc.Code == multiaddr.P_TLS {
return true return true

View file

@ -24,6 +24,6 @@ func TestAddress_TLSEnabled(t *testing.T) {
err := addr.FromString(test.input) err := addr.FromString(test.input)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, test.wantTLS, addr.isTLSEnabled(), test.input) require.Equal(t, test.wantTLS, addr.IsTLSEnabled(), test.input)
} }
} }

View file

@ -4,7 +4,6 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"strings"
"sync" "sync"
"time" "time"
@ -100,8 +99,7 @@ func dialTreeService(ctx context.Context, netmapAddr string) (*grpc.ClientConn,
), ),
} }
// FIXME(@fyrchik): ugly hack #1322 if netAddr.IsTLSEnabled() {
if !strings.HasPrefix(netAddr.URIAddr(), "grpcs:") {
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials())) opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
} }