-
Notifications
You must be signed in to change notification settings - Fork 6
Combinatorial MultiToken _transferFrom unit test #60
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
69f0172 to
52c082a
Compare
Pull Request Test Coverage Report for Build 4186351439
💛 - Coveralls |
8640973 to
969eb01
Compare
52c082a to
5648e15
Compare
jalextowle
left a comment
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 think you did a great job with this framework. It's a great addition to the repo. Aside from the other comments that I left, I have two requests. First, I'd appreciate using combinatorial instead of combi. Since every shell worth its salt has tab auto-completion for files, there isn't a compelling reason to use the abbreviation IMO. Second, I'd like to see more comments in the combinatorial test. Specifically in the functions that really matter (__fail and __success).
My comments should be addressed before merging, but I will approve since it LGTM once those comments are addressed.
* Use safe functions more consistently in `calculateNetCurveTradeSafe` * Fail if `calculateSharesOutGivenBondsInDownSafe` underflows * Fixed the rust tests * Improved the system's liveness when the present value can't be computed * Improved the liveness properties of `removeLiquidity` * Ignore `calculateLPSharePrice` failures in `removeLiquidity` * Fixed small typo * Addressed review feedback from @cmichel * Added a check on `addLiquidity` in `test_netting_extreme_positive_interest_time_elapsed` * Post merge fixes
This PR adds unit tests for
MultiToken._transferFrom(). In addition it also provides some framework guidance on how "combinatorial" unit tests are to be constructed differing to the design inprotocolv2to better structure and reduce line count.The tests are constructed with a fix sender
from(Alice) and receiverto(Bob). Also all transfers contain acallercontext which will either be Alice for a direct transfer or Eve for an approved transfer of which there are two kinds - a global approvalisApprovedForAlland aperTokenApprovalwhich is self-evident. Error cases involve an underflow on the non-infinite approvalm, thefrombalance updates and an overflow on to balance updates.To note we may want to consider a more explicative error messaging especially in context of the non-infinite approval underflow which would be more considerate for frontends.
As stated, this PR should highlight an arguably cleaner approach to our combinatorial unit testing framework which we have used previously in protocolV2.
As shown, a combinatorial test should be 1 test per file and in so far as possible define 4 functions,
__setup,__fail,__successand__logwhich ought to provide a template for test construction.__setup- teardown and setup of contract state in context of each test case__fail- validates if the test case ought to produce an error and attempts to catch that error. Must return a boolean so that the success phase can be short-circuited if an error is expected.__success- If applicable, event registration and state caching can be made before the call to the function under test. State validation follows.__log- logs test case values for debugging purposes