|
1 | 1 | var test = require('tape')
|
2 | 2 | var timingSafeEqual = require('timing-safe-equal/browser')
|
| 3 | +var bufferShims = require('buffer-shims') |
3 | 4 | test('timingSafeEqual', function (t) {
|
4 | 5 | t.plan(5)
|
5 | 6 | t.strictEqual(
|
6 |
| - timingSafeEqual(Buffer.from('foo'), Buffer.from('foo')), |
| 7 | + timingSafeEqual(bufferShims.from('foo'), bufferShims.from('foo')), |
7 | 8 | true,
|
8 | 9 | 'should consider equal strings to be equal'
|
9 | 10 | )
|
10 | 11 |
|
11 | 12 | t.strictEqual(
|
12 |
| - timingSafeEqual(Buffer.from('foo'), Buffer.from('bar')), |
| 13 | + timingSafeEqual(bufferShims.from('foo'), bufferShims.from('bar')), |
13 | 14 | false,
|
14 | 15 | 'should consider unequal strings to be unequal'
|
15 | 16 | )
|
16 | 17 |
|
17 | 18 | t.throws(function () {
|
18 |
| - timingSafeEqual(Buffer.from([1, 2, 3]), Buffer.from([1, 2])) |
| 19 | + timingSafeEqual(bufferShims.from([1, 2, 3]), bufferShims.from([1, 2])) |
19 | 20 | }, 'should throw when given buffers with different lengths')
|
20 | 21 |
|
21 | 22 | t.throws(function () {
|
22 |
| - timingSafeEqual('not a buffer', Buffer.from([1, 2])) |
| 23 | + timingSafeEqual('not a buffer', bufferShims.from([1, 2])) |
23 | 24 | }, 'should throw if the first argument is not a buffer')
|
24 | 25 |
|
25 | 26 | t.throws(function () {
|
26 |
| - timingSafeEqual(Buffer.from([1, 2]), 'not a buffer') |
| 27 | + timingSafeEqual(bufferShims.from([1, 2]), 'not a buffer') |
27 | 28 | }, 'should throw if the second argument is not a buffer')
|
28 | 29 | })
|
0 commit comments