2015-04-22 06:55:24 +00:00
|
|
|
var chai = require('chai');
|
|
|
|
var assert = chai.assert;
|
|
|
|
var coder = require('../lib/solidity/coder');
|
|
|
|
|
|
|
|
var tests = [
|
2015-04-24 08:34:59 +00:00
|
|
|
{ type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000001', expected: 1},
|
|
|
|
{ type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000010', expected: 16},
|
|
|
|
{ type: 'int', value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: -1},
|
|
|
|
{ type: 'bytes32', value: '6761766f66796f726b0000000000000000000000000000000000000000000000', expected: 'gavofyork'},
|
|
|
|
{ type: 'bytes', value: '0000000000000000000000000000000000000000000000000000000000000009' +
|
|
|
|
'6761766f66796f726b0000000000000000000000000000000000000000000000', expected: 'gavofyork'}
|
2015-04-22 06:55:24 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
describe('lib/solidity/coder', function () {
|
2015-04-22 07:26:00 +00:00
|
|
|
describe('decodeParam', function () {
|
2015-04-22 06:55:24 +00:00
|
|
|
tests.forEach(function (test) {
|
|
|
|
it('should turn ' + test.value + ' to ' + test.expected, function () {
|
|
|
|
assert.equal(coder.decodeParam(test.type, test.value), test.expected);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|