Skip to content

Commit

Permalink
Make dmsg lowercase where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Jan 16, 2020
1 parent ea49f0e commit b382e91
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion pkg/app/appnet/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func ConvertAddr(addr net.Addr) (Addr, error) {
switch a := addr.(type) {
case dmsg.Addr:
return Addr{
Net: TypeDMSG,
Net: TypeDmsg,
PubKey: a.PK,
Port: routing.Port(a.Port),
}, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/appnet/addr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestConvertAddr(t *testing.T) {
},
want: want{
addr: Addr{
Net: TypeDMSG,
Net: TypeDmsg,
PubKey: pk,
Port: routing.Port(port),
},
Expand Down
14 changes: 7 additions & 7 deletions pkg/app/appnet/dmsg_networker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ import (
"github.com/SkycoinProject/dmsg"
)

// DMSGNetworker implements `Networker` for dmsg network.
type DMSGNetworker struct {
// DmsgNetworker implements `Networker` for dmsg network.
type DmsgNetworker struct {
dmsgC *dmsg.Client
}

// NewDMSGNetworker constructs new `DMSGNetworker`.
func NewDMSGNetworker(dmsgC *dmsg.Client) Networker {
return &DMSGNetworker{
return &DmsgNetworker{
dmsgC: dmsgC,
}
}

// Dial dials remote `addr` via dmsg network.
func (n *DMSGNetworker) Dial(addr Addr) (net.Conn, error) {
func (n *DmsgNetworker) Dial(addr Addr) (net.Conn, error) {
return n.DialContext(context.Background(), addr)
}

// DialContext dials remote `addr` via dmsg network with context.
func (n *DMSGNetworker) DialContext(ctx context.Context, addr Addr) (net.Conn, error) {
func (n *DmsgNetworker) DialContext(ctx context.Context, addr Addr) (net.Conn, error) {
remote := dmsg.Addr{
PK: addr.PubKey,
Port: uint16(addr.Port),
Expand All @@ -34,11 +34,11 @@ func (n *DMSGNetworker) DialContext(ctx context.Context, addr Addr) (net.Conn, e
}

// Listen starts listening on local `addr` in the dmsg network.
func (n *DMSGNetworker) Listen(addr Addr) (net.Listener, error) {
func (n *DmsgNetworker) Listen(addr Addr) (net.Listener, error) {
return n.ListenContext(context.Background(), addr)
}

// ListenContext starts listening on local `addr` in the dmsg network with context.
func (n *DMSGNetworker) ListenContext(ctx context.Context, addr Addr) (net.Listener, error) {
func (n *DmsgNetworker) ListenContext(ctx context.Context, addr Addr) (net.Listener, error) {
return n.dmsgC.Listen(uint16(addr.Port))
}
6 changes: 3 additions & 3 deletions pkg/app/appnet/networker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func TestAddNetworker(t *testing.T) {
ClearNetworkers()

nType := TypeDMSG
nType := TypeDmsg

var n Networker

Expand All @@ -28,7 +28,7 @@ func TestAddNetworker(t *testing.T) {
func TestResolveNetworker(t *testing.T) {
ClearNetworkers()

nType := TypeDMSG
nType := TypeDmsg

var n Networker

Expand Down Expand Up @@ -110,7 +110,7 @@ func prepAddr() Addr {
addrPort := routing.Port(100)

return Addr{
Net: TypeDMSG,
Net: TypeDmsg,
PubKey: addrPK,
Port: addrPort,
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/app/appnet/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package appnet
type Type string

const (
// TypeDMSG is a network type for DMSG communication.
TypeDMSG Type = "dmsg"
// TypeDmsg is a network type for dmsg communication.
TypeDmsg Type = "dmsg"
// TypeSkynet is a network type for skywire communication.
TypeSkynet Type = "skynet"
)
Expand All @@ -18,7 +18,7 @@ func (n Type) IsValid() bool {

var (
validNetworks = map[Type]struct{}{
TypeDMSG: {},
TypeDmsg: {},
TypeSkynet: {},
}
)
2 changes: 1 addition & 1 deletion pkg/app/appnet/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestType_IsValid(t *testing.T) {
}{
{
name: "valid",
t: TypeDMSG,
t: TypeDmsg,
want: true,
},
{
Expand Down
6 changes: 3 additions & 3 deletions pkg/app/appserver/rpc_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

func TestRPCGateway_Dial(t *testing.T) {
l := logging.MustGetLogger("rpc_gateway")
nType := appnet.TypeDMSG
nType := appnet.TypeDmsg

dialAddr := prepAddr(nType)

Expand Down Expand Up @@ -142,7 +142,7 @@ func testRPCGatewayDialErrorWrappingConn(t *testing.T, l *logging.Logger, nType

func TestRPCGateway_Listen(t *testing.T) {
l := logging.MustGetLogger("rpc_gateway")
nType := appnet.TypeDMSG
nType := appnet.TypeDmsg

listenAddr := prepAddr(nType)

Expand Down Expand Up @@ -268,7 +268,7 @@ func testRPCGatewayAcceptOK(t *testing.T, l *logging.Logger) {
var resp AcceptResp
err := rpc.Accept(&lisID, &resp)
require.NoError(t, err)
require.Equal(t, resp.Remote, appnet.Addr{Net: appnet.TypeDMSG})
require.Equal(t, resp.Remote, appnet.Addr{Net: appnet.TypeDmsg})
}

func testRPCGatewayAcceptNoSuchListener(t *testing.T, l *logging.Logger) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/appserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestServer_ListenAndServe(t *testing.T) {

n.On("DialContext", mock.Anything, remote).Return(conn, noErr)

err = appnet.AddNetworker(appnet.TypeDMSG, n)
err = appnet.AddNetworker(appnet.TypeDmsg, n)
require.NoError(t, err)

cl, err := app.NewClient(logging.MustGetLogger("app_client"), clientConfig)
Expand Down Expand Up @@ -95,7 +95,7 @@ func prepAddrs() (dmsgLocal, dmsgRemote dmsg.Addr, remote appnet.Addr) {
Port: remotePort,
}
remote = appnet.Addr{
Net: appnet.TypeDMSG,
Net: appnet.TypeDmsg,
PubKey: remotePK,
Port: routing.Port(remotePort),
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/app/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestClient_Dial(t *testing.T) {
remotePK, _ := cipher.GenerateKeyPair()
remotePort := routing.Port(120)
remote := appnet.Addr{
Net: appnet.TypeDMSG,
Net: appnet.TypeDmsg,
PubKey: remotePK,
Port: remotePort,
}
Expand Down Expand Up @@ -215,7 +215,7 @@ func TestClient_Listen(t *testing.T) {

port := routing.Port(1)
local := appnet.Addr{
Net: appnet.TypeDMSG,
Net: appnet.TypeDmsg,
PubKey: visorPK,
Port: port,
}
Expand All @@ -235,7 +235,7 @@ func TestClient_Listen(t *testing.T) {
addr: local,
}

listener, err := cl.Listen(appnet.TypeDMSG, port)
listener, err := cl.Listen(appnet.TypeDmsg, port)
require.Nil(t, err)

appListener, ok := listener.(*Listener)
Expand All @@ -262,7 +262,7 @@ func TestClient_Listen(t *testing.T) {
_, err := cl.lm.Add(listenLisID, nil)
require.NoError(t, err)

listener, err := cl.Listen(appnet.TypeDMSG, port)
listener, err := cl.Listen(appnet.TypeDmsg, port)
require.Equal(t, err, idmanager.ErrValueAlreadyExists)
require.Nil(t, listener)
})
Expand All @@ -282,7 +282,7 @@ func TestClient_Listen(t *testing.T) {
_, err := cl.lm.Add(listenLisID, nil)
require.NoError(t, err)

listener, err := cl.Listen(appnet.TypeDMSG, port)
listener, err := cl.Listen(appnet.TypeDmsg, port)
require.Equal(t, err, idmanager.ErrValueAlreadyExists)
require.Nil(t, listener)
})
Expand All @@ -295,7 +295,7 @@ func TestClient_Listen(t *testing.T) {

cl := prepClient(l, visorPK, rpc)

listener, err := cl.Listen(appnet.TypeDMSG, port)
listener, err := cl.Listen(appnet.TypeDmsg, port)
require.Equal(t, listenErr, err)
require.Nil(t, listener)
})
Expand Down
10 changes: 5 additions & 5 deletions pkg/app/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestListener_Accept(t *testing.T) {
lisID := uint16(1)
visorPK, _ := cipher.GenerateKeyPair()
local := appnet.Addr{
Net: appnet.TypeDMSG,
Net: appnet.TypeDmsg,
PubKey: visorPK,
Port: routing.Port(100),
}
Expand All @@ -28,7 +28,7 @@ func TestListener_Accept(t *testing.T) {
acceptConnID := uint16(1)
acceptRemotePK, _ := cipher.GenerateKeyPair()
acceptRemote := appnet.Addr{
Net: appnet.TypeDMSG,
Net: appnet.TypeDmsg,
PubKey: acceptRemotePK,
Port: routing.Port(100),
}
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestListener_Accept(t *testing.T) {
acceptConnID := uint16(1)
acceptRemotePK, _ := cipher.GenerateKeyPair()
acceptRemote := appnet.Addr{
Net: appnet.TypeDMSG,
Net: appnet.TypeDmsg,
PubKey: acceptRemotePK,
Port: routing.Port(100),
}
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestListener_Accept(t *testing.T) {
acceptConnID := uint16(1)
acceptRemotePK, _ := cipher.GenerateKeyPair()
acceptRemote := appnet.Addr{
Net: appnet.TypeDMSG,
Net: appnet.TypeDmsg,
PubKey: acceptRemotePK,
Port: routing.Port(100),
}
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestListener_Close(t *testing.T) {
lisID := uint16(1)
localPK, _ := cipher.GenerateKeyPair()
local := appnet.Addr{
Net: appnet.TypeDMSG,
Net: appnet.TypeDmsg,
PubKey: localPK,
Port: routing.Port(100),
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/app/rpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestRPCClient_Dial(t *testing.T) {
n.On("DialContext", dialCtx, remote).Return(dialConn, testhelpers.NoErr)

appnet.ClearNetworkers()
err := appnet.AddNetworker(appnet.TypeDMSG, n)
err := appnet.AddNetworker(appnet.TypeDmsg, n)
require.NoError(t, err)

connID, localPort, err := cl.Dial(remote)
Expand All @@ -72,7 +72,7 @@ func TestRPCClient_Dial(t *testing.T) {
n.On("DialContext", dialCtx, remote).Return(dialConn, dialErr)

appnet.ClearNetworkers()
err := appnet.AddNetworker(appnet.TypeDMSG, n)
err := appnet.AddNetworker(appnet.TypeDmsg, n)
require.NoError(t, err)

connID, localPort, err := cl.Dial(remote)
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestRPCClient_Listen(t *testing.T) {
n.On("ListenContext", listenCtx, local).Return(listenLis, noErr)

appnet.ClearNetworkers()
err := appnet.AddNetworker(appnet.TypeDMSG, n)
err := appnet.AddNetworker(appnet.TypeDmsg, n)
require.NoError(t, err)

lisID, err := cl.Listen(local)
Expand All @@ -128,7 +128,7 @@ func TestRPCClient_Listen(t *testing.T) {
n.On("ListenContext", listenCtx, local).Return(listenLis, listenErr)

appnet.ClearNetworkers()
err := appnet.AddNetworker(appnet.TypeDMSG, n)
err := appnet.AddNetworker(appnet.TypeDmsg, n)
require.NoError(t, err)

lisID, err := cl.Listen(local)
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestRPCClient_Accept(t *testing.T) {
cl := prepRPCClient(t, rpcL.Addr().Network(), rpcL.Addr().String())

wantRemote := appnet.Addr{
Net: appnet.TypeDMSG,
Net: appnet.TypeDmsg,
PubKey: dmsgRemote.PK,
Port: routing.Port(dmsgRemote.Port),
}
Expand Down Expand Up @@ -667,7 +667,7 @@ func prepNetworkerWithListener(t *testing.T, lis *appcommon.MockListener, local
n := &appnet.MockNetworker{}
n.On("ListenContext", mock.Anything, local).Return(lis, noErr)

err := appnet.AddNetworker(appnet.TypeDMSG, n)
err := appnet.AddNetworker(appnet.TypeDmsg, n)
require.NoError(t, err)
}

Expand All @@ -678,7 +678,7 @@ func prepNetworkerWithConn(t *testing.T, conn *appcommon.MockConn, remote appnet
networker.On("DialContext", mock.Anything, remote).Return(conn, noErr)

appnet.ClearNetworkers()
err := appnet.AddNetworker(appnet.TypeDMSG, networker)
err := appnet.AddNetworker(appnet.TypeDmsg, networker)
require.NoError(t, err)
}

Expand Down Expand Up @@ -720,7 +720,7 @@ func prepAddrs() (dmsgLocal, dmsgRemote dmsg.Addr, local, remote appnet.Addr) {
Port: localPort,
}
local = appnet.Addr{
Net: appnet.TypeDMSG,
Net: appnet.TypeDmsg,
PubKey: localPK,
Port: routing.Port(localPort),
}
Expand All @@ -732,7 +732,7 @@ func prepAddrs() (dmsgLocal, dmsgRemote dmsg.Addr, local, remote appnet.Addr) {
Port: remotePort,
}
remote = appnet.Addr{
Net: appnet.TypeDMSG,
Net: appnet.TypeDmsg,
PubKey: remotePK,
Port: routing.Port(remotePort),
}
Expand Down

0 comments on commit b382e91

Please sign in to comment.