Files
BinancePayTool/sdk/go/client_test.go
T
qianyubtcandClaude Fable 5 f87ec65541 BinancePayTool v0.1.0:币安支付个人收款网关(Go 核心 + 四语言 SDK)
- Go 服务端:唯一金额/备注码/回填订单编号三路匹配、托管收银页、HMAC 回调七级重试、SQLite 单二进制
- SDK:Go / Java / PHP / Python,共享签名测试向量(docs/test_vectors.json)
- 跨语言 e2e(真实二进制 × Python SDK × mock 币安)、GitHub Actions CI、Dockerfile
- 协议文档 docs/protocol.md、调研与实测结论 docs/research.md

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-02 14:09:32 +08:00

35 lines
757 B
Go

package bpaygate
import (
"encoding/json"
"os"
"testing"
)
func TestVectors(t *testing.T) {
data, err := os.ReadFile("../../docs/test_vectors.json")
if err != nil {
t.Fatal(err)
}
var vf struct {
Secret string `json:"secret"`
Cases []struct {
Type, Timestamp, Nonce, Method, Path, Body, Signature string
} `json:"cases"`
}
if err := json.Unmarshal(data, &vf); err != nil {
t.Fatal(err)
}
for i, c := range vf.Cases {
var got string
if c.Type == "request" {
got = SignRequest(vf.Secret, c.Timestamp, c.Nonce, c.Method, c.Path, []byte(c.Body))
} else {
got = SignCallback(vf.Secret, c.Timestamp, c.Nonce, []byte(c.Body))
}
if got != c.Signature {
t.Errorf("case %d: got %s want %s", i, got, c.Signature)
}
}
}