more testing
This commit is contained in:
parent
03858e4f4b
commit
c5e4c4b9a4
|
@ -1793,8 +1793,8 @@ WalletService.prototype.createTx = function(opts, cb) {
|
|||
|
||||
|
||||
function getFeePerKb(wallet, cb) {
|
||||
if (opts.inputs && _.isNumber(opts.fee)) return null;
|
||||
if (_.isNumber(opts.feePerKb)) return opts.feePerKb;
|
||||
if (opts.inputs && _.isNumber(opts.fee)) return cb();
|
||||
if (_.isNumber(opts.feePerKb)) return cb(null, opts.feePerKb);
|
||||
self.getFeeLevels({
|
||||
network: wallet.network
|
||||
}, function(err, levels) {
|
||||
|
|
|
@ -2360,8 +2360,23 @@ describe('Wallet service', function() {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it.skip('should fail to specify both feeLevel & feePerKb', function(done) {
|
||||
|
||||
it('should fail to specify both feeLevel & feePerKb', function(done) {
|
||||
helpers.stubUtxos(server, wallet, 2, function() {
|
||||
var txOpts = {
|
||||
outputs: [{
|
||||
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
|
||||
amount: 1e8,
|
||||
}],
|
||||
feeLevel: 'normal',
|
||||
feePerKb: 123e2,
|
||||
};
|
||||
server.createTx(txOpts, function(err, txp) {
|
||||
should.exist(err);
|
||||
should.not.exist(txp);
|
||||
err.toString().should.contain('Only one of feeLevel/feePerKb');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should be able to create tx with inputs argument', function(done) {
|
||||
helpers.stubUtxos(server, wallet, [1, 3, 2], function(utxos) {
|
||||
|
@ -2731,33 +2746,69 @@ describe('Wallet service', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe.only('Fee levels', function() {
|
||||
describe('Fee levels', function() {
|
||||
it('should create a tx specifying feeLevel', function(done) {
|
||||
helpers.stubFeeLevels({
|
||||
1: 40000,
|
||||
2: 20000,
|
||||
6: 18000,
|
||||
24: 9000,
|
||||
1: 400e2,
|
||||
2: 200e2,
|
||||
6: 180e2,
|
||||
24: 90e2,
|
||||
});
|
||||
helpers.stubUtxos(server, wallet, [1, 2], function() {
|
||||
helpers.stubUtxos(server, wallet, 2, function() {
|
||||
var txOpts = {
|
||||
outputs: [{
|
||||
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
|
||||
amount: 0.8 * 1e8,
|
||||
amount: 1e8,
|
||||
}],
|
||||
feeLevel: 'economy',
|
||||
};
|
||||
server.createTx(txOpts, function(err, txp) {
|
||||
should.not.exist(err);
|
||||
should.exist(txp);
|
||||
txp.amount.should.equal(helpers.toSatoshi(0.8));
|
||||
txp.feePerKb.should.equal(180e2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it.skip('should fail if the specified fee level does not exist', function(done) {});
|
||||
it.skip('should assume "normal" fee level if no feeLevel and no feePerKb/fee is specified', function(done) {});
|
||||
it('should fail if the specified fee level does not exist', function(done) {
|
||||
helpers.stubUtxos(server, wallet, 2, function() {
|
||||
var txOpts = {
|
||||
outputs: [{
|
||||
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
|
||||
amount: 1e8,
|
||||
}],
|
||||
feeLevel: 'madeUpLevel',
|
||||
};
|
||||
server.createTx(txOpts, function(err, txp) {
|
||||
should.exist(err);
|
||||
should.not.exist(txp);
|
||||
err.toString().should.contain('Invalid fee level');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should assume "normal" fee level if no feeLevel and no feePerKb/fee is specified', function(done) {
|
||||
helpers.stubFeeLevels({
|
||||
1: 400e2,
|
||||
2: 200e2,
|
||||
6: 180e2,
|
||||
24: 90e2,
|
||||
});
|
||||
helpers.stubUtxos(server, wallet, 2, function() {
|
||||
var txOpts = {
|
||||
outputs: [{
|
||||
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
|
||||
amount: 1e8,
|
||||
}],
|
||||
};
|
||||
server.createTx(txOpts, function(err, txp) {
|
||||
should.not.exist(err);
|
||||
should.exist(txp);
|
||||
txp.feePerKb.should.equal(200e2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should generate new change address for each created tx', function(done) {
|
||||
helpers.stubUtxos(server, wallet, [1, 2], function() {
|
||||
|
|
Loading…
Reference in New Issue