|
@ -169,10 +169,6 @@ helpers.stubBroadcast = function(txid) { |
|
|
blockchainExplorer.broadcast = sinon.stub().callsArgWith(1, null, txid); |
|
|
blockchainExplorer.broadcast = sinon.stub().callsArgWith(1, null, txid); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
helpers.stubBroadcastFail = function() { |
|
|
|
|
|
blockchainExplorer.broadcast = sinon.stub().callsArgWith(1, 'broadcast error'); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
helpers.stubHistory = function(txs) { |
|
|
helpers.stubHistory = function(txs) { |
|
|
blockchainExplorer.getTransactions = function(addresses, from, to, cb) { |
|
|
blockchainExplorer.getTransactions = function(addresses, from, to, cb) { |
|
|
var MAX_BATCH_SIZE = 100; |
|
|
var MAX_BATCH_SIZE = 100; |
|
@ -735,7 +731,7 @@ describe('Wallet service', function() { |
|
|
message: TestData.message.text, |
|
|
message: TestData.message.text, |
|
|
signature: TestData.message.signature, |
|
|
signature: TestData.message.signature, |
|
|
}, function(err, server) { |
|
|
}, function(err, server) { |
|
|
err.code.should.equal('NOTAUTHORIZED'); |
|
|
err.code.should.equal('NOT_AUTHORIZED'); |
|
|
err.message.should.contain('Copayer not found'); |
|
|
err.message.should.contain('Copayer not found'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -748,7 +744,7 @@ describe('Wallet service', function() { |
|
|
message: 'dummy', |
|
|
message: 'dummy', |
|
|
signature: 'dummy', |
|
|
signature: 'dummy', |
|
|
}, function(err, server) { |
|
|
}, function(err, server) { |
|
|
err.code.should.equal('NOTAUTHORIZED'); |
|
|
err.code.should.equal('NOT_AUTHORIZED'); |
|
|
err.message.should.contain('Invalid signature'); |
|
|
err.message.should.contain('Invalid signature'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -981,7 +977,7 @@ describe('Wallet service', function() { |
|
|
}); |
|
|
}); |
|
|
server.joinWallet(copayerOpts, function(err) { |
|
|
server.joinWallet(copayerOpts, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('WFULL'); |
|
|
err.code.should.equal('WALLET_FULL'); |
|
|
err.message.should.equal('Wallet full'); |
|
|
err.message.should.equal('Wallet full'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -999,7 +995,7 @@ describe('Wallet service', function() { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
|
server.joinWallet(copayerOpts, function(err) { |
|
|
server.joinWallet(copayerOpts, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('CINWALLET'); |
|
|
err.code.should.equal('COPAYER_IN_WALLET'); |
|
|
err.message.should.equal('Copayer already in wallet'); |
|
|
err.message.should.equal('Copayer already in wallet'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -1032,7 +1028,7 @@ describe('Wallet service', function() { |
|
|
}); |
|
|
}); |
|
|
server.joinWallet(copayerOpts, function(err) { |
|
|
server.joinWallet(copayerOpts, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('CREGISTERED'); |
|
|
err.code.should.equal('COPAYER_REGISTERED'); |
|
|
err.message.should.equal('Copayer ID already registered on server'); |
|
|
err.message.should.equal('Copayer ID already registered on server'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -1452,7 +1448,7 @@ describe('Wallet service', function() { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
|
server.getBalance({}, function(err, balance) { |
|
|
server.getBalance({}, function(err, balance) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('BLOCKCHAINERROR'); |
|
|
err.toString().should.equal('dummy error'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -1686,13 +1682,13 @@ describe('Wallet service', function() { |
|
|
txOpts.excludeUnconfirmedUtxos = true; |
|
|
txOpts.excludeUnconfirmedUtxos = true; |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('INSUFFICIENTFUNDS'); |
|
|
err.code.should.equal('INSUFFICIENT_FUNDS'); |
|
|
err.message.should.equal('Insufficient funds'); |
|
|
err.message.should.equal('Insufficient funds'); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 2.5, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 2.5, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
txOpts.excludeUnconfirmedUtxos = true; |
|
|
txOpts.excludeUnconfirmedUtxos = true; |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('INSUFFICIENTFUNDS'); |
|
|
err.code.should.equal('INSUFFICIENT_FUNDS_FOR_FEE'); |
|
|
err.message.should.equal('Insufficient funds for fee'); |
|
|
err.message.should.equal('Insufficient funds for fee'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -1716,7 +1712,7 @@ describe('Wallet service', function() { |
|
|
txOpts.excludeUnconfirmedUtxos = true; |
|
|
txOpts.excludeUnconfirmedUtxos = true; |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('LOCKEDFUNDS'); |
|
|
err.code.should.equal('LOCKED_FUNDS'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -1731,7 +1727,7 @@ describe('Wallet service', function() { |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('BLOCKCHAINERROR'); |
|
|
err.toString().should.equal('dummy error'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -1783,7 +1779,7 @@ describe('Wallet service', function() { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.not.exist(tx); |
|
|
should.not.exist(tx); |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('INVALIDADDRESS'); |
|
|
err.code.should.equal('INCORRECT_ADDRESS_NETWORK'); |
|
|
err.message.should.equal('Incorrect address network'); |
|
|
err.message.should.equal('Incorrect address network'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -1805,7 +1801,7 @@ describe('Wallet service', function() { |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 120, null, TestData.copayers[0].privKey_1H_0); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 120, null, TestData.copayers[0].privKey_1H_0); |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('INSUFFICIENTFUNDS'); |
|
|
err.code.should.equal('INSUFFICIENT_FUNDS'); |
|
|
err.message.should.equal('Insufficient funds'); |
|
|
err.message.should.equal('Insufficient funds'); |
|
|
server.getPendingTxs({}, function(err, txs) { |
|
|
server.getPendingTxs({}, function(err, txs) { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
@ -1826,7 +1822,7 @@ describe('Wallet service', function() { |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.048200, null, TestData.copayers[0].privKey_1H_0); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.048200, null, TestData.copayers[0].privKey_1H_0); |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('INSUFFICIENTFUNDS'); |
|
|
err.code.should.equal('INSUFFICIENT_FUNDS_FOR_FEE'); |
|
|
err.message.should.equal('Insufficient funds for fee'); |
|
|
err.message.should.equal('Insufficient funds for fee'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -1850,7 +1846,7 @@ describe('Wallet service', function() { |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, null, TestData.copayers[0].privKey_1H_0, 80000); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, null, TestData.copayers[0].privKey_1H_0, 80000); |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('INSUFFICIENTFUNDS'); |
|
|
err.code.should.equal('INSUFFICIENT_FUNDS_FOR_FEE'); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, null, TestData.copayers[0].privKey_1H_0, 5000); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, null, TestData.copayers[0].privKey_1H_0, 5000); |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
@ -1876,7 +1872,7 @@ describe('Wallet service', function() { |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.00000001, null, TestData.copayers[0].privKey_1H_0); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.00000001, null, TestData.copayers[0].privKey_1H_0); |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('DUSTAMOUNT'); |
|
|
err.code.should.equal('DUST_AMOUNT'); |
|
|
err.message.should.equal('Amount below dust threshold'); |
|
|
err.message.should.equal('Amount below dust threshold'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -1892,7 +1888,7 @@ describe('Wallet service', function() { |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', amount, null, TestData.copayers[0].privKey_1H_0, 10000); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', amount, null, TestData.copayers[0].privKey_1H_0, 10000); |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('DUSTAMOUNT'); |
|
|
err.code.should.equal('DUST_AMOUNT'); |
|
|
err.message.should.equal('Amount below dust threshold'); |
|
|
err.message.should.equal('Amount below dust threshold'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -1911,7 +1907,7 @@ describe('Wallet service', function() { |
|
|
txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 8, null, TestData.copayers[0].privKey_1H_0); |
|
|
txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 8, null, TestData.copayers[0].privKey_1H_0); |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('LOCKEDFUNDS'); |
|
|
err.code.should.equal('LOCKED_FUNDS'); |
|
|
err.message.should.equal('Funds are locked by pending transaction proposals'); |
|
|
err.message.should.equal('Funds are locked by pending transaction proposals'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -1987,7 +1983,7 @@ describe('Wallet service', function() { |
|
|
should.exist(tx); |
|
|
should.exist(tx); |
|
|
var txOpts2 = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 24, null, TestData.copayers[0].privKey_1H_0); |
|
|
var txOpts2 = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 24, null, TestData.copayers[0].privKey_1H_0); |
|
|
server.createTx(txOpts2, function(err, tx) { |
|
|
server.createTx(txOpts2, function(err, tx) { |
|
|
err.code.should.equal('LOCKEDFUNDS'); |
|
|
err.code.should.equal('LOCKED_FUNDS'); |
|
|
should.not.exist(tx); |
|
|
should.not.exist(tx); |
|
|
server.getPendingTxs({}, function(err, txs) { |
|
|
server.getPendingTxs({}, function(err, txs) { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
@ -2192,7 +2188,7 @@ describe('Wallet service', function() { |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('NOTALLOWEDTOCREATETX'); |
|
|
err.code.should.equal('TX_CANNOT_CREATE'); |
|
|
next(); |
|
|
next(); |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
@ -2214,7 +2210,7 @@ describe('Wallet service', function() { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
clock.restore(); |
|
|
clock.restore(); |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('NOTALLOWEDTOCREATETX'); |
|
|
err.code.should.equal('TX_CANNOT_CREATE'); |
|
|
next(); |
|
|
next(); |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
@ -2306,7 +2302,7 @@ describe('Wallet service', function() { |
|
|
reason: 'some other reason', |
|
|
reason: 'some other reason', |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('TXNOTPENDING'); |
|
|
err.code.should.equal('TX_NOT_PENDING'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -2371,7 +2367,7 @@ describe('Wallet service', function() { |
|
|
txProposalId: txid, |
|
|
txProposalId: txid, |
|
|
signatures: signatures, |
|
|
signatures: signatures, |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
err.code.should.contain('BADSIG'); |
|
|
err.code.should.equal('BAD_SIGNATURES'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -2442,7 +2438,7 @@ describe('Wallet service', function() { |
|
|
server.rejectTx({ |
|
|
server.rejectTx({ |
|
|
txProposalId: txid, |
|
|
txProposalId: txid, |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
err.code.should.contain('CVOTED'); |
|
|
err.code.should.contain('COPAYER_VOTED'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -2462,7 +2458,7 @@ describe('Wallet service', function() { |
|
|
txProposalId: txid, |
|
|
txProposalId: txid, |
|
|
signatures: signatures, |
|
|
signatures: signatures, |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
err.code.should.contain('CVOTED'); |
|
|
err.code.should.contain('COPAYER_VOTED'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -2511,7 +2507,7 @@ describe('Wallet service', function() { |
|
|
signatures: signatures, |
|
|
signatures: signatures, |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('TXNOTPENDING'); |
|
|
err.code.should.equal('TX_NOT_PENDING'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -2579,7 +2575,7 @@ describe('Wallet service', function() { |
|
|
txProposalId: txpid |
|
|
txProposalId: txpid |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('TXALREADYBROADCASTED'); |
|
|
err.code.should.equal('TX_ALREADY_BROADCASTED'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -2595,20 +2591,20 @@ describe('Wallet service', function() { |
|
|
txProposalId: txp.id |
|
|
txProposalId: txp.id |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('TXNOTACCEPTED'); |
|
|
err.code.should.equal('TX_NOT_ACCEPTED'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should keep tx as accepted if unable to broadcast it', function(done) { |
|
|
it('should keep tx as accepted if unable to broadcast it', function(done) { |
|
|
helpers.stubBroadcastFail(); |
|
|
blockchainExplorer.broadcast = sinon.stub().callsArgWith(1, 'broadcast error'); |
|
|
blockchainExplorer.getTransaction = sinon.stub().callsArgWith(1, null, null); |
|
|
blockchainExplorer.getTransaction = sinon.stub().callsArgWith(1, null, null); |
|
|
server.broadcastTx({ |
|
|
server.broadcastTx({ |
|
|
txProposalId: txpid |
|
|
txProposalId: txpid |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('BLOCKCHAINERROR'); |
|
|
err.toString().should.equal('broadcast error'); |
|
|
server.getTx({ |
|
|
server.getTx({ |
|
|
txProposalId: txpid |
|
|
txProposalId: txpid |
|
|
}, function(err, txp) { |
|
|
}, function(err, txp) { |
|
@ -2623,7 +2619,7 @@ describe('Wallet service', function() { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should mark tx as broadcasted if accepted but already in blockchain', function(done) { |
|
|
it('should mark tx as broadcasted if accepted but already in blockchain', function(done) { |
|
|
helpers.stubBroadcastFail(); |
|
|
blockchainExplorer.broadcast = sinon.stub().callsArgWith(1, 'broadcast error'); |
|
|
blockchainExplorer.getTransaction = sinon.stub().callsArgWith(1, null, { |
|
|
blockchainExplorer.getTransaction = sinon.stub().callsArgWith(1, null, { |
|
|
txid: '999' |
|
|
txid: '999' |
|
|
}); |
|
|
}); |
|
@ -2645,13 +2641,13 @@ describe('Wallet service', function() { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should keep tx as accepted if broadcast fails and cannot check tx in blockchain', function(done) { |
|
|
it('should keep tx as accepted if broadcast fails and cannot check tx in blockchain', function(done) { |
|
|
helpers.stubBroadcastFail(); |
|
|
blockchainExplorer.broadcast = sinon.stub().callsArgWith(1, 'broadcast error'); |
|
|
blockchainExplorer.getTransaction = sinon.stub().callsArgWith(1, 'bc check error'); |
|
|
blockchainExplorer.getTransaction = sinon.stub().callsArgWith(1, 'bc check error'); |
|
|
server.broadcastTx({ |
|
|
server.broadcastTx({ |
|
|
txProposalId: txpid |
|
|
txProposalId: txpid |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('BLOCKCHAINERROR'); |
|
|
err.toString().should.equal('bc check error'); |
|
|
server.getTx({ |
|
|
server.getTx({ |
|
|
txProposalId: txpid |
|
|
txProposalId: txpid |
|
|
}, function(err, txp) { |
|
|
}, function(err, txp) { |
|
@ -3085,7 +3081,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
|
it('should notify sign and acceptance', function(done) { |
|
|
it('should notify sign and acceptance', function(done) { |
|
|
server.getPendingTxs({}, function(err, txs) { |
|
|
server.getPendingTxs({}, function(err, txs) { |
|
|
helpers.stubBroadcastFail(); |
|
|
blockchainExplorer.broadcast = sinon.stub().callsArgWith(1, 'broadcast error'); |
|
|
var tx = txs[0]; |
|
|
var tx = txs[0]; |
|
|
var signatures = helpers.clientSign(tx, TestData.copayers[0].xPrivKey); |
|
|
var signatures = helpers.clientSign(tx, TestData.copayers[0].xPrivKey); |
|
|
server.signTx({ |
|
|
server.signTx({ |
|
@ -3379,7 +3375,7 @@ describe('Wallet service', function() { |
|
|
txProposalId: txp.id |
|
|
txProposalId: txp.id |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('TXNOTPENDING'); |
|
|
err.code.should.equal('TX_NOT_PENDING'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
@ -3392,7 +3388,7 @@ describe('Wallet service', function() { |
|
|
txProposalId: txp.id |
|
|
txProposalId: txp.id |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.contain('TXCANNOTREMOVE'); |
|
|
err.code.should.contain('TX_CANNOT_REMOVE'); |
|
|
server2.getPendingTxs({}, function(err, txs) { |
|
|
server2.getPendingTxs({}, function(err, txs) { |
|
|
txs.length.should.equal(1); |
|
|
txs.length.should.equal(1); |
|
|
done(); |
|
|
done(); |
|
@ -3412,7 +3408,7 @@ describe('Wallet service', function() { |
|
|
server.removePendingTx({ |
|
|
server.removePendingTx({ |
|
|
txProposalId: txp.id |
|
|
txProposalId: txp.id |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
err.code.should.equal('TXCANNOTREMOVE'); |
|
|
err.code.should.equal('TX_CANNOT_REMOVE'); |
|
|
err.message.should.contain('Cannot remove'); |
|
|
err.message.should.contain('Cannot remove'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
@ -3770,7 +3766,7 @@ describe('Wallet service', function() { |
|
|
blockchainExplorer.getTransactions = sinon.stub().callsArgWith(3, 'dummy error'); |
|
|
blockchainExplorer.getTransactions = sinon.stub().callsArgWith(3, 'dummy error'); |
|
|
server.getTxHistory({}, function(err, txs) { |
|
|
server.getTxHistory({}, function(err, txs) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('BLOCKCHAINERROR'); |
|
|
err.toString().should.equal('dummy error'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -3920,7 +3916,7 @@ describe('Wallet service', function() { |
|
|
blockchainExplorer.getAddressActivity = sinon.stub().callsArgWith(1, 'dummy error'); |
|
|
blockchainExplorer.getAddressActivity = sinon.stub().callsArgWith(1, 'dummy error'); |
|
|
server.scan({}, function(err) { |
|
|
server.scan({}, function(err) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('BLOCKCHAINERROR'); |
|
|
err.toString().should.equal('dummy error'); |
|
|
server.getWallet({}, function(err, wallet) { |
|
|
server.getWallet({}, function(err, wallet) { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
|
wallet.scanStatus.should.equal('error'); |
|
|
wallet.scanStatus.should.equal('error'); |
|
@ -4117,7 +4113,7 @@ describe('Wallet service', function() { |
|
|
}); |
|
|
}); |
|
|
copayerOpts.isTemporaryRequestKey = false; |
|
|
copayerOpts.isTemporaryRequestKey = false; |
|
|
server.replaceTemporaryRequestKey(copayerOpts, function(err, wallet) { |
|
|
server.replaceTemporaryRequestKey(copayerOpts, function(err, wallet) { |
|
|
err.code.should.equal('WNOTFULL'); |
|
|
err.code.should.equal('WALLET_NOT_COMPLETE'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -4149,7 +4145,7 @@ describe('Wallet service', function() { |
|
|
}); |
|
|
}); |
|
|
copayerOpts.isTemporaryRequestKey = false; |
|
|
copayerOpts.isTemporaryRequestKey = false; |
|
|
server.replaceTemporaryRequestKey(copayerOpts, function(err, wallet) { |
|
|
server.replaceTemporaryRequestKey(copayerOpts, function(err, wallet) { |
|
|
err.code.should.equal('CDATAMISMATCH'); |
|
|
err.code.should.equal('COPAYER_DATA_MISMATCH'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -4192,7 +4188,7 @@ describe('Wallet service', function() { |
|
|
}); |
|
|
}); |
|
|
copayerOpts.isTemporaryRequestKey = false; |
|
|
copayerOpts.isTemporaryRequestKey = false; |
|
|
server.replaceTemporaryRequestKey(copayerOpts, function(err, wallet) { |
|
|
server.replaceTemporaryRequestKey(copayerOpts, function(err, wallet) { |
|
|
err.code.should.equal('CDATAMISMATCH'); |
|
|
err.code.should.equal('COPAYER_DATA_MISMATCH'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -4309,7 +4305,8 @@ describe('Wallet service', function() { |
|
|
server.getPendingTxs({}, function(err, txps) { |
|
|
server.getPendingTxs({}, function(err, txps) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
should.not.exist(txps); |
|
|
should.not.exist(txps); |
|
|
err.toString().should.contain('created by a newer version'); |
|
|
err.code.should.equal('UPGRADE_NEEDED'); |
|
|
|
|
|
err.message.should.contain('newer version'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -4367,7 +4364,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('INSUFFICIENTFUNDS'); |
|
|
err.code.should.equal('INSUFFICIENT_FUNDS_FOR_FEE'); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, null, TestData.copayers[0].privKey_1H_0, 5000); |
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, null, TestData.copayers[0].privKey_1H_0, 5000); |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
|