mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 19:48:13 +00:00
web3.sha3 returns string with hex prefix
This commit is contained in:
parent
9642608f51
commit
dd875e06aa
@ -96,7 +96,11 @@ Web3.prototype.isAddress = utils.isAddress;
|
|||||||
Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
|
Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
|
||||||
Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
|
Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
|
||||||
Web3.prototype.isIBAN = utils.isIBAN;
|
Web3.prototype.isIBAN = utils.isIBAN;
|
||||||
Web3.prototype.sha3 = sha3;
|
|
||||||
|
|
||||||
|
Web3.prototype.sha3 = function(msg) {
|
||||||
|
return '0x' + sha3(msg);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms direct icap to address
|
* Transforms direct icap to address
|
||||||
|
18
test/web3.sha3.js
Normal file
18
test/web3.sha3.js
Normal 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'));
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user