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