test for dust amount
This commit is contained in:
parent
787a3376be
commit
8cf28b2200
|
@ -26,6 +26,7 @@ var TxProposal = require('./model/txproposal');
|
|||
var Notification = require('./model/Notification');
|
||||
|
||||
var MINIMUM_FEE_SAT = 10000;
|
||||
var DUST_THRESHOLD = 5430;
|
||||
|
||||
var initialized = false;
|
||||
var storage;
|
||||
|
@ -434,6 +435,8 @@ CopayServer.prototype._selectUtxos = function(txp, utxos) {
|
|||
return;
|
||||
} catch (ex) {
|
||||
//if (ex.name != 'bitcore.ErrorTransactionFeeError') {}
|
||||
//if (ex.name != 'bitcore.ErrorTransactionDustOutputs') {}
|
||||
console.log(ex);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
@ -477,6 +480,9 @@ CopayServer.prototype.createTx = function(opts, cb) {
|
|||
if (toAddress.network != wallet.getNetworkName())
|
||||
return cb(new ClientError('INVALIDADDRESS', 'Incorrect address network'));
|
||||
|
||||
if (opts.amount < DUST_THRESHOLD)
|
||||
return cb(new ClientError('DUSTAMOUNT', 'Amount below dust threshold'));
|
||||
|
||||
self._getUtxos(function(err, utxos) {
|
||||
if (err) return cb(err);
|
||||
|
||||
|
|
|
@ -771,7 +771,18 @@ describe('Copay server', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it.skip('should fail to create tx for dust amount', function(done) {});
|
||||
it('should fail to create tx for dust amount', function(done) {
|
||||
helpers.createUtxos(server, wallet, [1], function(utxos) {
|
||||
helpers.stubBlockExplorer(server, utxos);
|
||||
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.00000001, null, TestData.copayers[0].privKey);
|
||||
server.createTx(txOpts, function(err, tx) {
|
||||
should.exist(err);
|
||||
err.code.should.equal('DUSTAMOUNT');
|
||||
err.message.should.equal('Amount below dust threshold');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should create tx when there is a pending tx and enough UTXOs', function(done) {
|
||||
helpers.createUtxos(server, wallet, [10.1, 10.2, 10.3], function(utxos) {
|
||||
|
|
Loading…
Reference in New Issue