From 43bae55376d90eaa053ccaa51ef83f35a9b7c357 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Mon, 15 Jul 2019 10:21:34 +0300 Subject: [PATCH] Fix integration tests data races and panics --- pkg/app/app.go | 4 ++-- pkg/app/app_test.go | 3 +-- pkg/node/config_test.go | 3 +-- pkg/node/node.go | 3 +-- pkg/node/node_test.go | 3 +-- pkg/router/port_list.go | 3 +-- pkg/routing/rule_test.go | 1 - 7 files changed, 7 insertions(+), 13 deletions(-) diff --git a/pkg/app/app.go b/pkg/app/app.go index c3d2fdb5b9..495f4745b1 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -120,7 +120,7 @@ func (app *App) Accept() (net.Conn, error) { laddr := addrs[0] raddr := addrs[1] - loop := routing.Loop{Local: *laddr, Remote: *raddr} + loop := routing.Loop{Local: routing.Addr{Port: laddr.Port}, Remote: *raddr} conn, out := net.Pipe() app.mu.Lock() app.conns[loop] = conn @@ -136,7 +136,7 @@ func (app *App) Dial(raddr *routing.Addr) (net.Conn, error) { if err != nil { return nil, err } - loop := routing.Loop{Local: laddr, Remote: *raddr} + loop := routing.Loop{Local: routing.Addr{Port: laddr.Port}, Remote: *raddr} conn, out := net.Pipe() app.mu.Lock() app.conns[loop] = conn diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index f1a1a24676..6d6d085d19 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -61,7 +61,7 @@ func TestAppDial(t *testing.T) { assert.Equal(t, rpk.Hex()+":3", conn.RemoteAddr().String()) assert.Equal(t, lpk.Hex()+":2", conn.LocalAddr().String()) - require.NotNil(t, app.conns[routing.Loop{Local: routing.Addr{PubKey: lpk, Port: 2}, Remote: routing.Addr{PubKey: rpk, Port: 3}}]) + require.NotNil(t, app.conns[routing.Loop{Local: routing.Addr{Port: 2}, Remote: routing.Addr{PubKey: rpk, Port: 3}}]) require.NoError(t, conn.Close()) // Justified. Attempt to remove produces: FAIL @@ -69,7 +69,6 @@ func TestAppDial(t *testing.T) { var loop routing.Loop require.NoError(t, json.Unmarshal(<-dataCh, &loop)) - assert.Equal(t, lpk, loop.Local.PubKey) assert.Equal(t, routing.Port(2), loop.Local.Port) assert.Equal(t, rpk, loop.Remote.PubKey) assert.Equal(t, routing.Port(3), loop.Remote.Port) diff --git a/pkg/node/config_test.go b/pkg/node/config_test.go index 6427bce485..b1c0dbef45 100644 --- a/pkg/node/config_test.go +++ b/pkg/node/config_test.go @@ -10,13 +10,12 @@ import ( "testing" "time" - "github.com/skycoin/skywire/pkg/routing" - "github.com/skycoin/dmsg/cipher" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/skycoin/skywire/internal/httpauth" + "github.com/skycoin/skywire/pkg/routing" ) func TestMessagingDiscovery(t *testing.T) { diff --git a/pkg/node/node.go b/pkg/node/node.go index b8641e80e1..d1ae2b413e 100644 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -19,9 +19,8 @@ import ( "syscall" "time" - "github.com/skycoin/skycoin/src/util/logging" - "github.com/skycoin/dmsg/noise" + "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire/pkg/app" routeFinder "github.com/skycoin/skywire/pkg/route-finder/client" diff --git a/pkg/node/node_test.go b/pkg/node/node_test.go index 582f3545aa..f348e42fa3 100644 --- a/pkg/node/node_test.go +++ b/pkg/node/node_test.go @@ -15,8 +15,6 @@ import ( "testing" "time" - "github.com/skycoin/skywire/pkg/routing" - "github.com/skycoin/dmsg/cipher" "github.com/skycoin/dmsg/disc" "github.com/skycoin/skycoin/src/util/logging" @@ -25,6 +23,7 @@ import ( "github.com/skycoin/skywire/internal/httpauth" "github.com/skycoin/skywire/pkg/app" + "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/transport" "github.com/skycoin/skywire/pkg/transport/dmsg" "github.com/skycoin/skywire/pkg/util/pathutil" diff --git a/pkg/router/port_list.go b/pkg/router/port_list.go index cf6630caf7..5652d8de6c 100644 --- a/pkg/router/port_list.go +++ b/pkg/router/port_list.go @@ -4,9 +4,8 @@ import ( "math" "sync" - "github.com/skycoin/skywire/pkg/routing" - "github.com/skycoin/skywire/pkg/app" + "github.com/skycoin/skywire/pkg/routing" ) type portBind struct { diff --git a/pkg/routing/rule_test.go b/pkg/routing/rule_test.go index 9b8d3c3792..2e8432c1b5 100644 --- a/pkg/routing/rule_test.go +++ b/pkg/routing/rule_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/uuid" "github.com/skycoin/dmsg/cipher" - "github.com/stretchr/testify/assert" )