Skip to content

Commit 5d5a8d8

Browse files
committed
tests: compare hex, not byte-by-byte (easier debugging)
1 parent 678c338 commit 5d5a8d8

File tree

3 files changed

+6
-44
lines changed

3 files changed

+6
-44
lines changed

hexpp.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/hash.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,34 @@
1-
var hexpp = require('../hexpp').defaults({ bigendian: false })
21
var tape = require('tape')
32
var Hash = require('../hash')
43

54
var hex = '0A1B2C3D4E5F6G7H'
65

76
function equal (t, a, b) {
87
t.equal(a.length, b.length)
9-
10-
for (var i = 0; i < a.length; i++) {
11-
t.equal(a[i], b[i])
12-
}
8+
t.equal(a.toString('hex'), b.toString('hex'))
139
}
1410

15-
var hexBuf = new Buffer([48, 65, 49, 66, 50, 67, 51, 68, 52, 69, 53, 70, 54, 71, 55, 72])
11+
var hexBuf = new Buffer('0A1B2C3D4E5F6G7H', 'utf8')
1612
var count16 = {
1713
strings: ['0A1B2C3D4E5F6G7H'],
1814
buffers: [
1915
hexBuf,
20-
new Buffer([128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128])
16+
new Buffer('80000000000000000000000000000080', 'hex')
2117
]
2218
}
2319

2420
var empty = {
2521
strings: [''],
2622
buffers: [
27-
new Buffer([ 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ])
23+
new Buffer('80000000000000000000000000000000', 'hex')
2824
]
2925
}
3026

3127
var multi = {
3228
strings: ['abcd', 'efhijk', 'lmnopq'],
3329
buffers: [
3430
new Buffer('abcdefhijklmnopq', 'ascii'),
35-
new Buffer([128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128])
31+
new Buffer('80000000000000000000000000000080', 'hex')
3632
]
3733
}
3834

@@ -41,7 +37,7 @@ var long = {
4137
buffers: [
4238
hexBuf,
4339
hexBuf,
44-
new Buffer([128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0])
40+
new Buffer('80000000000000000000000000000100', 'hex')
4541
]
4642
}
4743

@@ -56,12 +52,6 @@ function makeTest (name, data) {
5652

5753
h._update = function (block) {
5854
var e = expected.shift()
59-
60-
console.log('---block---')
61-
console.log(hexpp(block), block.length)
62-
console.log('---e---')
63-
console.log(hexpp(e), block.length)
64-
console.log(block)
6555
equal(t, block, e)
6656

6757
if (n < 0) {

test/vectors.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ var tape = require('tape')
22
var vectors = require('hash-test-vectors')
33
// var from = require('bops/typedarray/from')
44
var Buffer = require('buffer').Buffer
5-
var hexpp = require('../hexpp')
65

76
var createHash = require('../')
87

@@ -14,7 +13,6 @@ function makeTest (alg, i, verbose) {
1413
console.log(v)
1514
console.log('VECTOR', i)
1615
console.log('INPUT', v.input)
17-
console.log(hexpp(new Buffer(v.input, 'base64')))
1816
console.log(new Buffer(v.input, 'base64').toString('hex'))
1917
}
2018

0 commit comments

Comments
 (0)