diff --git a/pkg/setup/node_test.go b/pkg/setup/node_test.go index f1ce282d0..12ff4d919 100644 --- a/pkg/setup/node_test.go +++ b/pkg/setup/node_test.go @@ -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) { @@ -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") +// } +// } diff --git a/pkg/transport/mock.go b/pkg/transport/mock.go index 57f3c62c0..9e1053eb6 100644 --- a/pkg/transport/mock.go +++ b/pkg/transport/mock.go @@ -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") @@ -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) @@ -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