MCPcopy
hub / github.com/daptin/daptin / TestYJSBidirectionalRelay

Function TestYJSBidirectionalRelay

yjs_test.go:215–239  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

213}
214
215func TestYJSBidirectionalRelay(t *testing.T) {
216 ensureServer()
217 token := signUpAndGetToken(t)
218
219 docName := fmt.Sprintf("bidir-%d", time.Now().UnixNano())
220
221 connA := connectAndSubscribe(t, docName, token)
222 defer connA.Close()
223 connB := connectAndSubscribe(t, docName, token)
224 defer connB.Close()
225
226 // A → B
227 connA.WriteMessage(gorillaWs.BinaryMessage, buildYjsUpdate([]byte{0x01}))
228 _, okAB := tryReadYJSMessage(connB, 5*time.Second)
229 if !okAB {
230 t.Error("A→B relay failed")
231 }
232
233 // B → A
234 connB.WriteMessage(gorillaWs.BinaryMessage, buildYjsUpdate([]byte{0x02}))
235 _, okBA := tryReadYJSMessage(connA, 5*time.Second)
236 if !okBA {
237 t.Error("B→A relay failed")
238 }
239}
240
241func TestYJSSyncStep1Forwarding(t *testing.T) {
242 ensureServer()

Callers

nothing calls this directly

Calls 7

ensureServerFunction · 0.85
signUpAndGetTokenFunction · 0.85
connectAndSubscribeFunction · 0.85
buildYjsUpdateFunction · 0.85
tryReadYJSMessageFunction · 0.85
ErrorMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected