1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

Fix normalizeMsgData function to always return hex prefixed

This commit is contained in:
Dan Finlay 2017-03-06 16:33:33 -08:00
parent 26ea5993a9
commit e66e755766
2 changed files with 3 additions and 3 deletions

View File

@ -112,7 +112,7 @@ module.exports = class PersonalMessageManager extends EventEmitter{
try {
const stripped = ethUtil.stripHexPrefix(data)
if (stripped.match(hexRe)) {
return stripped
return ethUtil.addHexPrefix(stripped)
}
} catch (e) {
log.debug(`Message was not hex encoded, interpreting as utf8.`)

View File

@ -97,13 +97,13 @@ describe('Personal Message Manager', function() {
it('tolerates a hex prefix', function() {
var input = '0x12'
var output = messageManager.normalizeMsgData(input)
assert.equal(output, '12', 'un modified')
assert.equal(output, '0x12', 'un modified')
})
it('tolerates normal hex', function() {
var input = '12'
var output = messageManager.normalizeMsgData(input)
assert.equal(output, '12', 'adds prefix')
assert.equal(output, '0x12', 'adds prefix')
})
})