-
Notifications
You must be signed in to change notification settings - Fork 1
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
Support state transitions for dependent contracts during invariant testing #97
Comments
Thanks to @BowTiedBlox for pointing out this idea! |
It's an interesting idea but tricky in practice. Covering every contract in the dependency chain risks combinatorial explosion, as the state space grows rapidly. Mocks and stubs (and Test Doubles in general) may actually help here. Imagine that the main contract (SUT) manages positions for a CLMM/DEX pool (e.g., a vault). It interacts with the pool's range, tick, and math functions, plus other libraries. Targeting the entire dependency chain (pool code, price oracles, etc.) makes the complexity unmanageable. We likely only care about how the vault updates user liquidity or handles rebalances. Test Doubles help simulate relevant pool state changes (e.g., tick moves, fees, liquidity updates), helping detect the unexpected without integrating the full DEX code. This questioning also applies to example/unit-based and property-based testing: in the context of testing the SUT, is there a use case where touching all its dependencies uncovered a bug missed otherwise? |
@moodmosaic Thank you for the detailed and well-documented comment, as always! Based on the For example, if a stacking pool contract depends on (contract-call? .pox-4 function-name function-args)
;; becomes
(function-name (function-args))
;; where function-name is temporarily moved to the SUT for fuzz testing purposes However, we can still cause state transitions in the boot contracts (including pox-4), as they are responsible for the chain functionality and advancement. |
Yes, if |
When a smart contract depends on another contract (e.g., a function in the target contract calls another contract), include state transitions for all contracts in the dependency chain during invariant testing. This means:
This approach ensures state transitions across the entire dependency chain, improving the accuracy of invariant testing.
The text was updated successfully, but these errors were encountered: