Files
web3.js/test/eth.abi.encodeFunctionCall.js
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

53 lines
1.9 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'
}]
}, ['2345675643', 'Hello!%']],
result: '0x24ee0097000000000000000000000000000000000000000000000000000000008bd02b7b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000748656c6c6f212500000000000000000000000000000000000000000000000000'
},{
params: [{
name: 'myOtherMethod',
type: 'function',
inputs: [{
type: 'uint16',
name: 'myNumberdd'
},{
type: 'bytes32',
name: 'myBytes'
}]
}, [2323, '0x234567432145678543213456']],
result: '0xed6d6f8500000000000000000000000000000000000000000000000000000000000009132345674321456785432134560000000000000000000000000000000000000000'
},{
params: [{
name: 'myMethod',
type: 'function',
inputs: [{
type: 'uint256',
name: 'myNumber'
},{
type: 'bytes',
name: 'myBytes'
}]
}, ['2345675643', '0x23456743214567854321ffffdddddd']],
result: '0x4c6a9980000000000000000000000000000000000000000000000000000000008bd02b7b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000f23456743214567854321ffffdddddd0000000000000000000000000000000000'
}];
describe('encodeFunctionCall', function () {
tests.forEach(function (test) {
it('should convert correctly', function () {
assert.equal(Abi.encodeFunctionCall.apply(Abi, test.params), test.result);
});
});
});