2015-02-26 16:20:46 +01:00
|
|
|
var assert = require('assert');
|
2017-01-26 10:24:14 +01:00
|
|
|
var formatters = require('../packages/web3-core-helpers/src/formatters.js');
|
2015-02-26 16:20:46 +01:00
|
|
|
|
|
|
|
describe('formatters', function () {
|
|
|
|
describe('outputTransactionFormatter', function () {
|
|
|
|
it('should return the correct value', function () {
|
2017-01-26 10:24:14 +01:00
|
|
|
|
2015-02-26 16:20:46 +01:00
|
|
|
assert.deepEqual(formatters.outputTransactionFormatter({
|
2015-06-08 17:06:20 +02:00
|
|
|
input: '0x3454645634534',
|
2017-01-26 10:24:14 +01:00
|
|
|
from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe',
|
|
|
|
to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae',
|
2015-02-26 16:20:46 +01:00
|
|
|
value: '0x3e8',
|
|
|
|
gas: '0x3e8',
|
2015-03-23 18:50:33 +01:00
|
|
|
gasPrice: '0x3e8',
|
2015-04-20 19:52:43 +02:00
|
|
|
nonce: '0xb',
|
2015-03-23 18:50:33 +01:00
|
|
|
transactionIndex: '0x1',
|
|
|
|
blockNumber: '0x3e8',
|
2015-06-08 17:06:20 +02:00
|
|
|
blockHash: '0xc9b9cdc2092a9d6589d96662b1fd6949611163fb3910cf8a173cd060f17702f9'
|
2015-02-26 16:20:46 +01:00
|
|
|
}), {
|
2015-06-08 17:06:20 +02:00
|
|
|
input: '0x3454645634534',
|
2017-01-26 10:24:14 +01:00
|
|
|
from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe',
|
|
|
|
to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe',
|
|
|
|
value: '1000',
|
2015-02-26 16:20:46 +01:00
|
|
|
gas: 1000,
|
2017-01-26 10:24:14 +01:00
|
|
|
gasPrice: '1000',
|
2015-04-20 19:52:43 +02:00
|
|
|
nonce: 11,
|
2015-03-23 18:50:33 +01:00
|
|
|
blockNumber: 1000,
|
2015-06-08 17:06:20 +02:00
|
|
|
blockHash: '0xc9b9cdc2092a9d6589d96662b1fd6949611163fb3910cf8a173cd060f17702f9',
|
2015-03-23 18:50:33 +01:00
|
|
|
transactionIndex: 1
|
2015-02-26 16:20:46 +01:00
|
|
|
});
|
|
|
|
});
|
2015-06-08 17:06:20 +02:00
|
|
|
|
|
|
|
it('should return the correct value, when null values are present', function () {
|
2017-01-26 10:24:14 +01:00
|
|
|
|
2015-06-08 17:06:20 +02:00
|
|
|
assert.deepEqual(formatters.outputTransactionFormatter({
|
|
|
|
input: '0x3454645634534',
|
2017-01-26 10:24:14 +01:00
|
|
|
from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae',
|
2015-06-08 17:06:20 +02:00
|
|
|
to: null,
|
|
|
|
value: '0x3e8',
|
|
|
|
gas: '0x3e8',
|
|
|
|
gasPrice: '0x3e8',
|
|
|
|
nonce: '0xb',
|
|
|
|
transactionIndex: null,
|
|
|
|
blockNumber: null,
|
|
|
|
blockHash: null
|
|
|
|
}), {
|
|
|
|
input: '0x3454645634534',
|
2017-01-26 10:24:14 +01:00
|
|
|
from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe',
|
2015-06-08 17:06:20 +02:00
|
|
|
to: null,
|
2017-01-26 10:24:14 +01:00
|
|
|
value: 1000,
|
2015-06-08 17:06:20 +02:00
|
|
|
gas: 1000,
|
2017-01-26 10:24:14 +01:00
|
|
|
gasPrice: '1000',
|
2015-06-08 17:06:20 +02:00
|
|
|
nonce: 11,
|
|
|
|
blockNumber: null,
|
|
|
|
blockHash: null,
|
|
|
|
transactionIndex: null
|
|
|
|
});
|
|
|
|
});
|
2015-02-26 16:20:46 +01:00
|
|
|
});
|
2015-03-08 18:18:52 +01:00
|
|
|
});
|