Skip to content
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

run test workflow at PR opening #101

Merged
merged 2 commits into from
Mar 3, 2023
Merged

run test workflow at PR opening #101

merged 2 commits into from
Mar 3, 2023

Conversation

peterjah
Copy link
Contributor

@peterjah peterjah commented Mar 3, 2023

No description provided.

@Thykof Thykof merged commit a73147f into main Mar 3, 2023
const c = a * b;
assert(c / a == b, "SafeMath: multiplication overflow");
const c = a * b;
assert(c / a == b, 'SafeMath: multiplication overflow');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not doing the assert before the calculation as the others ?

Suggested change
assert(c / a == b, 'SafeMath: multiplication overflow');
assert( b <= u64.MAX_VALUE / a, 'SafeMath: multiplication overflow');

* @returns Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*/
static div(a: u64, b: u64): u64 {
assert(b > 0, "SafeMath: division by zero");
const c = a / b;
assert(b > 0, 'SafeMath: division by zero');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert(b > 0, 'SafeMath: division by zero');
assert(b != 0, 'SafeMath: division by zero');

const c: u64 = a + b;
assert(c >= a, "SafeMath: addition overflow");
const c: u64 = a + b;
assert(c >= a, 'SafeMath: addition overflow');
Copy link
Contributor

Choose a reason for hiding this comment

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

should be done before the calculation

Suggested change
assert(c >= a, 'SafeMath: addition overflow');
assert(b <= u64.MAX_VALUE - a, 'SafeMath: addition overflow');

@Thykof Thykof mentioned this pull request Mar 3, 2023
@Thykof
Copy link
Contributor

Thykof commented Mar 3, 2023

Thanks @gregLibert for your code review, I have created a issue that reference it #102

@Ben-Rey Ben-Rey deleted the fix_test_ci_for_pr branch April 21, 2023 07:37
@Ben-Rey Ben-Rey mentioned this pull request Apr 27, 2023
17 tasks
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.

None yet

3 participants