This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1016 from LiskHQ/1009-decoupling_unconfirmed_phas…
- Loading branch information
Showing
19 changed files
with
377 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
36
test/functional/http/post/1.X.unconfirmed/1.1.second.secret.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
36
test/functional/http/post/1.X.unconfirmed/1.6.dapps.inTransfer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
36
test/functional/http/post/1.X.unconfirmed/1.7.dapps.outTransfer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.