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

feat: Use RDTTestBase (SC-5205) #42

Merged
merged 4 commits into from
Mar 16, 2022
Merged

feat: Use RDTTestBase (SC-5205) #42

merged 4 commits into from
Mar 16, 2022

Conversation

lucas-manuel
Copy link

Added a base test to remove duplicate code

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #5205: [rdt] Refactor tests to use functions for assertions.

address notStaker;
bytes constant ARITHMETIC_ERROR = abi.encodeWithSignature("Panic(uint256)", 0x11);

uint256 constant START = 10_000_000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add internal modifier?

}

// Deposit asset into RDT
function _depositAsset(address asset_, address staker_, uint256 depositAmount_) internal {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can remove the asset from the input parameters since it's already a state variable.

}

// Transfer funds into RDT and update the vesting schedule
function _transferAndUpdateVesting(address asset_, address rdToken_, uint256 vestingAmount_, uint256 vestingPeriod_) internal {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can remove asset and rdToken from the input parameters since they're already state variables.
Same for all the other utility functions where state variables are available.

}

// Returns a valid `permit` signature signed by this contract's `owner` address
function _getValidPermitSignature(uint256 value_, address owner_, address spender_, uint256 ownerSk_, uint256 deadline_) internal returns (uint8 v_, bytes32 r_, bytes32 s_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Reorder params to match order in which they are used in the function body.

notOwner = new Owner();
owner = new Owner();
asset = new MockERC20("MockToken", "MT", 18);
rdToken = new RDT("Revenue Distribution Token", "RDT", address(owner), address(asset), 1e30);
vm.warp(START);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add new line here.


uint256 constant sampleAssetsToConvert = 1e18;
uint256 constant sampleSharesToConvert = 1e18;

address staker;
address notStaker;
bytes constant ARITHMETIC_ERROR = abi.encodeWithSignature("Panic(uint256)", 0x11);
Copy link
Contributor

Choose a reason for hiding this comment

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

How about adding this to TestUtils directly?

@lucas-manuel lucas-manuel merged commit c5920bd into main Mar 16, 2022
@lucas-manuel lucas-manuel deleted the sc-5205-use-test-base branch March 16, 2022 23:51
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.

2 participants