Skip to content

Commit d6eb2f0

Browse files
committed
fix(index): set default hashAlgorithm
omfg config really needs to be more centralized soon
1 parent 2318a8f commit d6eb2f0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Diff for: lib/entry-index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function insert (cache, key, digest, opts) {
3636
const entry = {
3737
key: key,
3838
digest: digest,
39-
hashAlgorithm: opts.hashAlgorithm,
39+
hashAlgorithm: opts.hashAlgorithm || 'sha512',
4040
time: +(new Date()),
4141
metadata: opts.metadata
4242
}

Diff for: test/index.insert.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ test('inserts additional entries into existing key', function (t) {
6363
t.deepEqual(entries, [{
6464
key: KEY,
6565
digest: DIGEST,
66+
hashAlgorithm: 'sha512',
6667
metadata: 1
6768
}, {
6869
key: KEY,
6970
digest: DIGEST,
71+
hashAlgorithm: 'sha512',
7072
metadata: 2
7173
}], 'all entries present')
7274
})
@@ -91,7 +93,8 @@ test('separates entries even if one is corrupted', function (t) {
9193
delete entry.time
9294
t.deepEqual(entry, {
9395
key: KEY,
94-
digest: DIGEST
96+
digest: DIGEST,
97+
hashAlgorithm: 'sha512'
9598
}, 'new entry unaffected by corruption')
9699
})
97100
})
@@ -108,6 +111,7 @@ test('optional arbitrary metadata', function (t) {
108111
t.deepEqual(entry, {
109112
key: KEY,
110113
digest: DIGEST,
114+
hashAlgorithm: 'sha512',
111115
metadata: metadata
112116
}, 'entry includes inserted metadata')
113117
})
@@ -155,7 +159,8 @@ test('path-breaking characters', function (t) {
155159
delete entry.time
156160
t.deepEqual(entry, {
157161
key: newKey,
158-
digest: DIGEST
162+
digest: DIGEST,
163+
hashAlgorithm: 'sha512'
159164
}, 'entry exists and matches original key with invalid chars')
160165
})
161166
})
@@ -175,7 +180,8 @@ test('extremely long keys', function (t) {
175180
delete entry.time
176181
t.deepEqual(entry, {
177182
key: newKey,
178-
digest: DIGEST
183+
digest: DIGEST,
184+
hashAlgorithm: 'sha512'
179185
}, 'entry exists in spite of INCREDIBLY LONG key')
180186
})
181187
})

0 commit comments

Comments
 (0)