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

Commit

Permalink
Add type 6 on top of type 1 & 4 functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
diego-G committed Nov 14, 2017
1 parent d43530d commit 9478e4d
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
74 changes: 74 additions & 0 deletions test/functional/http/post/1.second.secret.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ describe('POST /api/transactions (type 1) register second secret', function () {

transactionsToWaitFor.push(transaction1.id, transaction2.id, transaction3.id, transaction4.id);
return waitForConfirmations(transactionsToWaitFor);
})
.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');
goodTransactions.push(transaction);
node.guestbookDapp.transactionId = transaction.id;

transactionsToWaitFor.push(transaction.id);
return waitForConfirmations(transactionsToWaitFor);
});
});

Expand Down Expand Up @@ -185,6 +199,19 @@ describe('POST /api/transactions (type 1) register second secret', function () {
});
});
});

describe('type 6 - 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 () {
Expand Down Expand Up @@ -396,6 +423,53 @@ describe('POST /api/transactions (type 1) register second secret', function () {
});
});
});

describe('type 6 - inTransfer', function () {

before(function () {
transaction = node.lisk.dapp.createDapp(account.password, account.secondPassword, node.blockDataDapp);

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');
goodTransactionsEnforcement.push(transaction);
node.blockDataDapp.transactionId = transaction.id;

return waitForConfirmations([node.blockDataDapp.transactionId]);
});
});

it('using no second passphrase on an account with second passphrase enabled should fail', function () {
transaction = node.lisk.transfer.createInTransfer(node.blockDataDapp.transactionId, 10 * node.normalizer, account.password);

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('Missing sender second signature');
badTransactionsEnforcement.push(transaction);
});
});

it('using second passphrase not matching registered secondPublicKey should fail', function () {
transaction = node.lisk.transfer.createInTransfer(node.blockDataDapp.transactionId, 10 * node.normalizer, account.password, 'wrong second password');

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('Failed to verify second signature');
badTransactionsEnforcement.push(transaction);
});
});

it('using correct second passphrase should be ok', function () {
transaction = node.lisk.transfer.createInTransfer(node.blockDataDapp.transactionId, 10 * node.normalizer, account.password, account.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').that.is.equal('Transaction(s) accepted');
goodTransactionsEnforcement.push(transaction);
});
});
});
});

describe('confirm validation', function () {
Expand Down
57 changes: 57 additions & 0 deletions test/functional/http/post/4.multisig.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,63 @@ describe('POST /api/transactions (type 4) register multisignature', function ()
});
});
});

describe('type 6 - inTransfer', function () {

var dapp6 = node.randomApplication();

before(function () {
transaction = node.lisk.dapp.createDapp(scenarios.regular.account.password, null, dapp6);

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');
goodTransactionsEnforcement.push(transaction);
dapp6.transactionId = transaction.id;

return node.Promise.all(node.Promise.map(scenarios.regular.members, function (member) {
signature = node.lisk.multisignature.signTransaction(transaction, member.password);

return sendSignaturePromise(signature, transaction).then(function (res) {
node.expect(res).to.have.property('statusCode').to.equal(apiCodes.OK);
node.expect(res).to.have.nested.property('body.status').to.equal('Signature Accepted');
});
}));
})
.then(function () {
goodTransactionsEnforcement.push(transaction);

return waitForConfirmations([dapp6.transactionId]);
});
});

it('regular scenario(3,2) should be ok', function () {
transaction = node.lisk.transfer.createInTransfer(dapp6.transactionId, 10 * node.normalizer, scenarios.regular.account.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').to.equal('Transaction(s) accepted');
scenarios.regular.transaction = transaction;
});
});

describe('signing transactions', function () {

it('with min required signatures regular scenario(3,2) should be ok and confirmed', function () {
return node.Promise.all(node.Promise.map(scenarios.regular.members, function (member) {
signature = node.lisk.multisignature.signTransaction(scenarios.regular.transaction, member.password);

return sendSignaturePromise(signature, scenarios.regular.transaction).then(function (res) {
node.expect(res).to.have.property('statusCode').to.equal(apiCodes.OK);
node.expect(res).to.have.nested.property('body.status').to.equal('Signature Accepted');
});
})).then(function () {
goodTransactionsEnforcement.push(scenarios.regular.transaction);
});
});
});
});
});

describe('confirm validation', function () {
Expand Down

0 comments on commit 9478e4d

Please sign in to comment.