github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/js/src/solts/lib/solidity.test.ts (about) 1 import assert from 'assert'; 2 import { ABI } from '../../contracts/abi'; 3 import { getSize, libraryName, nameFromABI, sha3 } from './solidity'; 4 5 describe('abi helpers', function () { 6 it('should compute a valid method id', async function () { 7 assert.equal(sha3('baz(uint32,bool)').slice(0, 8), 'CDCD77C0'); 8 }); 9 10 it('should return the full function name with args', async function () { 11 const abi: ABI.Func = { 12 type: 'function', 13 name: 'baz', 14 stateMutability: 'pure', 15 inputs: [ 16 { 17 name: '1', 18 type: 'uint32', 19 }, 20 { 21 name: '2', 22 type: 'bool', 23 }, 24 ], 25 }; 26 assert.equal(nameFromABI(abi), 'baz(uint32,bool)'); 27 }); 28 29 it('should strip array size', () => { 30 assert.equal(getSize('uint[3]'), 3); 31 }); 32 33 it('should extract library name', () => { 34 assert.equal(libraryName('sol/Storage.sol:Storage'), 'Storage'); 35 }); 36 });