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

Staking manager unit tests #476

Merged
merged 31 commits into from
Aug 7, 2024
Merged

Conversation

cam-schultz
Copy link
Contributor

Why this should be merged

  • Adds unit tests for the happy path for validator regestration and delisting.

  • Adds unit tests for StakingMessages packing/unpacking functions

  • Adds methods to StakingMessages to achieve full packing/unpacking parity

  • NativeTokenStakingManager initializes StakingManager

  • Early return from churn check if max rate is set to 0

  • Identifies a number of additional test cases that will be implemented later

How this was tested

forge test

How is this documented

N/A


contract NativeTokenStakingManager is StakingManager, INativeTokenStakingManager {
using Address for address payable;

constructor(StakingManagerSettings memory settings) {

Choose a reason for hiding this comment

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

we should avoid pasing through constructor since the contract is meant to be upgradeable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll wait to merge this PR until after #477, and update all the constructor/initialize calls then.

registrationTimestamp: 1000,
completionTimestamp: 2000
});
bytes memory setValidatorWeightPayload =

Choose a reason for hiding this comment

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

can add a using statement for the IDs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you suggesting adding using for validationID so we can call certain packing methods directly on the validationID? My hesitation there is that not all of the methods take validationID's, and I'd prefer consistent notation.

@michaelkaplan13 michaelkaplan13 requested a review from ceyonur August 2, 2024 21:55
* @param uptime The uptime of the validator.
* @return The packed message.
*/
function packValidationUptimeMessage(

Choose a reason for hiding this comment

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

does abi.encodePacked work for these packs? ref: #482

Copy link

@minghinmatthewlam minghinmatthewlam left a comment

Choose a reason for hiding this comment

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

LGTM, happy to get this in the WIP draft first before too many changes to that branch

@cam-schultz cam-schultz merged commit 9338b32 into staking-contract Aug 7, 2024
12 checks passed
@cam-schultz cam-schultz deleted the staking-manager-unit-tests branch August 8, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants