refactor integration test code

This commit is contained in:
Ivan Socolsky 2016-02-26 16:05:27 -03:00
parent 040bb0004f
commit baaa6e62c7
1 changed files with 405 additions and 362 deletions

View File

@ -239,6 +239,8 @@ describe('Wallet service', function() {
});
describe('#joinWallet', function() {
describe('New clients', function() {
var server, walletId;
beforeEach(function(done) {
server = new WalletService();
@ -526,7 +528,7 @@ describe('Wallet service', function() {
});
});
describe('#joinWallet new/legacy clients', function() {
describe('Interaction new/legacy clients', function() {
var server;
beforeEach(function() {
server = new WalletService();
@ -556,6 +558,7 @@ describe('Wallet service', function() {
});
});
});
it('should fail to join new wallet from legacy client', function(done) {
var walletOpts = {
name: 'my wallet',
@ -581,6 +584,7 @@ describe('Wallet service', function() {
});
});
});
});
describe('Address derivation strategy', function() {
var server;
@ -3084,11 +3088,9 @@ describe('Wallet service', function() {
});
});
});
});
});
describe('#createTx backoff time', function(done) {
describe('Backoff time', function(done) {
var server, wallet, txid;
beforeEach(function(done) {
@ -3165,6 +3167,49 @@ describe('Wallet service', function() {
});
});
describe('UTXO selection', function() {
var server, wallet;
beforeEach(function(done) {
helpers.createAndJoinWallet(2, 3, function(s, w) {
server = s;
wallet = w;
done();
});
});
it('should create a tx', function(done) {
helpers.stubUtxos(server, wallet, [1, 2], function() {
var txOpts = {
outputs: [{
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
amount: 0.8 * 1e8,
}],
message: 'some message',
customData: 'some custom data',
};
server.createTx(txOpts, function(err, tx) {
should.not.exist(err);
should.exist(tx);
tx.walletM.should.equal(2);
tx.walletN.should.equal(3);
tx.requiredRejections.should.equal(2);
tx.requiredSignatures.should.equal(2);
tx.isAccepted().should.equal.false;
tx.isRejected().should.equal.false;
tx.isPending().should.equal.true;
tx.isTemporary().should.equal.true;
tx.amount.should.equal(helpers.toSatoshi(0.8));
server.getPendingTxs({}, function(err, txs) {
should.not.exist(err);
txs.should.be.empty;
done();
});
});
});
});
});
});
describe('#rejectTx', function() {
var server, wallet, txid;
@ -5023,7 +5068,6 @@ describe('Wallet service', function() {
done();
});
});
});
describe('#scan', function() {
@ -5686,5 +5730,4 @@ describe('Wallet service', function() {
});
});
});
});