From 983e4b108267c2d6620c1ab5c49987c1421732e8 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 22 Apr 2015 08:41:30 +0200 Subject: [PATCH] removed signature.js --- lib/web3/signature.js | 42 ------------------------------------- test/signature.js | 48 ------------------------------------------- 2 files changed, 90 deletions(-) delete mode 100644 lib/web3/signature.js delete mode 100644 test/signature.js diff --git a/lib/web3/signature.js b/lib/web3/signature.js deleted file mode 100644 index 44ecf1f31a2..00000000000 --- a/lib/web3/signature.js +++ /dev/null @@ -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 . -*/ -/** @file signature.js - * @authors: - * Marek Kotewicz - * @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 -}; - diff --git a/test/signature.js b/test/signature.js deleted file mode 100644 index 709f662fd5b..00000000000 --- a/test/signature.js +++ /dev/null @@ -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); - }); - }); - }); -}); -