alexfertel/bulloak

Feature: Provide a way to specify condition names

Opened this issue · 1 comments

Discussed in #77

Originally posted by clauBv23 July 10, 2024
When testing complex code a common scenario scenario involves verifying specific behaviors under different setups. For example in Sablier V2 Core, the test tree looks like this:

             ...
            └── given all streams are warm
            ├── when the caller is unauthorized for all streams
            │  ├── when the caller is a malicious third party
            │  │  └── it should revert
            │  └── when the caller is the recipient
            │     └── it should revert
            ├── when the caller is unauthorized for some streams
            │  ├── when the caller is a malicious third party
            │  │  └── it should revert
            │  └── when the caller is the recipient
            │     └── it should revert
            ...

This tree structure checks that when the caller is a malicious third party and when the caller is the recipient should revert in both cases: when the caller is unauthorized for all streams and when the caller is unauthorized for some streams.

Using bulloak, this specification fails because in Solidity two functions or modifiers cannot have the same signature.

However, in the Sablier V2 Core repo this issue is managed by also appending the scenario description to the function name instead of just creating a modifier, as shown below:

function test_RevertWhen_CallerUnauthorizedAllStreams_MaliciousThirdParty()
        external
        whenNotDelegateCalled
        whenArrayCountNotZero
        givenNoNull
        givenAllStreamsWarm
        whenCallerUnauthorized
    

Is there a way to handle this in bulloak? or any workaround for this issue?

Perhaps a special word, character, or ASCII sequence in the tree, could be used to append the description to the function name?

Adding a comment to receive notifications on updates 👀 🔥