ut_metadata/test/basic.js

32 lines
846 B
JavaScript
Raw Normal View History

2016-02-05 22:32:52 +00:00
var bencode = require('bencode')
2016-03-16 19:33:57 +00:00
var fixtures = require('webtorrent-fixtures')
2014-03-23 03:34:50 +00:00
var Protocol = require('bittorrent-protocol')
var test = require('tape')
2016-02-05 22:32:52 +00:00
var ut_metadata = require('../')
2014-03-23 03:34:50 +00:00
test('wire.use(ut_metadata())', function (t) {
var wire = new Protocol()
wire.pipe(wire)
wire.use(ut_metadata())
2014-03-26 09:03:13 +00:00
t.ok(wire.ut_metadata)
t.ok(wire.ut_metadata.fetch)
t.ok(wire.ut_metadata.cancel)
t.notOk(wire.ut_metadata.metadata)
2014-03-23 03:34:50 +00:00
t.end()
})
test('wire.use(ut_metadata(metadata))', function (t) {
var wire = new Protocol()
wire.pipe(wire)
2016-03-16 19:33:57 +00:00
wire.use(ut_metadata(fixtures.leavesMetadata.torrent))
2014-03-23 03:34:50 +00:00
2014-03-26 09:03:13 +00:00
t.ok(wire.ut_metadata)
t.ok(wire.ut_metadata.fetch)
t.ok(wire.ut_metadata.cancel)
2016-03-16 19:33:57 +00:00
t.equal(wire.ut_metadata.metadata.toString('hex'), bencode.encode(bencode.decode(fixtures.leavesMetadata.torrent).info).toString('hex'))
2014-03-23 03:34:50 +00:00
t.end()
})