-
Notifications
You must be signed in to change notification settings - Fork 55
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
Conversation
Pull Request Test Coverage Report for Build 62
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Testing Missing
- 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previous comment.
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
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
src/model/transaction/Transaction.ts
Outdated
* @returns {Transaction} | ||
* @memberof Transaction | ||
*/ | ||
public reapplygiven(deadline: Deadline): Transaction { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
src/model/transaction/Transaction.ts
Outdated
if (this.isUnannounced()) { | ||
return Object.assign({__proto__: Object.getPrototypeOf(this)}, this, {deadline}); | ||
} else { | ||
throw new Error('an Announced transaction can\'t be modified'); |
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added inline comments
No description provided.