feat: 接入 CoinGlass 清算热力图隔离链路
Some checks failed
ci / build + vet + guard + race (push) Has been cancelled

This commit is contained in:
dela
2026-05-25 16:57:22 +08:00
parent e5fb54cb72
commit 1b61541ff5
32 changed files with 2550 additions and 70 deletions

View File

@@ -0,0 +1,44 @@
package coinglass
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
)
func TestResolveSeed_AllBranches(t *testing.T) {
cases := []struct {
name string
v string
path string
reqCacheTsV2 string
respTime string
wantSeed string
}{
{"v=0 → cache-ts-v2", "0", "/api/x", "1735689600000", "1735689601000", "1735689600000"},
{"v=1 → path", "1", "/api/index/v2/liqHeatMap", "ts", "rt", "/api/index/v2/liqHeatMap"},
{"v=2 → resp time", "2", "/api/x", "ts", "1735689601000", "1735689601000"},
{"v=55 → bundle const", "55", "", "", "", "170b070da9654622"},
{"v=66 → bundle const", "66", "", "", "", "d6537d845a964081"},
{"v=77 → bundle const", "77", "", "", "", "863f08689c97435b"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got, err := resolveSeed(tc.v, tc.path, tc.reqCacheTsV2, tc.respTime)
require.NoError(t, err)
require.Equal(t, tc.wantSeed, got)
})
}
}
func TestResolveSeed_UnknownV(t *testing.T) {
cases := []string{"3", "88", "99", "v0", ""}
for _, v := range cases {
t.Run("unknown_v="+v, func(t *testing.T) {
_, err := resolveSeed(v, "/p", "ts", "rt")
require.Error(t, err)
require.True(t, errors.Is(err, ErrUnknownV), "want ErrUnknownV, got %v", err)
})
}
}