Skip to content

Conversation

@funkyenough
Copy link
Collaborator

@funkyenough funkyenough commented May 27, 2025

Fix natspec and remove setUp in StakerTestBase

  • Add contract level natspec
  • Add test level natspec
  • Remove unused slither comments
  • Remove setUp in StakerTestBase and inheriting contracts

@funkyenough funkyenough requested a review from alexkeating May 28, 2025 15:00
@funkyenough funkyenough marked this pull request as ready for review May 29, 2025 14:13
Copy link
Collaborator

@alexkeating alexkeating left a comment

Choose a reason for hiding this comment

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

Great start, left a few comments!

/// Simulates calling notify function on MintRewardNotifier.
/// @title MintRewardNotifierTestBase
/// @author [ScopeLift](https://scopelift.co)
/// @notice Base contract for testing `MintRewardNotifier` functionality. Extends `StakerTestBase`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// @notice Base contract for testing `MintRewardNotifier` functionality. Extends `StakerTestBase`
/// @notice Base contract for testing a staker contract with a single mint reward notifier. Extends `StakerTestBase`

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in a0cac50
Modified other test base comments as well.

/// @title MintRewardNotifierTestBase
/// @author [ScopeLift](https://scopelift.co)
/// @notice Base contract for testing `MintRewardNotifier` functionality. Extends `StakerTestBase`
/// and provides the necessary setup for the `notify` on `MintRewardNotifier`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// and provides the necessary setup for the `notify` on `MintRewardNotifier`.
/// and implements the necessary notifying a reward.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure about the English phrasing here, so I went with implements the reward notification logic in a0cac50. What do you think?

/// @notice Base contract for testing `MintRewardNotifier` functionality. Extends `StakerTestBase`
/// and provides the necessary setup for the `notify` on `MintRewardNotifier`.
/// @dev This contract is designed to be used in conjunction with the deployment scripts in
/// `src/script/notifiers/DeployMintRewardNotifier.sol`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

They don't need to use our deployment scripts. They can have their own, but they need to make sure the test contract sets a mintRewardNotifier.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in a0cac50

/// @notice This abstract contract provides a common foundation and essential helper functions for
/// constructing modular integration tests. It is designed to be inherited by test suites that
/// verify the functionality of Staker contracts, various reward notifiers and earning power
/// calculators.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add an example here of what this inheritance will look like.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added example here a0cac50, open to feedback!

/// This includes tests for single and multiple depositors staking and earning rewards
/// over various timeframes and reward periods.
/// @dev Inherit this contract to test the fundamental staking and reward accrual logic of a Staker
/// implementation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would be more specific here which staking logic. It doesn't need to be exhaustive but it may be good to indicate in scenarios of single, multiple stakers, multiple periods etc...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would also think about this for the other test examples as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added more descriptions for all bases in a0cac50

/// calculated earned rewards.
/// @param _depositor The address of the staker.
/// @param _amount The amount of stake tokens to deposit.
/// @param _delegatee The address to delegate voting power to.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The

Suggested change
/// @param _delegatee The address to delegate voting power to.
/// @param _delegatee The address with the stake's voting power.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed all instances of _delegatee in a0cac50

/// used in conjunction with the deployment scripts in
/// @notice Base contract for testing `TransferRewardNotifier` functionality. Extends
/// `StakerTestBase`
/// and provides the necessary setup for `notify` on `TransferRewardNotifier`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Weird wrapping here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in a0cac50

/// `StakerTestBase`
/// and provides the necessary setup for `notify` on `TransferRewardNotifier`.
/// @dev This contract is designed to be used in conjunction with the deployment scripts in
/// `src/script/notifiers/DeployTransferRewardNotifier.sol`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add more detail here

@funkyenough funkyenough force-pushed the feature/modular-testing-natspec branch from a0cac50 to 7d33b4b Compare June 4, 2025 07:14
@funkyenough
Copy link
Collaborator Author

funkyenough commented Jun 4, 2025

Given that StakedBinaryEligibilityOracleEarningPowerCalculatorTestBase is expected to be removed in subsequent PR, I decided not to update its natspec.

@github-actions
Copy link

github-actions bot commented Jun 4, 2025

Coverage after merging feature/modular-testing-natspec into feature/modular-testing will be

100.00%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   DelegationSurrogate.sol100%100%100%100%
   DelegationSurrogateVotes.sol100%100%100%100%
   Staker.sol100%100%100%100%
src/calculators
   BinaryEligibilityOracleEarningPowerCalculator.sol100%100%100%100%
   IdentityEarningPowerCalculator.sol100%100%100%100%
src/extensions
   StakerCapDeposits.sol100%100%100%100%
   StakerDelegateSurrogateVotes.sol100%100%100%100%
   StakerOnBehalf.sol100%100%100%100%
   StakerPermitAndStake.sol100%100%100%100%
src/notifiers
   MintRewardNotifier.sol100%100%100%100%
   RewardTokenNotifierBase.sol100%100%100%100%
   TransferFromRewardNotifier.sol100%100%100%100%
   TransferRewardNotifier.sol100%100%100%100%

@funkyenough funkyenough requested a review from alexkeating June 4, 2025 14:17
@alexkeating alexkeating merged commit b33295f into feature/modular-testing Jun 4, 2025
6 checks passed
alexkeating added a commit that referenced this pull request Jun 4, 2025
---------

Co-authored-by: Alexander Keating <keating.dev@protonmail.com>

Add modular testing natspec (#150)

* Add modular testing natspec
alexkeating added a commit that referenced this pull request Jun 4, 2025
---------

Co-authored-by: Alexander Keating <keating.dev@protonmail.com>

Add modular testing natspec (#150)

* Add modular testing natspec
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