Files
gocryptotrader/exchanges/gateio/gateio_websocket_test.go
Ryan O'Hara-Reid 16f543666f GateIO: Fix and standardise ping handling (#2023)
* gateio: standardise ping handlers (cherry-pick)

* Add tests and expand incoming cases for proof

* lint: fix and add commentary on ping delay

* Update exchange/websocket/connection.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/gateio/gateio_websocket.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* linter: fix

* Update exchange/websocket/connection.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* fix test

* glorious: insane catch

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
2025-09-10 21:02:09 +10:00

34 lines
672 B
Go

package gateio
import (
"testing"
"time"
gws "github.com/gorilla/websocket"
"github.com/stretchr/testify/require"
)
func TestGetWSPingHandler(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
channel string
err error
}{
{optionsPingChannel, nil},
{futuresPingChannel, nil},
{spotPingChannel, nil},
{"dong", errInvalidPingChannel},
} {
got, err := getWSPingHandler(tc.channel)
if tc.err != nil {
require.ErrorIs(t, err, tc.err)
continue
}
require.NoError(t, err)
require.Equal(t, time.Second*10, got.Delay)
require.Equal(t, gws.TextMessage, got.MessageType)
require.Contains(t, string(got.Message), tc.channel)
}
}