How to use libp2p-tcp - 4 common examples

To help you get started, we’ve selected a few libp2p-tcp 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 / transports / transport-manager.node.js View on Github external
it('should be able to listen', async () => {
    tm.add(Transport.prototype[Symbol.toStringTag], Transport)
    await tm.listen(addrs)
    expect(tm._listeners).to.have.key(Transport.prototype[Symbol.toStringTag])
    expect(tm._listeners.get(Transport.prototype[Symbol.toStringTag])).to.have.length(addrs.length)
    // Ephemeral ip addresses may result in multiple listeners
    expect(tm.getAddrs().length).to.equal(addrs.length)
    await tm.close()
    expect(tm._listeners.get(Transport.prototype[Symbol.toStringTag])).to.have.length(0)
  })
github libp2p / js-libp2p / test / transports / transport-manager.node.js View on Github external
it('should be able to add and remove a transport', async () => {
    tm.add(Transport.prototype[Symbol.toStringTag], Transport)
    expect(tm._transports.size).to.equal(1)
    await tm.remove(Transport.prototype[Symbol.toStringTag])
  })
github libp2p / js-libp2p / test / dialing / direct.node.js View on Github external
before(async () => {
    remoteTM = new TransportManager({
      libp2p: {},
      upgrader: mockUpgrader
    })
    remoteTM.add(Transport.prototype[Symbol.toStringTag], Transport)

    localTM = new TransportManager({
      libp2p: {},
      upgrader: mockUpgrader
    })
    localTM.add(Transport.prototype[Symbol.toStringTag], Transport)

    await remoteTM.listen([listenAddr])

    remoteAddr = remoteTM.getAddrs()[0]
  })
github libp2p / js-libp2p / test / dialing / direct.node.js View on Github external
before(async () => {
    remoteTM = new TransportManager({
      libp2p: {},
      upgrader: mockUpgrader
    })
    remoteTM.add(Transport.prototype[Symbol.toStringTag], Transport)

    localTM = new TransportManager({
      libp2p: {},
      upgrader: mockUpgrader
    })
    localTM.add(Transport.prototype[Symbol.toStringTag], Transport)

    await remoteTM.listen([listenAddr])

    remoteAddr = remoteTM.getAddrs()[0]
  })

libp2p-tcp

Node.js implementation of the TCP module that libp2p uses, which implements the interface-connection and interface-transport interfaces

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular libp2p-tcp functions