Merge branch 'develop' of https://github.com/ethereum/ethereum.js into develop

This commit is contained in:
Marek Kotewicz 2015-05-07 20:47:11 +02:00
commit 22ca9b02e7
2 changed files with 55 additions and 17 deletions

View File

@ -72,7 +72,7 @@ var inputTransactionFormatter = function (options){
delete options.code;
}
['gasPrice', 'gas', 'value'].filter(function (key) {
['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
return options[key] !== undefined;
}).forEach(function(key){
options[key] = utils.fromDecimal(options[key]);

View File

@ -3,24 +3,62 @@ var assert = chai.assert;
var formatters = require('../lib/web3/formatters.js');
var BigNumber = require('bignumber.js');
var tests = [{
input: {
data: '0x34234bf23bf4234',
value: new BigNumber(100),
from: '0x00000',
to: '0x00000',
nonce: 1000,
gas: 1000,
gasPrice: new BigNumber(1000)
},
result: {
data: '0x34234bf23bf4234',
value: '0x64',
from: '0x00000',
to: '0x00000',
nonce: '0x3e8',
gas: '0x3e8',
gasPrice: '0x3e8'
}
},{
input: {
data: '0x34234bf23bf4234',
value: new BigNumber(100),
from: '0x00000',
to: '0x00000',
},
result: {
data: '0x34234bf23bf4234',
value: '0x64',
from: '0x00000',
to: '0x00000',
}
},{
input: {
data: '0x34234bf23bf4234',
value: new BigNumber(100),
from: '0x00000',
to: '0x00000',
gas: '1000',
gasPrice: new BigNumber(1000)
},
result: {
data: '0x34234bf23bf4234',
value: '0x64',
from: '0x00000',
to: '0x00000',
gas: '0x3e8',
gasPrice: '0x3e8'
}
}];
describe('formatters', function () {
describe('inputTransactionFormatter', function () {
it('should return the correct value', function () {
assert.deepEqual(formatters.inputTransactionFormatter({
data: '0x34234bf23bf4234',
value: new BigNumber(100),
from: '0x00000',
to: '0x00000',
gas: 1000,
gasPrice: new BigNumber(1000)
}), {
data: '0x34234bf23bf4234',
value: '0x64',
from: '0x00000',
to: '0x00000',
gas: '0x3e8',
gasPrice: '0x3e8'
tests.forEach(function(test){
it('should return the correct value', function () {
assert.deepEqual(formatters.inputTransactionFormatter(test.input), test.result);
});
});
});