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

Switch to Foundry cheatcodes from DSTest #476

Closed
palinatolmach opened this issue Mar 22, 2024 · 2 comments
Closed

Switch to Foundry cheatcodes from DSTest #476

palinatolmach opened this issue Mar 22, 2024 · 2 comments
Assignees
Labels
engagement enhancement New feature or request

Comments

@palinatolmach
Copy link
Collaborator

palinatolmach commented Mar 22, 2024

As @lucasmt identified, a failed DSTest assertion such as assertLt does not cause the test to revert and fail immediately. Instead, fail() function stores bytes32(uint256(0x01)) at the storage slot bytes32("failed"), which is only checked at the end of the execution as part of foundry_success predicate. Although it is probably expected behavior, it would be more efficient if we allowed Kontrol to identify the test as failing sooner if a DSTest assertion check has failed.

Behavior of DSTest assertions such as assertEq changed to revert immediately with forge-std >= 1.8.0, where support for DSTest was dropped in favor of native Foundry assertions (vm.assertEq(...)), which causes errors such as

  Node id: 22
  Failure reason:
    Matching failed.
    The following cells failed matching individually (antecedent #Implies consequent):
    K_CELL: #error_foundry selector ( "assertEq(uint256,uint256)" ) b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xff\xee\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xff\xee"
    ~> #return_foundry 160 0
    ~> #pc [ STATICCALL ]
    ~> #execute #Implies #halt ~> .K
    ~> CONTINUATION:K
    ACCOUNTS_CELL: <account>
...
@yale-vinson yale-vinson added enhancement New feature or request engagement labels Mar 26, 2024
@palinatolmach palinatolmach changed the title Fail fast on DSTest assertions Switch to Foundry cheatcodes from DSTest Mar 26, 2024
@anvacaru anvacaru self-assigned this Mar 26, 2024
@anvacaru
Copy link
Contributor

@palinatolmach I think that we can close this one.

@palinatolmach
Copy link
Collaborator Author

Mostly addressed by #507 and #558, a remaining portion of assertions will be added in #562.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engagement enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants