Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import junk from 'junk'
import joinIterator from 'join-async-iterator'
import parallel from 'run-parallel'
import queueMicrotask from 'queue-microtask'
import sha1 from 'simple-sha1'
import { sha1 } from 'uint8-util'
import 'fast-readable-async-iterator'

import getFiles from './get-files.js' // browser exclude
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"piece-length": "^2.0.1",
"queue-microtask": "^1.2.3",
"run-parallel": "^1.2.0",
"simple-sha1": "^3.1.0"
"uint8-util": "^1.0.1"
},
"devDependencies": {
"@webtorrent/semantic-release-config": "1.0.8",
Expand Down
11 changes: 7 additions & 4 deletions test/browser/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fixtures from 'webtorrent-fixtures'
import fs from 'fs'
import parseTorrent from 'parse-torrent'
import path from 'path'
import sha1 from 'simple-sha1'
import { sha1 } from 'uint8-util'
import test from 'tape'
import createTorrent from '../../index.js'

Expand Down Expand Up @@ -71,7 +71,9 @@ test('create single file torrent', t => {
])

window.parsedTorrent = parsedTorrent
t.equals(sha1.sync(parsedTorrent.infoBuffer), 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
})
})
})

Expand Down Expand Up @@ -117,7 +119,8 @@ test('create multi file torrent', t => {
t.deepEquals(parsedTorrent.pieces, [
'1f74648e50a6a6708ec54ab327a163d5536b7ced'
])

t.equals(sha1.sync(parsedTorrent.infoBuffer), '80562f38656b385ea78959010e51a2cc9db41ea0')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, '80562f38656b385ea78959010e51a2cc9db41ea0')
})
})
})
2 changes: 1 addition & 1 deletion test/browser/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import fs from 'fs'
import parseTorrent from 'parse-torrent'
import path from 'path'
import sha1 from 'simple-sha1'
import { sha1 } from 'uint8-util'
import test from 'tape'
import createTorrent from '../../index.js'

Expand Down
6 changes: 4 additions & 2 deletions test/buffer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import createTorrent from '../index.js'
import parseTorrent from 'parse-torrent'
import path from 'path'
import sha1 from 'simple-sha1'
import { sha1 } from 'uint8-util'
import test from 'tape'

test('create nested torrent with array of buffers', t => {
Expand Down Expand Up @@ -42,6 +42,8 @@ test('create nested torrent with array of buffers', t => {
t.deepEquals(parsedTorrent.pieces, [
'5bf1fd927dfb8679496a2e6cf00cbe50c1c87145'
])
t.equals(sha1.sync(parsedTorrent.infoBuffer), '8fa3c08e640db9576156b21f31353402456a0208')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, '8fa3c08e640db9576156b21f31353402456a0208')
})
})
})
19 changes: 13 additions & 6 deletions test/fs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fixtures from 'webtorrent-fixtures'
import parseTorrent from 'parse-torrent'
import path from 'path'
import sha1 from 'simple-sha1'
import { sha1 } from 'uint8-util'
import test from 'tape'
import createTorrent from '../index.js'

Expand Down Expand Up @@ -54,7 +54,9 @@ test('create single file torrent', t => {
'c698de9b0dad92980906c026d8c1408fa08fe4ec'
])

t.equals(sha1.sync(parsedTorrent.infoBuffer), 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
})
})
})

Expand Down Expand Up @@ -112,7 +114,9 @@ test('create multi file torrent', t => {
t.deepEquals(parsedTorrent.pieces, [
'1f74648e50a6a6708ec54ab327a163d5536b7ced'
])
t.equals(sha1.sync(parsedTorrent.infoBuffer), '80562f38656b385ea78959010e51a2cc9db41ea0')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, '80562f38656b385ea78959010e51a2cc9db41ea0')
})
})
})

Expand Down Expand Up @@ -165,8 +169,9 @@ test('create multi file torrent with nested directories', t => {
t.deepEquals(parsedTorrent.pieces, [
'47972f2befaee58b6f3860cd39bd56cb33a488f0'
])

t.equals(sha1.sync(parsedTorrent.infoBuffer), '427887e9c03e123f9c8458b1947090edf1c75baa')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, '427887e9c03e123f9c8458b1947090edf1c75baa')
})
})
})

