We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
As part of the great work in #38, we introduced a way to discard test cases using helper functions like:
(define-read-only (can-test-protocol-burn-balance-decrease (address principal) (amount uint)) (and (is-eq tx-sender deployer) (not (is-eq amount u0)) (not (> amount (unwrap-panic (get-balance-available address)))) ) ) (define-public (test-protocol-burn-balance-decrease (address principal) (amount uint)) (let ( (initial-balance (unwrap-panic (get-balance-available address))) ) (ok (begin (try! (protocol-burn amount address)) (asserts! (is-eq (unwrap-panic (get-balance-available address)) (- initial-balance amount)) ERR_FAILED_ASSERTION) true))))
While functional, this approach doesn't scale well for larger codebases:
Instead of using discard functions, we could simplify by signaling discards at the type level:
ok(true)
ok(false)
(define-public (test-protocol-burn-balance-decrease (address principal) (amount uint)) (let ( (initial-balance (unwrap-panic (get-balance-available address))) ) (ok (if (or (not (is-eq tx-sender deployer)) (is-eq amount u0) (> amount initial-balance)) false ;; Test is discarded. (begin (try! (protocol-burn amount address)) (asserts! (is-eq (unwrap-panic (get-balance-available address)) (- initial-balance amount)) ERR_FAILED_ASSERTION) ;; Test fails. true))))) ;; Test passes.
This eliminates the need for separate discard functions, reducing boilerplate and improving maintainability.
The text was updated successfully, but these errors were encountered:
(ok false)
Successfully merging a pull request may close this issue.
As part of the great work in #38, we introduced a way to discard test cases using helper functions like:
While functional, this approach doesn't scale well for larger codebases:
Instead of using discard functions, we could simplify by signaling discards at the type level:
ok(true)
: Test passes.ok(false)
: Test is discarded.This eliminates the need for separate discard functions, reducing boilerplate and improving maintainability.
The text was updated successfully, but these errors were encountered: