mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-24 12:08:22 +00:00
61 lines
1.3 KiB
JavaScript
61 lines
1.3 KiB
JavaScript
|
var chai = require('chai');
|
||
|
var assert = chai.assert;
|
||
|
var Web3 = require('../src/index.js');
|
||
|
var web3 = new Web3();
|
||
|
|
||
|
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(web3.eth.abi.encodeFunctionSignature.apply(web3.eth.abi, test.params), test.result);
|
||
|
});
|
||
|
});
|
||
|
});
|