Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #56 from fanatid/fix/bufferToHex
Browse files Browse the repository at this point in the history
fix bufferToHex
  • Loading branch information
wanderer authored Nov 8, 2016
2 parents ed316cf + b51bbb2 commit 8eb4dc1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 0 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ exports.bufferToInt = function (buf) {
*/
exports.bufferToHex = function (buf) {
buf = exports.toBuffer(buf)
if (buf.length === 0) {
return 0
}

return '0x' + buf.toString('hex')
}

Expand Down
5 changes: 5 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ describe('bufferToHex', function () {
var hex = ethUtils.bufferToHex(buf)
assert.equal(hex, '0x5b9ac8')
})
it('empty buffer', function () {
var buf = Buffer.alloc(0)
var hex = ethUtils.bufferToHex(buf)
assert.strictEqual(hex, '0x')
})
})

describe('intToHex', function () {
Expand Down

0 comments on commit 8eb4dc1

Please sign in to comment.