Skip to content

Exposed Deadline to the public in Transaction class #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
13 commits merged into from
Jul 17, 2018

Conversation

khawarizmus
Copy link
Contributor

No description provided.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 59

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 68.374%

Totals Coverage Status
Change from base Build 58: 0.0%
Covered Lines: 714
Relevant Lines: 986

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jul 11, 2018

Pull Request Test Coverage Report for Build 62

  • 52 of 52 (100.0%) changed or added relevant lines in 10 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.9%) to 69.255%

Files with Coverage Reduction New Missed Lines %
src/model/transaction/RegisterNamespaceTransaction.ts 1 145.16%
Totals Coverage Status
Change from base Build 58: 0.9%
Covered Lines: 745
Relevant Lines: 1018

💛 - Coveralls

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Testing Missing
  2. It might be not the best approach, since when you receive a transaction from network you are able to change the deadline and then the Transaction Hash won't be the same.

I might opt for a method similar to replyGiven(deadline: Deadline): Transaction; which creates a new Transaction with the previous data, replacing the deadline and without TransactionInfo

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous comment.

@khawarizmus
Copy link
Contributor Author

implementation and test done. please review @aleixmorgadas

package.json Outdated
@@ -5,6 +5,7 @@
"scripts": {
"pretest": "npm run build",
"test": "mocha --ui bdd --recursive ./dist/test --timeout 90000",
"tran": "mocha --ui bdd --recursive ./dist/test/model/transaction/Transaction.spec --timeout 90000",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I was just testing and forgot to remove it :P it's faster because somehow in my console mocha couldn't filter this ./src/test/model/transaction/Transaction.spec

* @returns {Transaction}
* @memberof Transaction
*/
public reapplygiven(deadline: Deadline): Transaction {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace reapplygiven by reply or replyGiven

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add the deadline as optional parameter, like

public reply(deadline: Deadline = Deadline.create()): Transaction

if (this.isUnannounced()) {
return Object.assign({__proto__: Object.getPrototypeOf(this)}, this, {deadline});
} else {
throw new Error('an Announced transaction can\'t be modified');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does exist a case where you want to reply an already announced transaction?

I would do:

if (this.isUnannounced()) {
    return Object.assign({__proto__: Object.getPrototypeOf(this)}, this, {deadline});
}
throw new Error('an Announced transaction can\'t be modified');

The code is more clean, personal style 😄

@@ -98,6 +98,52 @@ describe('Transaction', () => {
expect(transaction.hasMissingSignatures()).to.be.equal(true);
});
});

describe('reapplygiven', () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated according to the previous comments

undefined,
);

const newTransaction = transaction.reapplygiven(Deadline.create(3));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move check that the new deadline is assigned, something like:

const newDeadline = Deadline.create(3);
const newTransaction = transaction.reapplygiven(newDeadline); 
expect(newTransaction.deadline).to.be.equal(newDeadline);

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added inline comments

@ghost ghost merged commit 6f71e1f into symbol:master Jul 17, 2018
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants