Skip to content

Commit a88e7d1

Browse files
fix(deps): update dependency uint8-util to v2 (#192)
* 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>
1 parent a320137 commit a88e7d1

7 files changed

Lines changed: 18 additions & 18 deletions

File tree

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import junk from 'junk'
88
import joinIterator from 'join-async-iterator'
99
import parallel from 'run-parallel'
1010
import queueMicrotask from 'queue-microtask'
11-
import { sha1 } from 'uint8-util'
11+
import { hash } from 'uint8-util'
1212
import 'fast-readable-async-iterator'
1313

1414
import getFiles from './get-files.js' // browser exclude
@@ -225,7 +225,7 @@ async function getPieceList (files, pieceLength, estimatedTorrentLength, opts, c
225225
const i = pieceNum
226226
++pieceNum
227227
if (++remainingHashes < MAX_OUTSTANDING_HASHES) resolve()
228-
sha1(chunk, hash => {
228+
hash(chunk, 'hex').then(hash => {
229229
pieces[i] = hash
230230
--remainingHashes
231231
hashedLength += chunk.length

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"piece-length": "^2.0.1",
3030
"queue-microtask": "^1.2.3",
3131
"run-parallel": "^1.2.0",
32-
"uint8-util": "^1.0.1"
32+
"uint8-util": "^2.1.4"
3333
},
3434
"devDependencies": {
3535
"@webtorrent/semantic-release-config": "1.0.8",

test/buffer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import createTorrent from '../index.js'
22
import parseTorrent from 'parse-torrent'
33
import path from 'path'
4-
import { sha1 } from 'uint8-util'
4+
import { hash } from 'uint8-util'
55
import test from 'tape'
66

77
test('create nested torrent with array of buffers', t => {
@@ -42,7 +42,7 @@ test('create nested torrent with array of buffers', t => {
4242
t.deepEquals(parsedTorrent.pieces, [
4343
'5bf1fd927dfb8679496a2e6cf00cbe50c1c87145'
4444
])
45-
sha1(parsedTorrent.infoBuffer, hash => {
45+
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
4646
t.equals(hash, '8fa3c08e640db9576156b21f31353402456a0208')
4747
})
4848
})

test/fs.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fixtures from 'webtorrent-fixtures'
22
import parseTorrent from 'parse-torrent'
33
import path from 'path'
4-
import { sha1 } from 'uint8-util'
4+
import { hash } from 'uint8-util'
55
import test from 'tape'
66
import createTorrent from '../index.js'
77

@@ -54,7 +54,7 @@ test('create single file torrent', t => {
5454
'c698de9b0dad92980906c026d8c1408fa08fe4ec'
5555
])
5656

57-
sha1(parsedTorrent.infoBuffer, hash => {
57+
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
5858
t.equals(hash, 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
5959
})
6060
})
@@ -114,7 +114,7 @@ test('create multi file torrent', t => {
114114
t.deepEquals(parsedTorrent.pieces, [
115115
'1f74648e50a6a6708ec54ab327a163d5536b7ced'
116116
])
117-
sha1(parsedTorrent.infoBuffer, hash => {
117+
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
118118
t.equals(hash, '80562f38656b385ea78959010e51a2cc9db41ea0')
119119
})
120120
})
@@ -169,7 +169,7 @@ test('create multi file torrent with nested directories', t => {
169169
t.deepEquals(parsedTorrent.pieces, [
170170
'47972f2befaee58b6f3860cd39bd56cb33a488f0'
171171
])
172-
sha1(parsedTorrent.infoBuffer, hash => {
172+
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
173173
t.equals(hash, '427887e9c03e123f9c8458b1947090edf1c75baa')
174174
})
175175
})
@@ -230,7 +230,7 @@ test('create multi file torrent with array of paths', t => {
230230
t.deepEquals(parsedTorrent.pieces, [
231231
'1c4e1ba6da4d771ff82025d7cf76e8c368c6c3dd'
232232
])
233-
sha1(parsedTorrent.infoBuffer, hash => {
233+
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
234234
t.equals(hash, 'df25a2959378892f6ddaf4a2d7e75174e09878bb')
235235
})
236236
})

test/mixed.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fixtures from 'webtorrent-fixtures'
22
import fs from 'fs'
33
import parseTorrent from 'parse-torrent'
44
import path from 'path'
5-
import { sha1 } from 'uint8-util'
5+
import { hash } from 'uint8-util'
66
import test from 'tape'
77
import createTorrent from '../index.js'
88

@@ -65,7 +65,7 @@ test('create multi file torrent with array of mixed types', t => {
6565
t.deepEquals(parsedTorrent.pieces, [
6666
'9ad893bb9aeca601a0fab4ba85bd4a4c18b630e3'
6767
])
68-
sha1(parsedTorrent.infoBuffer, hash => {
68+
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
6969
t.equals(hash, 'bad3f8ea0d1d8a55c18a039dd464f1078f83dba2')
7070
})
7171
})

test/source.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { join } from 'path'
22
import fixtures from 'webtorrent-fixtures'
33
import parseTorrent from 'parse-torrent'
4-
import { sha1 } from 'uint8-util'
4+
import { hash } from 'uint8-util'
55
import test from 'tape'
66

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

3838
t.deepEquals(parsedTorrent.pieces, ['799c11e348d39f1704022b8354502e2f81f3c037'])
39-
sha1(parsedTorrent.infoBuffer, hash => {
39+
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
4040
t.equals(hash, 'b4dfce1f956f720c928535ded617d07696a819ef', 'mktorrent hash with no source')
4141
})
4242
})
@@ -73,7 +73,7 @@ test('verify info-hash an additional source attribute set on the info dict (a wa
7373
t.equal(parsedTorrent.pieceLength, 262144)
7474

7575
t.deepEquals(parsedTorrent.pieces, ['799c11e348d39f1704022b8354502e2f81f3c037'])
76-
sha1(parsedTorrent.infoBuffer, hash => {
76+
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
7777
t.equals(hash, 'a9499b56289356a3d5b8636387deb83709b8fa42', 'mktorrent run with -s SOURCE')
7878
})
7979
})

test/stream.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fixtures from 'webtorrent-fixtures'
22
import fs from 'fs'
33
import parseTorrent from 'parse-torrent'
44
import path from 'path'
5-
import { sha1 } from 'uint8-util'
5+
import { hash } from 'uint8-util'
66
import test from 'tape'
77
import createTorrent from '../index.js'
88

@@ -57,7 +57,7 @@ test('create single file torrent from a stream', t => {
5757
'56dcc242d03293e9446cf5e457d8eb3d9588fd90',
5858
'c698de9b0dad92980906c026d8c1408fa08fe4ec'
5959
])
60-
sha1(parsedTorrent.infoBuffer, hash => {
60+
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
6161
t.equals(hash, 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
6262
})
6363
})
@@ -112,7 +112,7 @@ test('create multi file torrent with streams', t => {
112112
t.deepEquals(parsedTorrent.pieces, [
113113
'1f74648e50a6a6708ec54ab327a163d5536b7ced'
114114
])
115-
sha1(parsedTorrent.infoBuffer, hash => {
115+
hash(parsedTorrent.infoBuffer, 'hex').then(hash => {
116116
t.equals(hash, '80562f38656b385ea78959010e51a2cc9db41ea0')
117117
})
118118
})

0 commit comments

Comments
 (0)