Skip to content

Commit

Permalink
coder.encodeParam, coder.decodeParam tests template
Browse files Browse the repository at this point in the history
  • Loading branch information
debris committed Apr 22, 2015
1 parent 983e4b1 commit 888a970
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/coder.decodeParam.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var chai = require('chai');
var assert = chai.assert;
var coder = require('../lib/solidity/coder');

var tests = [
{ type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000001', expected: 1},
{ type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000010', expected: 16},
{ type: 'int', value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: -1}
];

describe('lib/solidity/coder', function () {
describe('encodeParam', function () {
tests.forEach(function (test) {
it('should turn ' + test.value + ' to ' + test.expected, function () {
assert.equal(coder.decodeParam(test.type, test.value), test.expected);
});
});
});
});

20 changes: 20 additions & 0 deletions test/coder.encodeParam.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var chai = require('chai');
var assert = chai.assert;
var coder = require('../lib/solidity/coder');

var tests = [
{ type: 'int', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001'},
{ type: 'int', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010'},
{ type: 'int', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}
];

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);
});
});
});
});

0 comments on commit 888a970

Please sign in to comment.