Skip to content

Add flag: returnBool for property testing#660

Open
montyly wants to merge 7 commits into
crytic:masterfrom
montyly:feature-returnBool
Open

Add flag: returnBool for property testing#660
montyly wants to merge 7 commits into
crytic:masterfrom
montyly:feature-returnBool

Conversation

@montyly

@montyly montyly commented Aug 4, 2025

Copy link
Copy Markdown
Contributor

returnBool set to false will make medusa accept properties that don't return a boolean.

This is meant to mimic foundry's behavior, and ease the compatibility between the two tools. See https://getfoundry.sh/forge/advanced-testing/invariant-testing/#conditional-invariants

@elopez elopez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR! I'm overall confused about the feature though, wouldn't a property that does not return a boolean not be a property? It sounds like it would be something for the assertion testing mode instead.

Comment thread docs/src/project_configuration/testing_config.md Outdated
Comment thread docs/src/testing/writing-tests.md Outdated
Comment thread docs/src/static/medusa.json Outdated
Comment thread docs/src/static/function_level_testing_medusa.json Outdated
Comment thread fuzzing/config/config.go
TestPrefixes []string `json:"testPrefixes"`

// TestReturnBool dictactes if the properties should return a bool or not
TestReturnBool bool `json:"returnBool"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

but maybe it needs to be unified the other way to testReturnBool? it seems JSON options match their Go counterparts.

Comment thread fuzzing/test_case_property_provider.go Outdated
@montyly

montyly commented Aug 4, 2025

Copy link
Copy Markdown
Contributor Author

@elopez the way I have seen people using it in foundry setup is basically that the invariant_ functions should not revert.

It would be the same as having require(return_variable)

@dguido

dguido commented Jan 20, 2026

Copy link
Copy Markdown
Member

@montyly - This PR has been waiting for feedback since August. Could you respond to @elopez's question about whether this should be assertion testing mode instead of property testing? Once that's clarified, a rebase would be needed to resolve conflicts.

Resolve conflicts in fuzzing/utils/fuzz_method_utils.go by combining:
- PR crytic#660's propertyTestReturnBool parameter for flexible property testing
- Master's warning message return values for invalid test signatures

The merged IsPropertyTest() now accepts propertyTestReturnBool and returns
(bool, string) to support both features simultaneously.

Also fix dprint.json to use correct yaml plugin URL (add missing 'v' prefix),
and fix markdown formatting in docs.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@dguido dguido requested a review from samalws-tob as a code owner January 22, 2026 06:01
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.

3 participants