web3.sha3 returns string with hex prefix

This commit is contained in:
Martin 2016-03-04 00:47:05 +01:00
parent 9642608f51
commit dd875e06aa
2 changed files with 23 additions and 1 deletions

View File

@ -96,7 +96,11 @@ Web3.prototype.isAddress = utils.isAddress;
Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
Web3.prototype.isIBAN = utils.isIBAN;
Web3.prototype.sha3 = sha3;
Web3.prototype.sha3 = function(msg) {
return '0x' + sha3(msg);
};
/**
* Transforms direct icap to address

18
test/web3.sha3.js Normal file
View File

@ -0,0 +1,18 @@
var chai = require('chai');
var assert = chai.assert;
var Web3 = require('../index');
var sha3 = require('../lib/utils/sha3');
var web3 = new Web3();
var method = 'sha3';
describe('web3.sha3', function () {
it('should return sha3 with hex prefix', function() {
test1 = web3.sha3('test123');
test2 = web3.sha3('test(int)');
test3 = web3.sha3('sdffvkj');
assert.deepEqual(test1, '0x' + sha3('test123'));
assert.deepEqual(test2, '0x' + sha3('test(int)'));
assert.deepEqual(test3, '0x' + sha3('sdffvkj'));
});
});