Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1016 from LiskHQ/1009-decoupling_unconfirmed_phas…
Browse files Browse the repository at this point in the history
…e_tx_1

Decouple unconfirmed phase from functional test tx type 1 - Subtask #678 - Closes #1009
  • Loading branch information
karmacoma authored Nov 22, 2017
2 parents 0877380 + 3d6202e commit 76e547a
Show file tree
Hide file tree
Showing 19 changed files with 377 additions and 141 deletions.
36 changes: 36 additions & 0 deletions test/functional/http/post/1.X.unconfirmed/1.0.transfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var node = require('../../../../node');
var shared = require('../../../shared');
var localShared = require('./shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;

describe('POST /api/transactions (unconfirmed type 0 on top of type 1)', function () {

var transaction;
var badTransactions = [];
var goodTransactions = [];

var account = node.randomAccount();

localShared.beforeUnconfirmedPhase(account);

describe('sending funds', function () {

it('using second signature with an account that has a pending second passphrase registration should fail', function () {
transaction = node.lisk.transaction.createTransaction(node.randomAccount().address, 1, account.password, account.secondPassword);

return sendTransactionPromise(transaction).then(function (res) {
node.expect(res).to.have.property('status').to.equal(400);
node.expect(res).to.have.nested.property('body.message').to.equal('Sender does not have a second signature');
badTransactions.push(transaction);
});
});
});

describe('confirmation', function () {

shared.confirmationPhase(goodTransactions, badTransactions);
});
});
36 changes: 36 additions & 0 deletions test/functional/http/post/1.X.unconfirmed/1.1.second.secret.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var node = require('../../../../node');
var shared = require('../../../shared');
var localShared = require('./shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;

describe('POST /api/transactions (unconfirmed type 1 on top of type 1)', function () {

var transaction;
var badTransactions = [];
var goodTransactions = [];

var account = node.randomAccount();

localShared.beforeUnconfirmedPhase(account);

describe('registering second secret', function () {

it('duplicate submission should be ok and only last transaction to arrive should be confirmed', function () {
transaction = node.lisk.signature.createSignature(account.password, 'secondpassword');

return sendTransactionPromise(transaction).then(function (res) {
node.expect(res).to.have.property('status').to.equal(200);
node.expect(res).to.have.nested.property('body.status').to.equal('Transaction(s) accepted');
goodTransactions.push(transaction);
});
});
});

describe('confirmation', function () {

shared.confirmationPhase(goodTransactions, badTransactions);
});
});
36 changes: 36 additions & 0 deletions test/functional/http/post/1.X.unconfirmed/1.2.delegate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var node = require('../../../../node');
var shared = require('../../../shared');
var localShared = require('./shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;

describe('POST /api/transactions (unconfirmed type 2 on top of type 1)', function () {

var transaction;
var badTransactions = [];
var goodTransactions = [];

var account = node.randomAccount();

localShared.beforeUnconfirmedPhase(account);

describe('registering delegate', function () {

it('using second signature with an account that has a pending second passphrase registration should fail', function () {
transaction = node.lisk.delegate.createDelegate(account.password, account.username, account.secondPassword);

return sendTransactionPromise(transaction).then(function (res) {
node.expect(res).to.have.property('status').to.equal(400);
node.expect(res).to.have.nested.property('body.message').to.equal('Sender does not have a second signature');
badTransactions.push(transaction);
});
});
});

describe('confirmation', function () {

shared.confirmationPhase(goodTransactions, badTransactions);
});
});
36 changes: 36 additions & 0 deletions test/functional/http/post/1.X.unconfirmed/1.3.votes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var node = require('../../../../node');
var shared = require('../../../shared');
var localShared = require('./shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;

describe('POST /api/transactions (unconfirmed type 3 on top of type 1)', function () {

var transaction;
var badTransactions = [];
var goodTransactions = [];

var account = node.randomAccount();

localShared.beforeUnconfirmedPhase(account);

describe('voting delegate', function () {

it('using second signature with an account that has a pending second passphrase registration should fail', function () {
transaction = node.lisk.vote.createVote(account.password, ['+' + node.eAccount.publicKey], account.secondPassword);

return sendTransactionPromise(transaction).then(function (res) {
node.expect(res).to.have.property('status').to.equal(400);
node.expect(res).to.have.nested.property('body.message').to.equal('Sender does not have a second signature');
badTransactions.push(transaction);
});
});
});

describe('confirmation', function () {

shared.confirmationPhase(goodTransactions, badTransactions);
});
});
36 changes: 36 additions & 0 deletions test/functional/http/post/1.X.unconfirmed/1.4.multisig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var node = require('../../../../node');
var shared = require('../../../shared');
var localShared = require('./shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;

describe('POST /api/transactions (unconfirmed type 4 on top of type 1)', function () {

var transaction;
var badTransactions = [];
var goodTransactions = [];

var account = node.randomAccount();

localShared.beforeUnconfirmedPhase(account);

describe('creating multisig', function () {

it('using second signature with an account that has a pending second passphrase registration should fail', function () {
transaction = node.lisk.multisignature.createMultisignature(account.password, account.secondPassword, ['+' + node.eAccount.publicKey], 1, 1);

return sendTransactionPromise(transaction).then(function (res) {
node.expect(res).to.have.property('status').to.equal(400);
node.expect(res).to.have.nested.property('body.message').to.equal('Sender does not have a second signature');
badTransactions.push(transaction);
});
});
});

describe('confirmation', function () {

shared.confirmationPhase(goodTransactions, badTransactions);
});
});
36 changes: 36 additions & 0 deletions test/functional/http/post/1.X.unconfirmed/1.5.dapps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var node = require('../../../../node');
var shared = require('../../../shared');
var localShared = require('./shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;

describe('POST /api/transactions (unconfirmed type 5 on top of type 1)', function () {

var transaction;
var badTransactions = [];
var goodTransactions = [];

var account = node.randomAccount();

localShared.beforeUnconfirmedPhase(account);

describe('registering dapp', function () {

it('using second signature with an account that has a pending second passphrase registration should fail', function () {
transaction = node.lisk.dapp.createDapp(account.password, account.secondPassword, node.randomApplication());

return sendTransactionPromise(transaction).then(function (res) {
node.expect(res).to.have.property('status').to.equal(400);
node.expect(res).to.have.nested.property('body.message').to.equal('Sender does not have a second signature');
badTransactions.push(transaction);
});
});
});

describe('confirmation', function () {

shared.confirmationPhase(goodTransactions, badTransactions);
});
});
36 changes: 36 additions & 0 deletions test/functional/http/post/1.X.unconfirmed/1.6.dapps.inTransfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var node = require('../../../../node');
var shared = require('../../../shared');
var localShared = require('./shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;

describe('POST /api/transactions (unconfirmed type 6 on top of type 1)', function () {

var transaction;
var badTransactions = [];
var goodTransactions = [];

var account = node.randomAccount();

localShared.beforeUnconfirmedPhaseWithDapp(account);

describe('inTransfer', function () {

it('using second signature with an account that has a pending second passphrase registration should fail', function () {
transaction = node.lisk.transfer.createInTransfer(node.guestbookDapp.transactionId, 10 * node.normalizer, account.password, account.secondPassword);

return sendTransactionPromise(transaction).then(function (res) {
node.expect(res).to.have.property('status').to.equal(400);
node.expect(res).to.have.nested.property('body.message').to.equal('Sender does not have a second signature');
badTransactions.push(transaction);
});
});
});

describe('confirmation', function () {

shared.confirmationPhase(goodTransactions, badTransactions);
});
});
36 changes: 36 additions & 0 deletions test/functional/http/post/1.X.unconfirmed/1.7.dapps.outTransfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var node = require('../../../../node');
var shared = require('../../../shared');
var localShared = require('./shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;

describe('POST /api/transactions (unconfirmed type 7 on top of type 1)', function () {

var transaction;
var badTransactions = [];
var goodTransactions = [];

var account = node.randomAccount();

localShared.beforeUnconfirmedPhaseWithDapp(account);

describe('outTransfer', function () {

it('using second signature with an account that has a pending second passphrase registration should fail', function () {
transaction = node.lisk.transfer.createOutTransfer(node.guestbookDapp.transactionId, node.randomTransaction().id, node.randomAccount().address, 10 * node.normalizer, account.password, account.secondPassword);

return sendTransactionPromise(transaction).then(function (res) {
node.expect(res).to.have.property('status').to.equal(400);
node.expect(res).to.have.nested.property('body.message').to.equal('Sender does not have a second signature');
badTransactions.push(transaction);
});
});
});

describe('confirmation', function () {

shared.confirmationPhase(goodTransactions, badTransactions);
});
});
71 changes: 71 additions & 0 deletions test/functional/http/post/1.X.unconfirmed/shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
'use strict';

var node = require('../../../../node');
var shared = require('../../../shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;
var waitForConfirmations = require('../../../../common/apiHelpers').waitForConfirmations;

function beforeUnconfirmedPhase (account) {
before(function () {
var transaction = node.lisk.transaction.createTransaction(account.address, 1000 * node.normalizer, node.gAccount.password);

return sendTransactionPromise(transaction)
.then(function (res) {
node.expect(res).to.have.property('status').to.equal(200);
node.expect(res).to.have.nested.property('body.status').that.is.equal('Transaction(s) accepted');

return waitForConfirmations([transaction.id]);
})
.then(function () {
transaction = node.lisk.signature.createSignature(account.password, account.secondPassword, 1);

return sendTransactionPromise(transaction);
})
.then(function (res) {
node.expect(res).to.have.property('status').to.equal(200);
node.expect(res).to.have.nested.property('body.status').to.equal('Transaction(s) accepted');
});
});
};

function beforeUnconfirmedPhaseWithDapp (account) {
before(function () {
var transaction = node.lisk.transaction.createTransaction(account.address, 1000 * node.normalizer, node.gAccount.password);

return sendTransactionPromise(transaction)
.then(function (res) {
node.expect(res).to.have.property('status').to.equal(200);
node.expect(res).to.have.nested.property('body.status').that.is.equal('Transaction(s) accepted');

return waitForConfirmations([transaction.id]);
})
.then(function () {
transaction = node.lisk.dapp.createDapp(account.password, null, node.guestbookDapp);

return sendTransactionPromise(transaction);
})
.then(function (res) {
node.expect(res).to.have.property('status').to.equal(200);
node.expect(res).to.have.nested.property('body.status').to.equal('Transaction(s) accepted');

node.guestbookDapp.transactionId = transaction.id;

return waitForConfirmations([transaction.id]);
})
.then(function (res) {
transaction = node.lisk.signature.createSignature(account.password, account.secondPassword, 1);

return sendTransactionPromise(transaction);
})
.then(function (res) {
node.expect(res).to.have.property('status').to.equal(200);
node.expect(res).to.have.nested.property('body.status').to.equal('Transaction(s) accepted');
});
});
};

module.exports = {
beforeUnconfirmedPhase: beforeUnconfirmedPhase,
beforeUnconfirmedPhaseWithDapp: beforeUnconfirmedPhaseWithDapp
};
2 changes: 1 addition & 1 deletion test/functional/http/post/1.X.validation/1.0.transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var localShared = require('./shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;

describe('POST /api/transactions (type 0 on top of type 1)', function () {
describe('POST /api/transactions (validate type 0 on top of type 1)', function () {

var transaction;
var badTransactions = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var localShared = require('./shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;

describe('POST /api/transactions (type 1 on top of type 1)', function () {
describe('POST /api/transactions (validate type 1 on top of type 1)', function () {

var transaction;
var badTransactions = [];
Expand Down
2 changes: 1 addition & 1 deletion test/functional/http/post/1.X.validation/1.2.delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var localShared = require('./shared');

var sendTransactionPromise = require('../../../../common/apiHelpers').sendTransactionPromise;

describe('POST /api/transactions (type 2 on top of type 1)', function () {
describe('POST /api/transactions (validate type 2 on top of type 1)', function () {

var transaction;
var badTransactions = [];
Expand Down
Loading

0 comments on commit 76e547a

Please sign in to comment.