mirror of https://github.com/status-im/web3.js.git
removed signature.js
This commit is contained in:
parent
e9107367fd
commit
983e4b1082
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
ethereum.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ethereum.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/** @file signature.js
|
||||
* @authors:
|
||||
* Marek Kotewicz <marek@ethdev.com>
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var web3 = require('../web3');
|
||||
var c = require('../utils/config');
|
||||
|
||||
/// @param function name for which we want to get signature
|
||||
/// @returns signature of function with given name
|
||||
var functionSignatureFromAscii = function (name) {
|
||||
return web3.sha3(web3.fromAscii(name)).slice(0, 2 + c.ETH_SIGNATURE_LENGTH * 2);
|
||||
};
|
||||
|
||||
/// @param event name for which we want to get signature
|
||||
/// @returns signature of event with given name
|
||||
var eventSignatureFromAscii = function (name) {
|
||||
return web3.sha3(web3.fromAscii(name));
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
functionSignatureFromAscii: functionSignatureFromAscii,
|
||||
eventSignatureFromAscii: eventSignatureFromAscii
|
||||
};
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
var chai = require('chai');
|
||||
var assert = chai.assert;
|
||||
var utils = require('../lib/utils/utils');
|
||||
var FakeHttpProvider = require('./helpers/FakeHttpProvider');
|
||||
var signature = require('../lib/web3/signature');
|
||||
var web3 = require('../index');
|
||||
|
||||
var tests = [{
|
||||
method: 'functionSignatureFromAscii',
|
||||
call: 'web3_sha3',
|
||||
request: 'multiply',
|
||||
formattedRequest: utils.fromAscii('multiply'),
|
||||
result: '0x255d31552d29a21e93334e96055c6dca7cd329f5420ae74ec166d0c47f9f9843',
|
||||
formattedResult: '0x255d3155'
|
||||
},{
|
||||
method: 'eventSignatureFromAscii',
|
||||
call: 'web3_sha3',
|
||||
request: 'multiply',
|
||||
formattedRequest: utils.fromAscii('multiply'),
|
||||
result: '0x255d31552d29a21e93334e96055c6dca7cd329f5420ae74ec166d0c47f9f9843',
|
||||
formattedResult: '0x255d31552d29a21e93334e96055c6dca7cd329f5420ae74ec166d0c47f9f9843'
|
||||
}];
|
||||
|
||||
describe('lib/web3/signature', function () {
|
||||
tests.forEach(function (test, index) {
|
||||
describe(test.method, function () {
|
||||
it('should properly format and return signature of solidity functioni ' + index, function () {
|
||||
|
||||
// given
|
||||
var provider = new FakeHttpProvider();
|
||||
web3.setProvider(provider);
|
||||
provider.injectResult(test.result);
|
||||
provider.injectValidation(function (payload) {
|
||||
assert.equal(payload.method, test.call);
|
||||
assert.equal(payload.jsonrpc, '2.0');
|
||||
assert.equal(payload.params[0], test.formattedRequest);
|
||||
});
|
||||
|
||||
// when
|
||||
var result = signature[test.method].call(null, test.request);
|
||||
|
||||
// then
|
||||
assert.equal(result, test.formattedResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue