Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
While working in related code, I noticed the existing tests related to voting could use some improvement since they are rather inconsistent with the rest of the code base and are otherwise rather difficult to follow given they use a bunch of magic numbers, reference inconsistent global definitions, and don't really explain what it is they're intending to test. I also noticed they have some off by ones such that they aren't actually testing the edge conditions as was likely intended. This fully reworks the tests to address the aforementioned points and also takes the opportunity to make them more compact and improve their coverage in the process. They are also hopefully significantly easier to follow now as well both from the code structure itself and the new comments that describe what they actually intend to test. Quantifying the improvement to compactness, this includes all of the aforementioned improvements and comes in just under 540 less lines of code. Since it adds 357 additional lines of comments, the overall absolute reduction in the diff size is 180 lines. The following is an overview of the changes: - Convert tests to run all votes in the deployment in parallel - Create locally-scoped mock vote definitions for the deployment - Use named values for all vote bits extracted from the definitions - Calculate all critical values (edge conditions, intervals, etc) from the parameters so they will remain correct even if the params change - Combine and expand all tests related to parallel voting and quorum - Add additional tests for several edge conditions - Add additional test for attempting to reverse a vote with a different majority choice - Make every test check the states of all votes in the deployment for extra added assurance of correctness
- Loading branch information