mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 19:48:13 +00:00
add optional nonce property to sendTransaction
This commit is contained in:
parent
4690130b20
commit
08f3aaea8c
@ -72,7 +72,7 @@ var inputTransactionFormatter = function (options){
|
|||||||
delete options.code;
|
delete options.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
['gasPrice', 'gas', 'value'].filter(function (key) {
|
['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
|
||||||
return options[key] !== undefined;
|
return options[key] !== undefined;
|
||||||
}).forEach(function(key){
|
}).forEach(function(key){
|
||||||
options[key] = utils.fromDecimal(options[key]);
|
options[key] = utils.fromDecimal(options[key]);
|
||||||
|
@ -3,24 +3,62 @@ var assert = chai.assert;
|
|||||||
var formatters = require('../lib/web3/formatters.js');
|
var formatters = require('../lib/web3/formatters.js');
|
||||||
var BigNumber = require('bignumber.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('formatters', function () {
|
||||||
describe('inputTransactionFormatter', function () {
|
describe('inputTransactionFormatter', function () {
|
||||||
it('should return the correct value', function () {
|
tests.forEach(function(test){
|
||||||
|
it('should return the correct value', function () {
|
||||||
assert.deepEqual(formatters.inputTransactionFormatter({
|
assert.deepEqual(formatters.inputTransactionFormatter(test.input), test.result);
|
||||||
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'
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user