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

Feature request: special naming for the final leaf test #37

Open
PaulRBerg opened this issue Sep 28, 2023 · 1 comment
Open

Feature request: special naming for the final leaf test #37

PaulRBerg opened this issue Sep 28, 2023 · 1 comment
Labels
Feat New feature or request Uphill Needs research before being implemented

Comments

@PaulRBerg
Copy link
Contributor

PaulRBerg commented Sep 28, 2023

Context

In Sablier V2, we've applied this heuristic whereby the final leaves in the tree result in a Solidity test that bears the name of the function itself. Here's an example:

https://github.com/sablier-labs/v2-core/blob/52df5c15da76e47ca396fcf4986fefade0db237f/test/integration/concrete/comptroller/set-protocol-fee/setProtocolFee.t.sol#L43

The rationale is that the final leaf is in many ways the "happiest of all happy paths", i.e., what the developer hopes the user's txs will end up effecting in the vast majority of cases. It is thus helpful to give this leaf a privilege; separately, it may also be useful when visualizing a gas snapshot/ report.

Since tree files must begin with the name of the test contract (#3), the name of the function could be extracted from there by removing the Test suffix.

Input

Given the following tree:

SimpleBranchTest
├── when x is false
│   └── it should revert
└── when x is true
    └── it should return x

Output

I would like bulloak scaffold to produce the following output:

pragma solidity 0.8.0;

contract SimpleBranchTest {
  function test_RevertWhen_XIsFalse() external {
    // it should revert
  }
  
  modifier whenXIsTrue() {
       _;
  }

  function test_SimpleBranch() external whenXIsTrue {
    // it should return x
  }
}
@PaulRBerg
Copy link
Contributor Author

A corollary of this feature (if it gets implemented) is that the check command would have to be adjusted to accept both possible names, i.e.

  • test_WhenXIsTrue
  • test_SimpleBranch

@alexfertel alexfertel added Feat New feature or request Uphill Needs research before being implemented labels Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feat New feature or request Uphill Needs research before being implemented
Projects
None yet
Development

No branches or pull requests

2 participants