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

Signed SafeMath #1559

Merged
merged 10 commits into from
Dec 18, 2018
Merged

Signed SafeMath #1559

merged 10 commits into from
Dec 18, 2018

Conversation

frangio
Copy link
Contributor

@frangio frangio commented Dec 14, 2018

Closes #835.
Fixes #705.

This PR includes @facuspagnuolo's code and tests from #835 with @cag's fix from facuspagnuolo#1. I've also reviewed @cag's proofs that the math doesn't overflow in #835 (comment) and they seem correct to me.

@frangio frangio added this to the v2.1 milestone Dec 14, 2018
@nventuro nventuro self-requested a review December 17, 2018 19:09
@nventuro nventuro added feature New contracts, functions, or helpers. contracts Smart contract code. labels Dec 17, 2018
contracts/math/SafeMath.sol Outdated Show resolved Hide resolved
contracts/math/SafeMath.sol Outdated Show resolved Hide resolved
contracts/math/SafeMath.sol Outdated Show resolved Hide resolved
test/math/SafeMath.test.js Show resolved Hide resolved
test/math/SafeMath.test.js Outdated Show resolved Hide resolved
it('reverts with a 0 divisor', async function () {
const a = new BigNumber(5678);
const b = new BigNumber(0);
describe('div', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unsigned integer division has a couple more tests this one is missing, should we add them?

@frangio
Copy link
Contributor Author

frangio commented Dec 18, 2018

Created #1563 to merge this as-is for 2.1 and improve testing afterwards.

@nventuro
Copy link
Contributor

Please add this to the changelog.

@frangio
Copy link
Contributor Author

frangio commented Dec 18, 2018

PTAL.

Copy link
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

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

Neat, LGTM!

@frangio frangio merged commit d17ae0b into OpenZeppelin:master Dec 18, 2018
@frangio frangio deleted the signed-safe-math branch December 18, 2018 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contracts Smart contract code. feature New contracts, functions, or helpers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve SafeMath to support signed int operations
3 participants