Skip to content

Commit

Permalink
Refactor buffer constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
noelyoo authored and dcousens committed Sep 19, 2018
1 parent e69c617 commit b5c0c42
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions test/constructor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ describe('BN.js/Constructor', function () {
// the Array code is able to handle Buffer
describe('with Buffer input', function () {
it('should not fail on empty Buffer', function () {
assert.equal(new BN(new Buffer(0)).toString(16), '0');
assert.equal(new BN(Buffer.alloc(0)).toString(16), '0');
});

it('should import/export big endian', function () {
assert.equal(new BN(new Buffer('010203', 'hex')).toString(16), '10203');
assert.equal(new BN(Buffer.from('010203', 'hex')).toString(16), '10203');
});

it('should import little endian', function () {
assert.equal(new BN(new Buffer('010203', 'hex'), 'le').toString(16), '30201');
assert.equal(new BN(Buffer.from('010203', 'hex'), 'le').toString(16), '30201');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/pummel/dh-group-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('BN.js/Slow DH test', function () {
var mont = BN.red(new BN(group.prime, 16));
var priv = new BN(group.priv, 16);
var multed = base.toRed(mont).redPow(priv).fromRed();
var actual = new Buffer(multed.toArray());
var actual = Buffer.from(multed.toArray());
assert.equal(actual.toString('hex'), group.pub);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/red-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ describe('BN.js/Reduction context', function () {
}
return bits;
}
var t = new Buffer('aff1651e4cd6036d57aa8b2a05ccf1a9d5a40166340ecbbdc55' +
var t = Buffer.from('aff1651e4cd6036d57aa8b2a05ccf1a9d5a40166340ecbbdc55' +
'be10b568aa0aa3d05ce9a2fcec9df8ed018e29683c6051cb83e' +
'46ce31ba4edb045356a8d0d80b', 'hex');
var g = new BN('5c7ff6b06f8f143fe8288433493e4769c4d988ace5be25a0e24809670' +
Expand Down

0 comments on commit b5c0c42

Please sign in to comment.