How to use the libp2p-mplex.multicodec function in libp2p-mplex

To help you get started, we’ve selected a few libp2p-mplex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libp2p / js-libp2p / test / upgrading / upgrader.spec.js View on Github external
it('should fail if crypto fails', async () => {
    const { inbound, outbound } = mockMultiaddrConnPair({ addrs, remotePeer })

    const muxers = new Map([[Muxer.multicodec, Muxer]])
    sinon.stub(localUpgrader, 'muxers').value(muxers)
    sinon.stub(remoteUpgrader, 'muxers').value(muxers)

    const crypto = {
      tag: '/insecure',
      secureInbound: () => { throw new Error('Boom') },
      secureOutbound: () => { throw new Error('Boom') }
    }

    const cryptos = new Map([[crypto.tag, crypto]])
    sinon.stub(localUpgrader, 'cryptos').value(cryptos)
    sinon.stub(remoteUpgrader, 'cryptos').value(cryptos)

    // Wait for the results of each side of the connection
    const results = await pSettle([
      localUpgrader.upgradeOutbound(outbound),
github libp2p / js-libp2p / test / utils / mockConnection.js View on Github external
// Pipe all data through the muxer
  pipe(maConn, muxer, maConn)

  maConn.timeline.upgraded = Date.now()

  // Create the connection
  const connection = new Connection({
    localAddr: maConn.localAddr,
    remoteAddr: maConn.remoteAddr,
    localPeer: localPeer,
    remotePeer: remotePeer,
    stat: {
      direction,
      timeline: maConn.timeline,
      multiplexer: Muxer.multicodec,
      encryption: 'N/A'
    },
    newStream,
    getStreams: () => muxer.streams,
    close: err => maConn.close(err)
  })

  return connection
}
github libp2p / js-libp2p-switch / test / identify.node.js View on Github external
setTimeout(() => {
        const peerB = switchA._peerBook.get(switchB._peerInfo.id.toB58String())
        const peerA = switchB._peerBook.get(switchA._peerInfo.id.toB58String())
        expect(Array.from(peerB.protocols)).to.eql([
          multiplex.multicodec,
          identify.multicodec
        ])
        expect(Array.from(peerA.protocols)).to.eql([
          multiplex.multicodec,
          identify.multicodec,
          '/id-test/1.0.0'
        ])

        done()
      }, 500)
    })
github libp2p / js-libp2p / test / switch / identify.node.js View on Github external
setTimeout(() => {
        const peerB = switchA._peerBook.get(switchB._peerInfo.id.toB58String())
        const peerA = switchB._peerBook.get(switchA._peerInfo.id.toB58String())
        expect(Array.from(peerB.protocols)).to.eql([
          multiplex.multicodec,
          identify.multicodec
        ])
        expect(Array.from(peerA.protocols)).to.eql([
          multiplex.multicodec,
          identify.multicodec,
          '/id-test/1.0.0'
        ])

        done()
      }, 500)
    })

libp2p-mplex

JavaScript implementation of https://github.com/libp2p/mplex

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis