mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-13 05:11:21 +00:00
common: ProtocolAndAddress
This commit is contained in:
38
common/net_test.go
Normal file
38
common/net_test.go
Normal file
@ -0,0 +1,38 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestProtocolAndAddress(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
fullAddr string
|
||||
proto string
|
||||
addr string
|
||||
}{
|
||||
{
|
||||
"tcp://mydomain:80",
|
||||
"tcp",
|
||||
"mydomain:80",
|
||||
},
|
||||
{
|
||||
"mydomain:80",
|
||||
"tcp",
|
||||
"mydomain:80",
|
||||
},
|
||||
{
|
||||
"unix://mydomain:80",
|
||||
"unix",
|
||||
"mydomain:80",
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
proto, addr := ProtocolAndAddress(c.fullAddr)
|
||||
assert.Equal(t, proto, c.proto)
|
||||
assert.Equal(t, addr, c.addr)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user