Files
web3.js/test/eth.abi.encodeFunctionSignature.js
T
Samuel Furter 0ef6ee8e99 ABI v2 added (#1820)
* wip adding new decoder

* improved web3.js readme

* reworked decodeParameters

* bumped ethers version

* fixed tests

* fixed decode Log tests

* fixed decoding tests

* fixed encoding tests

* removed old encoder/decoder

* fixed all tests

* updated ether-js

* struct encoding and decoding

* decoding index params separate

* improved log decoding for indexed paramaters

* removed lock files

* fixed tests

* fixed test

* add components to contract

* Added some struct tests

* Finished decodeParameters testing

* Finished encodeParameter and encodeParameters tests

* fixed ABICoder decodeParameters

* fixed ABICoder decodeParameters

* removed console.log

* removed out commented code

* console.log removed

* decodeParameter in ABICoder fixed

* codestyle improvement

* new version of ethersjs abiCoder implemented and tested

* testcases added for structs

* package-lock removed

* encodeParameters extended for simplified format

* codestyle improvement

* simplified types added to decodeParameters

* types mapping fixed

* Started with updating of the documentation for encoding and decoding of parameters

* new abi lib tested and documentation updated

* decodeParameter/s tested and documentation updated

* package-locks fixed

* web3-eth-abi package version fixed

* gitignore updated

* web3.js removed

* modified package.lock

* documentation updated
2018-08-07 14:52:04 +02:00

60 lines
1.2 KiB
JavaScript

var chai = require('chai');
var assert = chai.assert;
var Abi = require('../packages/web3-eth-abi');
var tests = [{
params: [{
name: 'myMethod',
type: 'function',
inputs: [{
type: 'uint256',
name: 'myNumber'
},{
type: 'string',
name: 'myString'
}]
}],
result: '0x24ee0097'
},{
params: [{
name: 'myMethod',
type: 'function',
inputs: [{
type: 'string',
name: 'myNumber'
},{
type: 'bytes8',
name: 'myString'
}]
}],
result: '0x27b00c93'
},{
params: [{
name: 'Somthing',
type: 'function',
inputs: [{
type: 'uint16',
name: 'myNumber'
},{
type: 'bytes',
name: 'myString'
}]
}],
result: '0x724ff7a1'
},{
params: [{
name: 'something',
type: 'function',
inputs: []
}],
result: '0xa7a0d537'
}];
describe('encodeFunctionSignature', function () {
tests.forEach(function (test) {
it('should convert correctly', function () {
assert.equal(Abi.encodeFunctionSignature.apply(Abi, test.params), test.result);
});
});
});