aboutsummaryrefslogtreecommitdiff
path: root/node_modules/sha.js/test/hash.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/sha.js/test/hash.js')
-rw-r--r--node_modules/sha.js/test/hash.js39
1 files changed, 14 insertions, 25 deletions
diff --git a/node_modules/sha.js/test/hash.js b/node_modules/sha.js/test/hash.js
index 2f376b4d9..5fa000d5a 100644
--- a/node_modules/sha.js/test/hash.js
+++ b/node_modules/sha.js/test/hash.js
@@ -1,73 +1,62 @@
-var hexpp = require('../hexpp').defaults({ bigendian: false })
var tape = require('tape')
var Hash = require('../hash')
-
var hex = '0A1B2C3D4E5F6G7H'
function equal (t, a, b) {
t.equal(a.length, b.length)
-
- for (var i = 0; i < a.length; i++) {
- t.equal(a[i], b[i])
- }
+ t.equal(a.toString('hex'), b.toString('hex'))
}
-var hexBuf = new Buffer([48, 65, 49, 66, 50, 67, 51, 68, 52, 69, 53, 70, 54, 71, 55, 72])
+var hexBuf = Buffer.from('0A1B2C3D4E5F6G7H', 'utf8')
var count16 = {
strings: ['0A1B2C3D4E5F6G7H'],
buffers: [
hexBuf,
- new Buffer([ 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128])
+ Buffer.from('80000000000000000000000000000080', 'hex')
]
}
var empty = {
strings: [''],
buffers: [
- new Buffer([ 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ])
+ Buffer.from('80000000000000000000000000000000', 'hex')
]
}
var multi = {
- strings: ['abcd', 'efhijk', 'lmnopq'],
- buffers: [
- new Buffer('abcdefhijklmnopq', 'ascii'),
- new Buffer([128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128])
- ]
- }
+ strings: ['abcd', 'efhijk', 'lmnopq'],
+ buffers: [
+ Buffer.from('abcdefhijklmnopq', 'ascii'),
+ Buffer.from('80000000000000000000000000000080', 'hex')
+ ]
+}
var long = {
strings: [hex + hex],
buffers: [
hexBuf,
hexBuf,
- new Buffer([128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0])
+ Buffer.from('80000000000000000000000000000100', 'hex')
]
}
function makeTest (name, data) {
tape(name, function (t) {
-
var h = new Hash(16, 8)
- var hash = new Buffer(20)
+ var hash = Buffer.alloc(20)
var n = 2
var expected = data.buffers.slice()
// t.plan(expected.length + 1)
h._update = function (block) {
var e = expected.shift()
-
- console.log('---block---')
- console.log(hexpp(block), block.length)
- console.log('---e---')
- console.log(hexpp(e), block.length)
- console.log(block)
equal(t, block, e)
if (n < 0) {
throw new Error('expecting only 2 calls to _update')
}
-
+ }
+ h._hash = function () {
return hash
}