Deribit: Replace bespoke message IDs with uuid v7 (#1995)

* Deribit: Switch to string IDs

Switch from int to string IDs so we can use UUID.v7 instead of (the only) local high precision message id implementation

* Deribit: Dedup wsResponse / wsResponse

* Deribit: Use uuid v7 for IDs

This moves away from centralising message ids.
There's no real benefit to moving them to a central generator, since we
can one-line it, and reduce our testing plane and complexity.
And it's more concise for exchanges to say "I'm using this UUID".

* Deribit: Handle errors from StartHeartbeat

* Deribit: Simplify WS ID matching

* Exchanges: Add MessageID function to base
This commit is contained in:
Gareth Kirwan
2025-09-12 12:52:03 +07:00
committed by GitHub
parent 4ac0519a4c
commit 6907dfa6a8
7 changed files with 97 additions and 69 deletions

View File

@@ -7,6 +7,7 @@ import (
"testing"
"time"
"github.com/gofrs/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/thrasher-corp/gocryptotrader/common"
@@ -2865,11 +2866,22 @@ func TestCheckOrderExecutionLimits(t *testing.T) {
}
func TestWebsocketSubmitOrder(t *testing.T) {
t.Parallel()
_, err := (&Base{}).WebsocketSubmitOrder(t.Context(), nil)
require.ErrorIs(t, err, common.ErrFunctionNotSupported)
}
func TestWebsocketSubmitOrders(t *testing.T) {
t.Parallel()
_, err := (&Base{}).WebsocketSubmitOrders(t.Context(), nil)
require.ErrorIs(t, err, common.ErrFunctionNotSupported)
}
func TestMessageID(t *testing.T) {
t.Parallel()
id := (new(Base)).MessageID()
require.NotEmpty(t, id, "MessageID must return a non-empty message ID")
u, err := uuid.FromString(id)
require.NoError(t, err, "MessageID must return a valid UUID")
assert.Equal(t, byte(0x7), u.Version(), "MessageID should return a V7 uuid")
}