Skip to content

Commit 1f3d161

Browse files
axiccdetrio
authored andcommitted
Ensure hex is correctly translated to Buffer
1 parent 8657d37 commit 1f3d161

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tests/util.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ exports.verifyPostConditions = function (state, testData, t, cb) {
7878
var keyMap = {}
7979

8080
for (var key in testData) {
81-
var hash = utils.sha3(new Buffer(key, 'hex')).toString('hex')
81+
var hash = utils.sha3(new Buffer(utils.stripHexPrefix(key), 'hex')).toString('hex')
8282
hashedAccounts[hash] = testData[key]
8383
keyMap[hash] = key
8484
}
@@ -238,8 +238,7 @@ exports.fromDecimal = function (string) {
238238
* @return {Buffer}
239239
*/
240240
exports.fromAddress = function (hexString) {
241-
hexString = hexString.substring(2)
242-
return utils.setLength(new Buffer(new BN(hexString, 16).toArray()), 32)
241+
return utils.setLength(new Buffer(new BN(hexString.slice(2), 16).toArray()), 32)
243242
}
244243

245244
/**
@@ -248,7 +247,7 @@ exports.fromAddress = function (hexString) {
248247
* @return {Buffer}
249248
*/
250249
exports.toCodeHash = function (hexCode) {
251-
return utils.sha3(new Buffer(hexCode.substring(2), 'hex'))
250+
return utils.sha3(new Buffer(hexCode.slice(2), 'hex'))
252251
}
253252

254253
exports.makeBlockHeader = function (data) {

0 commit comments

Comments
 (0)