-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add BitTorrent v2 test torrents
- Loading branch information
1 parent
b7246d2
commit a733975
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var bencode = require('..') | ||
var test = require('tape').test | ||
var fs = require('fs') | ||
var path = require('path') | ||
|
||
var files = { | ||
test: fs.readFileSync(path.join(__dirname, 'data', 'test.torrent')), | ||
bittorrent2: fs.readFileSync(path.join(__dirname, 'data', 'bittorrent-v2-test.torrent')), | ||
bittorrent2Hybrid: fs.readFileSync(path.join(__dirname, 'data', 'bittorrent-v2-hybrid-test.torrent')) | ||
} | ||
|
||
test('Torrent test files', function (t) { | ||
t.test('should decode & encode `test.torrent` file', function (t) { | ||
t.plan(2) | ||
var decoded = bencode.decode(files.test) | ||
var encoded = bencode.encode(decoded) | ||
t.equal(encoded.length, files.test.length) | ||
t.deepEqual(encoded, files.test) | ||
}) | ||
|
||
t.test('should decode & encode `bittorrent-v2-test.torrent` file', function (t) { | ||
t.plan(2) | ||
var decoded = bencode.decode(files.bittorrent2) | ||
var encoded = bencode.encode(decoded) | ||
t.equal(encoded.length, files.bittorrent2.length) | ||
t.deepEqual(encoded, files.bittorrent2) | ||
}) | ||
|
||
t.test('should decode & encode `bittorrent-v2-hybrid-test.torrent` file', function (t) { | ||
t.plan(2) | ||
var decoded = bencode.decode(files.bittorrent2Hybrid) | ||
var encoded = bencode.encode(decoded) | ||
t.equal(encoded.length, files.bittorrent2Hybrid.length) | ||
t.deepEqual(encoded, files.bittorrent2Hybrid) | ||
}) | ||
}) |