mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 11:38:12 +00:00
more tests for encoding and decoding solidity params
This commit is contained in:
parent
baed4c879d
commit
330b0da690
@ -32,6 +32,17 @@ describe('lib/solidity/coder', function () {
|
||||
'0000000000000000000000000000000000000000000000000000000000000001' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000002' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000003'});
|
||||
test({ type: 'bool', expected: true, value: '0000000000000000000000000000000000000000000000000000000000000001'});
|
||||
test({ type: 'bool', expected: false, value: '0000000000000000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'real', expected: new bn(1), value: '0000000000000000000000000000000100000000000000000000000000000000'});
|
||||
test({ type: 'real', expected: new bn(2.125), value: '0000000000000000000000000000000220000000000000000000000000000000'});
|
||||
test({ type: 'real', expected: new bn(8.5), value: '0000000000000000000000000000000880000000000000000000000000000000'});
|
||||
test({ type: 'real', expected: new bn(-1), value: 'ffffffffffffffffffffffffffffffff00000000000000000000000000000000'});
|
||||
test({ type: 'ureal', expected: new bn(1), value: '0000000000000000000000000000000100000000000000000000000000000000'});
|
||||
test({ type: 'ureal', expected: new bn(2.125), value: '0000000000000000000000000000000220000000000000000000000000000000'});
|
||||
test({ type: 'ureal', expected: new bn(8.5), value: '0000000000000000000000000000000880000000000000000000000000000000'});
|
||||
test({ type: 'address', expected: '0x407d73d8a49eeb85d32cf465507dd71d507100c1',
|
||||
value: '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1'});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -15,6 +15,8 @@ describe('lib/solidity/coder', function () {
|
||||
test({ type: 'int', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001'});
|
||||
test({ type: 'int', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'});
|
||||
test({ type: 'int', value: 0.1, expected: '0000000000000000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'int', value: 3.9, expected: '0000000000000000000000000000000000000000000000000000000000000003'});
|
||||
test({ type: 'int256', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001'});
|
||||
test({ type: 'int256', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int256', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'});
|
||||
@ -29,6 +31,17 @@ describe('lib/solidity/coder', function () {
|
||||
'0000000000000000000000000000000000000000000000000000000000000001' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000002' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000003'});
|
||||
test({ type: 'bool', value: true, expected: '0000000000000000000000000000000000000000000000000000000000000001'});
|
||||
test({ type: 'bool', value: false, expected: '0000000000000000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'address', value: '0x407d73d8a49eeb85d32cf465507dd71d507100c1',
|
||||
expected: '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1'});
|
||||
test({ type: 'real', value: 1, expected: '0000000000000000000000000000000100000000000000000000000000000000'});
|
||||
test({ type: 'real', value: 2.125, expected: '0000000000000000000000000000000220000000000000000000000000000000'});
|
||||
test({ type: 'real', value: 8.5, expected: '0000000000000000000000000000000880000000000000000000000000000000'});
|
||||
test({ type: 'real', value: -1, expected: 'ffffffffffffffffffffffffffffffff00000000000000000000000000000000'});
|
||||
test({ type: 'ureal', value: 1, expected: '0000000000000000000000000000000100000000000000000000000000000000'});
|
||||
test({ type: 'ureal', value: 2.125, expected: '0000000000000000000000000000000220000000000000000000000000000000'});
|
||||
test({ type: 'ureal', value: 8.5, expected: '0000000000000000000000000000000880000000000000000000000000000000'});
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user