How to use the webtorrent-fixtures.leavesMetadata.torrent function in webtorrent-fixtures

To help you get started, we’ve selected a few webtorrent-fixtures 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 webtorrent / ut_metadata / test / fetch.js View on Github external
test('fetch()', t => {
  t.plan(3)

  const wire1 = new Protocol()
  const wire2 = new Protocol()
  wire1.pipe(wire2).pipe(wire1)

  wire1.use(utMetadata(leavesMetadata.torrent)) // wire1 already has metadata
  wire2.use(utMetadata()) // wire2 does not

  wire2.ut_metadata.fetch()

  wire2.ut_metadata.on('metadata', _metadata => {
    // got metadata!
    t.equal(
      _metadata.toString('hex'),
      bencode.encode({
        info: bencode.decode(leavesMetadata.torrent).info
      }).toString('hex')
    )
  })

  wire2.on('handshake', (infoHash, peerId, extensions) => {
    wire2.handshake(leavesMetadata.parsedTorrent.infoHash, id2)
github webtorrent / ut_metadata / test / fetch.js View on Github external
wire2.ut_metadata.on('metadata', _metadata => {
    // got metadata!
    t.equal(
      _metadata.toString('hex'),
      bencode.encode({
        info: bencode.decode(leavesMetadata.torrent).info
      }).toString('hex')
    )
  })
github webtorrent / ut_metadata / test / basic.js View on Github external
test('wire.use(utMetadata(metadata))', t => {
  const wire = new Protocol()
  wire.pipe(wire)

  wire.use(utMetadata(leavesMetadata.torrent))

  t.ok(wire.ut_metadata)
  t.ok(wire.ut_metadata.fetch)
  t.ok(wire.ut_metadata.cancel)
  t.equal(
    wire.ut_metadata.metadata.toString('hex'),
    bencode.encode(bencode.decode(leavesMetadata.torrent).info).toString('hex')
  )
  t.end()
})
github webtorrent / ut_metadata / test / basic.js View on Github external
test('wire.use(utMetadata(metadata))', t => {
  const wire = new Protocol()
  wire.pipe(wire)

  wire.use(utMetadata(leavesMetadata.torrent))

  t.ok(wire.ut_metadata)
  t.ok(wire.ut_metadata.fetch)
  t.ok(wire.ut_metadata.cancel)
  t.equal(
    wire.ut_metadata.metadata.toString('hex'),
    bencode.encode(bencode.decode(leavesMetadata.torrent).info).toString('hex')
  )
  t.end()
})