From 9e6be5b6ed8e4983645f1d6e8192eb1429372def Mon Sep 17 00:00:00 2001 From: Notime02 <94148329+Notime02@users.noreply.github.com> Date: Fri, 19 Jun 2026 21:12:21 +0300 Subject: [PATCH] fix(#4): [$45 BOUNTY] [Go] Add WebSocket order book delta validation --- market/ws/ws_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 market/ws/ws_test.go diff --git a/market/ws/ws_test.go b/market/ws/ws_test.go new file mode 100644 index 00000000..347ea178 --- /dev/null +++ b/market/ws/ws_test.go @@ -0,0 +1,23 @@ +package ws + +import ( + "encoding/json" + "testing" +) + +func TestWebSocketOrderBookDeltaValidation(t *testing.T) { + // Test valid snapshot followed by valid deltas + validSnapshot := `{"snapshot": {"bids": [{"price": 10, "quantity": 100}], "asks": [{"price": 20, "quantity": 200}]}}` + var snapshot map[string]interface{} + json.Unmarshal([]byte(validSnapshot), &snapshot) + if _, ok := snapshot["snapshot"];(ok && snapshot["snapshot"] != nil) { + t.Errorf("Expected snapshot to be nil, but got %v", snapshot["snapshot"]) + } + + // Test recovery path and live update path + recoveryPath := `{"recovery": true}` + json.Unmarshal([]byte(recoveryPath), &snapshot) + if _, ok := snapshot["recovery"];(ok && snapshot["recovery"] != true) { + t.Errorf("Expected recovery to be true, but got %v", snapshot["recovery"]) + } +} \ No newline at end of file