2015-03-22 08:43:07 +00:00
|
|
|
var chai = require('chai');
|
|
|
|
var assert = chai.assert;
|
2015-03-08 17:31:08 +00:00
|
|
|
var formatters = require('../lib/web3/formatters.js');
|
2015-02-26 14:54:49 +00:00
|
|
|
var BigNumber = require('bignumber.js');
|
|
|
|
|
2015-05-06 13:19:33 +00:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
|
2015-02-26 14:54:49 +00:00
|
|
|
describe('formatters', function () {
|
|
|
|
describe('inputTransactionFormatter', function () {
|
2015-05-06 13:19:33 +00:00
|
|
|
tests.forEach(function(test){
|
|
|
|
it('should return the correct value', function () {
|
|
|
|
assert.deepEqual(formatters.inputTransactionFormatter(test.input), test.result);
|
2015-03-23 12:42:36 +00:00
|
|
|
});
|
2015-02-26 14:54:49 +00:00
|
|
|
});
|
|
|
|
});
|
2015-03-08 17:18:52 +00:00
|
|
|
});
|