diff --git a/pkg/app/appserver/rpc_gateway_test.go b/pkg/app/appserver/rpc_gateway_test.go index eb6a5a3b2a..d2ccf0ade7 100644 --- a/pkg/app/appserver/rpc_gateway_test.go +++ b/pkg/app/appserver/rpc_gateway_test.go @@ -23,8 +23,7 @@ import ( "github.com/SkycoinProject/skywire-mainnet/pkg/routing" ) -// TODO (Darkren): fix test -/*func TestRPCGateway_Dial(t *testing.T) { +func TestRPCGateway_Dial(t *testing.T) { l := logging.MustGetLogger("rpc_gateway") nType := appnet.TypeDMSG @@ -53,7 +52,9 @@ func testRPCGatewayDialOK(t *testing.T, l *logging.Logger, nType appnet.Type, di localPort := routing.Port(100) dialCtx := context.Background() - dialConn := dmsg.NewStream(nil, nil, dmsg.Addr{Port: uint16(localPort)}, dmsg.Addr{}, 0, 10, func() {}) + dialConn := &appcommon.MockConn{} + dialConn.On("LocalAddr").Return(dmsg.Addr{Port: uint16(localPort)}) + dialConn.On("RemoteAddr").Return(dmsg.Addr{}) var dialErr error @@ -137,7 +138,7 @@ func testRPCGatewayDialErrorWrappingConn(t *testing.T, l *logging.Logger, nType var resp DialResp err = rpc.Dial(&dialAddr, &resp) require.Equal(t, err, appnet.ErrUnknownAddrType) -}*/ +} func TestRPCGateway_Listen(t *testing.T) { l := logging.MustGetLogger("rpc_gateway") diff --git a/pkg/app/conn_test.go b/pkg/app/conn_test.go index 394440f851..c4dceec041 100644 --- a/pkg/app/conn_test.go +++ b/pkg/app/conn_test.go @@ -180,12 +180,12 @@ func TestConn_TestConn(t *testing.T) { fmt.Printf("C2 Local: %s\n", keys[1].PK) p1, p2 := net.Pipe() a1 := appnet.Addr{ - Net: appnet.Type(netType), + Net: netType, PubKey: keys[0].PK, Port: 0, } a2 := appnet.Addr{ - Net: appnet.Type(netType), + Net: netType, PubKey: keys[1].PK, Port: 0, } @@ -207,17 +207,15 @@ func TestConn_TestConn(t *testing.T) { n.On("DialContext", mock.Anything, a2).Return(wc2, testhelpers.NoErr) appnet.ClearNetworkers() - err := appnet.AddNetworker(appnet.Type(netType), n) + err := appnet.AddNetworker(netType, n) if err != nil { return nil, nil, nil, err } - //require.NoError(t, err) rpcL, err := nettest.NewLocalListener("tcp") if err != nil { return nil, nil, nil, err } - //require.NoError(t, err) rpcS := rpc.NewServer() @@ -229,12 +227,10 @@ func TestConn_TestConn(t *testing.T) { if err != nil { return nil, nil, nil, err } - //require.NoError(t, err) err = rpcS.RegisterName(appKeys[1].PK.Hex(), gateway2) if err != nil { return nil, nil, nil, err } - //require.NoError(t, err) go rpcS.Accept(rpcL) @@ -242,7 +238,6 @@ func TestConn_TestConn(t *testing.T) { if err != nil { return nil, nil, nil, err } - //require.NoError(t, err) cl1 := Client{ log: logging.MustGetLogger("test_client_1"), @@ -256,7 +251,6 @@ func TestConn_TestConn(t *testing.T) { if err != nil { return nil, nil, nil, err } - //require.NoError(t, err) cl2 := Client{ log: logging.MustGetLogger("test_client_2"), @@ -270,59 +264,20 @@ func TestConn_TestConn(t *testing.T) { if err != nil { return nil, nil, nil, err } - //require.NoError(t, err) c2, err := cl2.Dial(a1) if err != nil { return nil, nil, nil, err } - //require.NoError(t, err) stop := func() { - /*err := c1.Close() - require.NoError(t, err) - err = c2.Close() - require.NoError(t, err) - err = rpcL.Close() - require.NoError(t, err)*/ + _ = c1.Close() //nolint:errcheck + _ = c2.Close() //nolint:errcheck + _ = rpcL.Close() //nolint:errcheck } return c1, c2, stop, nil } - /*payload := []byte("hello") - - errC := make(chan error) - nC := make(chan int) - bufC := make(chan []byte) - go func() { - buf := make([]byte, 10) - n, err := c2.Read(buf) - fmt.Printf("Err is %v\n", err) - errC <- err - if err != nil { - return - } - - nC <- n - bufC <- buf[:n] - }() - - written, err := c1.Write(payload) - require.NoError(t, err) - require.Equal(t, len(payload), written) - - require.NoError(t, <-errC) - close(errC) - require.Equal(t, len(payload), <-nC) - close(nC) - require.Equal(t, payload, <-bufC) - close(bufC) - - err = c1.Close() - require.NoError(t, err) - err = c2.Close() - require.NoError(t, err)*/ - nettest.TestConn(t, mp) } diff --git a/pkg/app/rpc_client_test.go b/pkg/app/rpc_client_test.go index 71a708655e..a4d24be4af 100644 --- a/pkg/app/rpc_client_test.go +++ b/pkg/app/rpc_client_test.go @@ -25,8 +25,7 @@ import ( "github.com/SkycoinProject/skywire-mainnet/pkg/app/appserver" ) -// TODO (Darkren): fix test -/*func TestRPCClient_Dial(t *testing.T) { +func TestRPCClient_Dial(t *testing.T) { t.Run("ok", func(t *testing.T) { s := prepRPCServer(t, prepGateway()) rpcL, lisCleanup := prepListener(t) @@ -38,12 +37,12 @@ import ( dmsgLocal, dmsgRemote, _, remote := prepAddrs() dialCtx := context.Background() - dialConn := dmsg.NewStream(&appcommon.MockConn{}, logging.MustGetLogger("dmsg_tp"), - dmsgLocal, dmsgRemote, 0, 1024, func() {}) - var noErr error + dialConn := &appcommon.MockConn{} + dialConn.On("LocalAddr").Return(dmsgLocal) + dialConn.On("RemoteAddr").Return(dmsgRemote) n := &appnet.MockNetworker{} - n.On("DialContext", dialCtx, remote).Return(dialConn, noErr) + n.On("DialContext", dialCtx, remote).Return(dialConn, testhelpers.NoErr) appnet.ClearNetworkers() err := appnet.AddNetworker(appnet.TypeDMSG, n) @@ -82,7 +81,7 @@ import ( require.Equal(t, connID, uint16(0)) require.Equal(t, localPort, routing.Port(0)) }) -}*/ +} func TestRPCClient_Listen(t *testing.T) { t.Run("ok", func(t *testing.T) { @@ -139,19 +138,18 @@ func TestRPCClient_Listen(t *testing.T) { }) } -// TODO (Darkren): fix test -/*func TestRPCClient_Accept(t *testing.T) { +func TestRPCClient_Accept(t *testing.T) { dmsgLocal, dmsgRemote, local, _ := prepAddrs() t.Run("ok", func(t *testing.T) { gateway := prepGateway() - lisConn := dmsg.NewStream(&appcommon.MockConn{}, logging.MustGetLogger("dmsg_tp"), - dmsgLocal, dmsgRemote, 0, 1024, func() {}) - var noErr error + lisConn := &appcommon.MockConn{} + lisConn.On("LocalAddr").Return(dmsgLocal) + lisConn.On("RemoteAddr").Return(dmsgRemote) lis := &appcommon.MockListener{} - lis.On("Accept").Return(lisConn, noErr) + lis.On("Accept").Return(lisConn, testhelpers.NoErr) prepNetworkerWithListener(t, lis, local) @@ -206,7 +204,7 @@ func TestRPCClient_Listen(t *testing.T) { require.Equal(t, connID, uint16(0)) require.Equal(t, remote, appnet.Addr{}) }) -}*/ +} func TestRPCClient_Write(t *testing.T) { dmsgLocal, dmsgRemote, _, remote := prepAddrs() diff --git a/pkg/visor/visor_test.go b/pkg/visor/visor_test.go index c931568434..4704b2a098 100644 --- a/pkg/visor/visor_test.go +++ b/pkg/visor/visor_test.go @@ -82,7 +82,6 @@ func TestMain(m *testing.M) { // assert.NotNil(t, node.startedApps) //} -// TODO (Darkren): fix tests func TestNodeStartClose(t *testing.T) { r := &router.MockRouter{} r.On("Serve", mock.Anything /* context */).Return(testhelpers.NoErr) diff --git a/vendor/github.com/SkycoinProject/skycoin/src/cipher/crypto.go b/vendor/github.com/SkycoinProject/skycoin/src/cipher/crypto.go index 94499df00c..0f68f85c86 100644 --- a/vendor/github.com/SkycoinProject/skycoin/src/cipher/crypto.go +++ b/vendor/github.com/SkycoinProject/skycoin/src/cipher/crypto.go @@ -434,6 +434,7 @@ func VerifyPubKeySignedHash(pubkey PubKey, sig Sig, hash SHA256) error { return ErrInvalidSigPubKeyRecovery } if pubkeyRec != pubkey { + fmt.Printf("Recovered: %s, original: %s\n", pubkeyRec.Hex(), pubkey.Hex()) return ErrPubKeyRecoverMismatch } if secp256k1.VerifyPubkey(pubkey[:]) != 1 { diff --git a/vendor/golang.org/x/net/nettest/conntest.go b/vendor/golang.org/x/net/nettest/conntest.go index 0427987e7d..39cc6a631e 100644 --- a/vendor/golang.org/x/net/nettest/conntest.go +++ b/vendor/golang.org/x/net/nettest/conntest.go @@ -37,9 +37,9 @@ func TestConn(t *testing.T, mp MakePipe) { t.Run("WriteTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testWriteTimeout) }) t.Run("PastTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testPastTimeout) }) t.Run("PresentTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testPresentTimeout) }) - //t.Run("FutureTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testFutureTimeout) }) - //t.Run("CloseTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testCloseTimeout) }) - //t.Run("ConcurrentMethods", func(t *testing.T) { timeoutWrapper(t, mp, testConcurrentMethods) }) + t.Run("FutureTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testFutureTimeout) }) + t.Run("CloseTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testCloseTimeout) }) + t.Run("ConcurrentMethods", func(t *testing.T) { timeoutWrapper(t, mp, testConcurrentMethods) }) } type connTester func(t *testing.T, c1, c2 net.Conn)