bitbucket.org/number571/tendermint@v0.8.14/libs/net/net_test.go (about)

     1  package net
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestProtocolAndAddress(t *testing.T) {
    10  
    11  	cases := []struct {
    12  		fullAddr string
    13  		proto    string
    14  		addr     string
    15  	}{
    16  		{
    17  			"tcp://mydomain:80",
    18  			"tcp",
    19  			"mydomain:80",
    20  		},
    21  		{
    22  			"grpc://mydomain:80",
    23  			"grpc",
    24  			"mydomain:80",
    25  		},
    26  		{
    27  			"mydomain:80",
    28  			"tcp",
    29  			"mydomain:80",
    30  		},
    31  		{
    32  			"unix://mydomain:80",
    33  			"unix",
    34  			"mydomain:80",
    35  		},
    36  	}
    37  
    38  	for _, c := range cases {
    39  		proto, addr := ProtocolAndAddress(c.fullAddr)
    40  		assert.Equal(t, proto, c.proto)
    41  		assert.Equal(t, addr, c.addr)
    42  	}
    43  }