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

test: bulker #765

Merged
merged 23 commits into from
Apr 18, 2023
Merged

test: bulker #765

merged 23 commits into from
Apr 18, 2023

Conversation

pakim249CAL
Copy link
Contributor

Separate PR for testing the bulker to prevent clutter in the feat PR while I work on this.

@pakim249CAL pakim249CAL changed the title test: add test layout and approve test test: bulker Apr 11, 2023
@pakim249CAL pakim249CAL requested review from Rubilmax, MerlinEgalite and makcandrov and removed request for Rubilmax and MerlinEgalite April 14, 2023 13:41
@pakim249CAL pakim249CAL marked this pull request as ready for review April 14, 2023 13:42
Copy link
Contributor

@MerlinEgalite MerlinEgalite left a comment

Choose a reason for hiding this comment

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

Nice !! 🔥

Some suggestions to improve the testing suite as I think it's not 100% complete:

  • Add some random (or not if too complex) sequences of tx because we are only testing one tx at a time
  • Make sure that it's not possible to borrow, withdraw on behalf of someone else. Example: Alice deposits some WETH as collateral, bob should be able to borrow, withdrawCollateral in any way

test/extensions/TestExtensionsBulker.t.sol Outdated Show resolved Hide resolved
(actions[0], data[0]) = _getWrapStETHData(amount);

bulker.execute(actions, data);
assertEq(ERC20(sNative).balanceOf(address(bulker)), IWSTETH(sNative).getWstETHByStETH(amount), "bulker balance");
Copy link
Contributor

Choose a reason for hiding this comment

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

in general you also test that the stETH balance is zero

assertApproxEqAbs(morpho.borrowBalance(borrowedMarket.underlying, delegator), 0, 2, "onBehalf borrow balance");
}

// asset amount receiver maxiterations
Copy link
Contributor

Choose a reason for hiding this comment

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

to remove I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, yes. I put this as a note for myself so I wouldn't have to reference later haha.

Copy link
Contributor

@MerlinEgalite MerlinEgalite left a comment

Choose a reason for hiding this comment

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

Requesting changes then

@pakim249CAL
Copy link
Contributor Author

Make sure that it's not possible to borrow, withdraw on behalf of someone else. Example: Alice deposits some WETH as collateral, bob should be able to borrow, withdrawCollateral in any way

I agree with your other points, but this particular one I'm not sure we can actually address. There is simply no entry point to ever do an action on behalf of anyone else in the bulker, as the parameters sent to Morpho are strictly based on msg.sender. So testing this would simply be testing msg.sender.

Copy link
Collaborator

@Rubilmax Rubilmax left a comment

Choose a reason for hiding this comment

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

The test suite could be extended with invariant tests in order to test several actions one after the others (I can work on it)

src/interfaces/ILido.sol Outdated Show resolved Hide resolved
test/extensions/TestExtensionsBulker.t.sol Outdated Show resolved Hide resolved
test/extensions/TestExtensionsBulker.t.sol Outdated Show resolved Hide resolved
@pakim249CAL
Copy link
Contributor Author

The test suite could be extended with invariant tests in order to test several actions one after the others (I can work on it)

I think we can consider invariant tests to be in a different scope and can be completely separated into another PR.

@pakim249CAL pakim249CAL merged commit 518c4fc into feat/bulker Apr 18, 2023
@pakim249CAL pakim249CAL deleted the test/bulker branch April 18, 2023 15:09
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.

4 participants