MCPcopy
hub / github.com/feross/simple-peer / tryTest

Function tryTest

test/binary.js:28–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26 peer2.on('connect', tryTest)
27
28 function tryTest () {
29 if (!peer1.connected || !peer2.connected) return
30
31 peer1.send(Buffer.from([0, 1, 2]))
32 peer2.on('data', function (data) {
33 t.ok(Buffer.isBuffer(data), 'data is Buffer')
34 t.deepEqual(data, Buffer.from([0, 1, 2]), 'got correct message')
35
36 peer2.send(Buffer.from([0, 2, 4]))
37 peer1.on('data', function (data) {
38 t.ok(Buffer.isBuffer(data), 'data is Buffer')
39 t.deepEqual(data, Buffer.from([0, 2, 4]), 'got correct message')
40
41 peer1.on('close', function () { t.pass('peer1 destroyed') })
42 peer1.destroy()
43 peer2.on('close', function () { t.pass('peer2 destroyed') })
44 peer2.destroy()
45 })
46 })
47 }
48})
49
50test('data send/receive Uint8Array', function (t) {

Callers

nothing calls this directly

Calls 2

sendMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…