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

Add property-based tests for signers-voting contract functions #4403

Merged
merged 3 commits into from Feb 28, 2024

Conversation

moodmosaic
Copy link
Member

Description

Add property-based tests for signers-voting contract functions

  • reward-cycle-to-burn-height
  • burn-height-to-reward-cycle
  • is-in-prepare-phase

This effort, initially part of #4286, is now in a separate commit and PR as it's autonomous with regards to PoX-4 property and fuzz testing. Additional property-based tests for the remaining functions of the signers-voting contract are warranted and will be addressed in separate commits/PRs.

Applicable issues

Additional info (benefits, drawbacks, caveats)

Checklist

  • Test coverage for new or modified code paths
  • Changelog is updated
  • Required documentation changes (e.g., docs/rpc/openapi.yaml and rpc-endpoints.md for v2 endpoints, event-dispatcher.md for new events)
  • New clarity functions have corresponding PR in clarity-benchmarking repo
  • New integration test(s) added to bitcoin-tests.yml

Copy link

codecov bot commented Feb 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.40%. Comparing base (9385b42) to head (8d373fc).
Report is 1 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #4403      +/-   ##
==========================================
- Coverage   83.41%   83.40%   -0.02%     
==========================================
  Files         448      448              
  Lines      323930   323930              
==========================================
- Hits       270197   270158      -39     
- Misses      53733    53772      +39     

see 21 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9385b42...8d373fc. Read the comment docs.

friedger
friedger previously approved these changes Feb 27, 2024
Copy link
Collaborator

@friedger friedger left a comment

Choose a reason for hiding this comment

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

The tests for read-only functions look good.

Maybe variation over account is not necessary, as these are read-only functions that do not use tx-sender.

For a different PR, it might be interesting to check is-in-prepare-phase with block-height in a contract call vs read-only call.

Copy link
Collaborator

@hugocaillard hugocaillard left a comment

Choose a reason for hiding this comment

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

I left a couple of suggestions.
Also, would you consider adding a formatter (such as prettier)?
Happy to help on that

@moodmosaic
Copy link
Member Author

moodmosaic commented Feb 27, 2024

I left a couple of suggestions.

Thanks for the review!

Also, would you consider adding a formatter (such as prettier)? Happy to help on that

I always run deno ftm and go with the defaults from that. If we have some existing config for Prettier, happy to use that instead.

@hugocaillard
Copy link
Collaborator

Any formater is good as far as i'm concerned. But I was a bit surprised with this formatting

          pox_4_info.value.data[
            "first-burnchain-block-height"];

@moodmosaic
Copy link
Member Author

Any formater is good as far as i'm concerned. But I was a bit surprised with this formatting

          pox_4_info.value.data[
            "first-burnchain-block-height"];

me too, actually. It's left from when I was adding // @ts-ignore and making sure it won't ignore more than it should. Thanks 👍After I'm done checking #4403 (comment) I'll reformat and push.

- reward-cycle-to-burn-height
- burn-height-to-reward-cycle
- is-in-prepare-phase

This effort, initially part of #4286,
is now in a separate commit and PR as it's autonomous with regards to PoX-4
property and fuzz testing. Additional property-based tests for the remaining
functions of the signers-voting contract are warranted and will be addressed
in separate commits/PRs.
@moodmosaic
Copy link
Member Author

Addressed feedback, formatted using deno fmt and force-pushed. Ready for review @hugocaillard @friedger.

- Bump @stacks/transactions from ^6.9.0 to ^6.12.0 for `isClarityType`.
- Use `assert` and `isClarityType` for stricter TypeScript type checks.
- Replace `// @ts-ignore` with precise assertions, improving tests.

Thanks to Hugo Caillard for his crucial help and guidance.
Copy link
Collaborator

@hugocaillard hugocaillard left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@friedger friedger left a comment

Choose a reason for hiding this comment

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

:shipit:

@wileyj wileyj added this pull request to the merge queue Feb 28, 2024
Merged via the queue into next with commit d063a74 Feb 28, 2024
2 checks passed
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

5 participants