Expand Down Expand Up @@ -225,6 +230,8 @@ test('create multi file torrent with array of paths', t => {
t.deepEquals(parsedTorrent.pieces, [
'1c4e1ba6da4d771ff82025d7cf76e8c368c6c3dd'
])
t.equals(sha1.sync(parsedTorrent.infoBuffer), 'df25a2959378892f6ddaf4a2d7e75174e09878bb')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, 'df25a2959378892f6ddaf4a2d7e75174e09878bb')
})
})
})
6 changes: 4 additions & 2 deletions test/mixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fixtures from 'webtorrent-fixtures'
import fs from 'fs'
import parseTorrent from 'parse-torrent'
import path from 'path'
import sha1 from 'simple-sha1'
import { sha1 } from 'uint8-util'
import test from 'tape'
import createTorrent from '../index.js'

Expand Down Expand Up @@ -65,6 +65,8 @@ test('create multi file torrent with array of mixed types', t => {
t.deepEquals(parsedTorrent.pieces, [
'9ad893bb9aeca601a0fab4ba85bd4a4c18b630e3'
])
t.equals(sha1.sync(parsedTorrent.infoBuffer), 'bad3f8ea0d1d8a55c18a039dd464f1078f83dba2')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, 'bad3f8ea0d1d8a55c18a039dd464f1078f83dba2')
})
})
})
12 changes: 7 additions & 5 deletions test/source.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'path'
import fixtures from 'webtorrent-fixtures'
import parseTorrent from 'parse-torrent'
import sha1 from 'simple-sha1'
import { sha1 } from 'uint8-util'
import test from 'tape'

import createTorrent from '../index.js'
Expand Down Expand Up @@ -36,8 +36,9 @@ test('verify info-hash without no source set (default)', t => {
t.equal(parsedTorrent.pieceLength, 262144)

t.deepEquals(parsedTorrent.pieces, ['799c11e348d39f1704022b8354502e2f81f3c037'])

t.equals(sha1.sync(parsedTorrent.infoBuffer), 'b4dfce1f956f720c928535ded617d07696a819ef', 'mktorrent hash with no source')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, 'b4dfce1f956f720c928535ded617d07696a819ef')
Comment thread
ThaUnknown marked this conversation as resolved.
Outdated
})
})
})

Expand Down Expand Up @@ -72,7 +73,8 @@ test('verify info-hash an additional source attribute set on the info dict (a wa
t.equal(parsedTorrent.pieceLength, 262144)

t.deepEquals(parsedTorrent.pieces, ['799c11e348d39f1704022b8354502e2f81f3c037'])

t.equals(sha1.sync(parsedTorrent.infoBuffer), 'a9499b56289356a3d5b8636387deb83709b8fa42', 'mktorrent run with -s SOURCE')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, 'a9499b56289356a3d5b8636387deb83709b8fa42')
Comment thread
ThaUnknown marked this conversation as resolved.
Outdated
})
})
})
11 changes: 7 additions & 4 deletions test/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fixtures from 'webtorrent-fixtures'
import fs from 'fs'
import parseTorrent from 'parse-torrent'
import path from 'path'
import sha1 from 'simple-sha1'
import { sha1 } from 'uint8-util'
import test from 'tape'
import createTorrent from '../index.js'

Expand Down Expand Up @@ -57,8 +57,9 @@ test('create single file torrent from a stream', t => {
'56dcc242d03293e9446cf5e457d8eb3d9588fd90',
'c698de9b0dad92980906c026d8c1408fa08fe4ec'
])

t.equals(sha1.sync(parsedTorrent.infoBuffer), 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
})
})
})

Expand Down Expand Up @@ -111,7 +112,9 @@ test('create multi file torrent with streams', t => {
t.deepEquals(parsedTorrent.pieces, [
'1f74648e50a6a6708ec54ab327a163d5536b7ced'
])
t.equals(sha1.sync(parsedTorrent.infoBuffer), '80562f38656b385ea78959010e51a2cc9db41ea0')
sha1(parsedTorrent.infoBuffer, hash => {
t.equals(hash, '80562f38656b385ea78959010e51a2cc9db41ea0')
})
})
})

Expand Down