Files
gocryptotrader/exchanges/okx/okx_wrapper_test.go
Ryan O'Hara-Reid fefb866b02 exchanges/GateIO, OKX: Fix and optimise websocket request ID message generation (#2103)
* gatio: fix MessageID regression (cherry-pick me)

* Update exchanges/gateio/gateio_wrapper_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* glorious: AI

* Update exchanges/gateio/gateio_wrapper.go

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

* thrasher: use optimisation in okx as well

* okx: Add length check in tests for string -> uuid conversion

* thrasher: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
2025-11-11 14:25:21 +11:00

27 lines
683 B
Go

package okx
import (
"testing"
"github.com/gofrs/uuid"
"github.com/stretchr/testify/require"
)
func TestMessageID(t *testing.T) {
t.Parallel()
id := new(Exchange).MessageID()
require.Len(t, id, 32, "Must return the correct length of message id")
u, err := uuid.FromString(id)
require.NoError(t, err, "MessageID must return a valid UUID")
require.Equal(t, uuid.V7, u.Version(), "MessageID must return a V7 uuid")
require.Len(t, u.String(), 36, "UUID v7 string representation must be 36 characters long")
}
// 7696807 153.1 ns/op 48 B/op 2 allocs/op
func BenchmarkMessageID(b *testing.B) {
e := new(Exchange)
for b.Loop() {
_ = e.MessageID()
}
}