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

fix bufferToHex #56

Merged
merged 1 commit into from
Nov 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

@wanderer wanderer Nov 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is causing the linter to fail and it doesn't seem to be doing anything

var hex = ethUtils.bufferToHex(buf)
assert.strictEqual(hex, '0x')
})
})

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