Skip to content

Commit

Permalink
Merge pull request #546 from nkryuchkov/bug/fix-linter
Browse files Browse the repository at this point in the history
Fix linter errors after merging
  • Loading branch information
志宇 authored Sep 4, 2019
2 parents c41d06a + 9c9600a commit 30daea1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 35 deletions.
53 changes: 23 additions & 30 deletions pkg/setup/node_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package setup

import (
"errors"
"log"
"os"
"testing"
"time"

"github.com/skycoin/dmsg"
"github.com/skycoin/dmsg/cipher"
"github.com/skycoin/dmsg/disc"
"github.com/skycoin/skycoin/src/util/logging"
"github.com/stretchr/testify/require"
"golang.org/x/net/nettest"
)

func TestMain(m *testing.M) {
Expand Down Expand Up @@ -342,26 +335,26 @@ func TestMain(m *testing.M) {
})
}*/

func createServer(t *testing.T, dc disc.APIClient) (srv *dmsg.Server, srvErr <-chan error) {
pk, sk, err := cipher.GenerateDeterministicKeyPair([]byte("s"))
require.NoError(t, err)
l, err := nettest.NewLocalListener("tcp")
require.NoError(t, err)
srv, err = dmsg.NewServer(pk, sk, "", l, dc)
require.NoError(t, err)
errCh := make(chan error, 1)
go func() {
errCh <- srv.Serve()
close(errCh)
}()
return srv, errCh
}

func errWithTimeout(ch <-chan error) error {
select {
case err := <-ch:
return err
case <-time.After(5 * time.Second):
return errors.New("timeout")
}
}
// func createServer(t *testing.T, dc disc.APIClient) (srv *dmsg.Server, srvErr <-chan error) {
// pk, sk, err := cipher.GenerateDeterministicKeyPair([]byte("s"))
// require.NoError(t, err)
// l, err := nettest.NewLocalListener("tcp")
// require.NoError(t, err)
// srv, err = dmsg.NewServer(pk, sk, "", l, dc)
// require.NoError(t, err)
// errCh := make(chan error, 1)
// go func() {
// errCh <- srv.Serve()
// close(errCh)
// }()
// return srv, errCh
// }
//
// func errWithTimeout(ch <-chan error) error {
// select {
// case err := <-ch:
// return err
// case <-time.After(5 * time.Second):
// return errors.New("timeout")
// }
// }
12 changes: 7 additions & 5 deletions pkg/transport/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ func MockTransportManagersPair() (pk1, pk2 cipher.PubKey, m1, m2 *Manager, errCh

dmsgD := disc.NewMock()

if err = dmsgD.SetEntry(context.TODO(), disc.NewClientEntry(pk1, 0, []cipher.PubKey{})); err != nil {
return
if err := dmsgD.SetEntry(context.TODO(), disc.NewClientEntry(pk1, 0, []cipher.PubKey{})); err != nil {
return cipher.PubKey{}, cipher.PubKey{}, nil, nil, nil, err
}

// l, err := nettest.NewLocalListener("tcp")
Expand All @@ -199,6 +199,7 @@ func MockTransportManagersPair() (pk1, pk2 cipher.PubKey, m1, m2 *Manager, errCh
// return
// }
//
// errCh := make(chan error, 1)
// go func() {
// errCh <- srv.Serve()
// close(errCh)
Expand All @@ -211,16 +212,17 @@ func MockTransportManagersPair() (pk1, pk2 cipher.PubKey, m1, m2 *Manager, errCh
net2 := snet.NewRaw(nc2, dmsgC2)

if m1, err = NewManager(net1, mc1); err != nil {
return
return cipher.PubKey{}, cipher.PubKey{}, nil, nil, nil, err
}
if m2, err = NewManager(net2, mc2); err != nil {
return
return cipher.PubKey{}, cipher.PubKey{}, nil, nil, nil, err
}

go m1.Serve(context.TODO())
go m2.Serve(context.TODO())

return
// return pk1, pk2, m1,m2, errCh, err
return pk1, pk2, m1, m2, nil, err
}

// MockTransportManager creates Manager
Expand Down

0 comments on commit 30daea1

Please sign in to comment.