stacks-network / clarity-wasm

`clar2wasm` is a compiler for generating WebAssembly from Clarity.
GNU General Public License v3.0
12 stars 12 forks source link

Proptests for stx functions #397

Closed Acaccia closed 4 months ago

Acaccia commented 4 months ago

This PR adds property tests for the functions stx-burn?, stx-get-balance, stx-transfer?, stx-transfer-memo?.

To use random amounts in the tests, some adaptations were made to the TestEnvironment.

All those functions suffered from a wrong conversion of the amount (i64, i64) -> u128.

This PR is part of #261 .

It will currently fail the CI until we merge #396 . done

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 86.00000% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 86.94%. Comparing base (c577461) to head (c7ad521).

Files Patch % Lines
clar2wasm/src/tools.rs 85.41% 4 Missing and 3 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #397 +/- ## ========================================== - Coverage 86.95% 86.94% -0.02% ========================================== Files 43 43 Lines 18291 18325 +34 Branches 18291 18325 +34 ========================================== + Hits 15905 15932 +27 - Misses 1046 1053 +7 Partials 1340 1340 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Acaccia commented 4 months ago

@csgui No need to test for unhappy path in the proptests, it's done in the unit tests. Here we prove that any values read by the host function is correct. And since we have this proof, we know that the unit tests for the unhappy path are sufficient.

csgui commented 4 months ago

@csgui No need to test for unhappy path in the proptests, it's done in the unit tests. Here we prove that any values read by the host function is correct. And since we have this proof, we know that the unit tests for the unhappy path are sufficient.

@Acaccia Yep, I know that. But for functions and operations dealing with amounts and value transfers, I take extra care with testing. And seems that there is no unit tests to cover unhappy path for the stx-transfer-memo? 😉

Approving this PR and opening an issue to improve the stx-transfer-memo? unit tests.