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

Feature/uint enumerable set tests #2253 #2254

Conversation

julianmrodri
Copy link
Contributor

@julianmrodri julianmrodri commented May 31, 2020

#2253

Fixes #2253

Implemented the required tests for UintSet following the same approach taken for AddressSet, and implementing a common behavior.. Regarding the Mock contract I split the implementation in two separate contracts one for AddressSet and one for UintSet.

All linter checks and tests running correctly.

Files modified:

  • test/utils/EnumerableSet.test.js
  • test/utils/EnumerableSet.behavior.js (added)
  • contracts/mocks/EnumerableSetMock.sol

@julianmrodri
Copy link
Contributor Author

@nventuro @frangio This PR is ready to be reviewed. I noticed we were missing tests for EnumerableSet.UintSet so I added them.

I recommend looking at each commit individually in order to easily understand the changes, as they got mixed quite ugly by Github at the file level.

@nventuro
Copy link
Contributor

nventuro commented Jun 1, 2020

Hm, it seems like I overlooked this when adding UintSet and the generic Set.

We could follow the approach taken in this PR, though it would increase complexity and number of tests in the suite. A way to do it might be to have a set behavior that receives three values, and then call it for each set type:

describe('EnumerableSet', function () {
  describe('AddressSet', function () {
    shouldBehaveLikeSet(accountA, accountB, accountC);
  });
  
  describe('UintSet', function () {
    shouldBehaveLikeSet(numberA, numberB, numberC);
  });
});

Alternatively we could just test the Set and assume that the specialized variants (which aren't more than casts) are implemented correctly. An issue with this is that Set's functions are private, so exposing those would be an issue. If we assume the casts are correct, then just testing any variant (like the current AddressSet tests) should suffice.

@frangio what do you think?

@julianmrodri
Copy link
Contributor Author

Thanks @nventuro. I like the first proposal you mention. IMHO it is better to do that instead of just assuming the casts are correct. Even though they are basically casts, it is also quite a bunch of code that would remain uncovered (for UintSet for example )

@frangio
Copy link
Contributor

frangio commented Jun 1, 2020

I think it's desirable to test each typed variant separately. Using a behavior sounds like a good approach.

@nventuro
Copy link
Contributor

nventuro commented Jun 1, 2020

Awesome! @julianmrodri do you think you can go ahead and implement the tests in the way described above?

@julianmrodri
Copy link
Contributor Author

julianmrodri commented Jun 1, 2020 via email

@frangio
Copy link
Contributor

frangio commented Jun 1, 2020

Thank you for the awesome contributions!

@julianmrodri
Copy link
Contributor Author

@nventuro @frangio This is ready to be Reviewed. It is implemented using behavior. Looks much better, thanks for this suggestion.

@julianmrodri julianmrodri force-pushed the feature/uintEnumerableSet-tests-#2253 branch from 7e731e0 to 9debca1 Compare June 4, 2020 14:44
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.

This looks great @julianmrodri, thank you very much for your help!

@nventuro nventuro merged commit d7a6e7b into OpenZeppelin:master Jun 4, 2020
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.

Missing Tests for EnumerableSet.UintSet
3 participants