Skip to content

Commit

Permalink
fix(deps): update dependency uint8-util to v2 (#192)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency uint8-util to v2

* fix: new hash format (#197)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Cas <6506529+ThaUnknown@users.noreply.github.com>
  • Loading branch information
renovate[bot] and ThaUnknown authored Jan 25, 2023
1 parent a320137 commit a88e7d1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions 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 'uint8-util'
import { hash } from 'uint8-util'
import 'fast-readable-async-iterator'

import getFiles from './get-files.js' // browser exclude
Expand Down Expand Up @@ -225,7 +225,7 @@ async function getPieceList (files, pieceLength, estimatedTorrentLength, opts, c
const i = pieceNum
++pieceNum
if (++remainingHashes < MAX_OUTSTANDING_HASHES) resolve()
sha1(chunk, hash => {
hash(chunk, 'hex').then(hash => {
pieces[i] = hash
--remainingHashes
hashedLength += chunk.length
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",
"uint8-util": "^1.0.1"
"uint8-util": "^2.1.4"
},
"devDependencies": {
"@webtorrent/semantic-release-config": "1.0.8",
Expand Down
4 changes: 2 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 'uint8-util'
import { hash } from 'uint8-util'
import test from 'tape'

test('create nested torrent with array of buffers', t => {
Expand Down Expand Up @@ -42,7 +42,7 @@ test('create nested torrent with array of buffers', t => {
t.deepEquals(parsedTorrent.pieces, [
'5bf1fd927dfb8679496a2e6cf00cbe50c1c87145'
])
sha1(parsedTorrent.infoBuffer, hash => {
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
t.equals(hash, '8fa3c08e640db9576156b21f31353402456a0208')
})
})
Expand Down
10 changes: 5 additions & 5 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 'uint8-util'
import { hash } from 'uint8-util'
import test from 'tape'
import createTorrent from '../index.js'

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

sha1(parsedTorrent.infoBuffer, hash => {
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
t.equals(hash, 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
})
})
Expand Down Expand Up @@ -114,7 +114,7 @@ test('create multi file torrent', t => {
t.deepEquals(parsedTorrent.pieces, [
'1f74648e50a6a6708ec54ab327a163d5536b7ced'
])
sha1(parsedTorrent.infoBuffer, hash => {
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
t.equals(hash, '80562f38656b385ea78959010e51a2cc9db41ea0')
})
})
Expand Down Expand Up @@ -169,7 +169,7 @@ test('create multi file torrent with nested directories', t => {
t.deepEquals(parsedTorrent.pieces, [
'47972f2befaee58b6f3860cd39bd56cb33a488f0'
])
sha1(parsedTorrent.infoBuffer, hash => {
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
t.equals(hash, '427887e9c03e123f9c8458b1947090edf1c75baa')
})
})
Expand Down Expand Up @@ -230,7 +230,7 @@ test('create multi file torrent with array of paths', t => {
t.deepEquals(parsedTorrent.pieces, [
'1c4e1ba6da4d771ff82025d7cf76e8c368c6c3dd'
])
sha1(parsedTorrent.infoBuffer, hash => {
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
t.equals(hash, 'df25a2959378892f6ddaf4a2d7e75174e09878bb')
})
})
Expand Down
4 changes: 2 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 'uint8-util'
import { hash } from 'uint8-util'
import test from 'tape'
import createTorrent from '../index.js'

Expand Down Expand Up @@ -65,7 +65,7 @@ test('create multi file torrent with array of mixed types', t => {
t.deepEquals(parsedTorrent.pieces, [
'9ad893bb9aeca601a0fab4ba85bd4a4c18b630e3'
])
sha1(parsedTorrent.infoBuffer, hash => {
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
t.equals(hash, 'bad3f8ea0d1d8a55c18a039dd464f1078f83dba2')
})
})
Expand Down
6 changes: 3 additions & 3 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 'uint8-util'
import { hash } from 'uint8-util'
import test from 'tape'

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

t.deepEquals(parsedTorrent.pieces, ['799c11e348d39f1704022b8354502e2f81f3c037'])
sha1(parsedTorrent.infoBuffer, hash => {
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
t.equals(hash, 'b4dfce1f956f720c928535ded617d07696a819ef', 'mktorrent hash with no source')
})
})
Expand Down Expand Up @@ -73,7 +73,7 @@ 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'])
sha1(parsedTorrent.infoBuffer, hash => {
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
t.equals(hash, 'a9499b56289356a3d5b8636387deb83709b8fa42', 'mktorrent run with -s SOURCE')
})
})
Expand Down
6 changes: 3 additions & 3 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 'uint8-util'
import { hash } from 'uint8-util'
import test from 'tape'
import createTorrent from '../index.js'

Expand Down Expand Up @@ -57,7 +57,7 @@ test('create single file torrent from a stream', t => {
'56dcc242d03293e9446cf5e457d8eb3d9588fd90',
'c698de9b0dad92980906c026d8c1408fa08fe4ec'
])
sha1(parsedTorrent.infoBuffer, hash => {
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
t.equals(hash, 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
})
})
Expand Down Expand Up @@ -112,7 +112,7 @@ test('create multi file torrent with streams', t => {
t.deepEquals(parsedTorrent.pieces, [
'1f74648e50a6a6708ec54ab327a163d5536b7ced'
])
sha1(parsedTorrent.infoBuffer, hash => {
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
t.equals(hash, '80562f38656b385ea78959010e51a2cc9db41ea0')
})
})
Expand Down

0 comments on commit a88e7d1

Please sign in to comment.