Skip to content

chore(tests): Add BasisModule <> SlippageIssuance Integration Tests #229

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

Merged
merged 7 commits into from
Apr 11, 2022

Conversation

0xSachinK
Copy link
Contributor

@0xSachinK 0xSachinK commented Mar 22, 2022

Review suggestions

  • Remove duplicated tests
    • Removed duplicated issuance tests in 7fa3e3e
    • Added comments to explain which parts are tested and which skipped along with reasons.
  • Tests for redemption when funding is non-zero (Added here and here)
  • Use getRedemptionAdjustment in a redemption flow to test the UI flow (Added in 9b88be4)

Additions to unit tests

  • Setting the performance fee after withdrawing with different amounts (897a00b)
  • Deposit entire withdrawn amount (b46101e)

@0xSachinK 0xSachinK changed the title feat(tests): Add BasisModule <> SlippageIssuance integration tests fix(tests): Add BasisModule <> SlippageIssuance integration tests Mar 22, 2022
@cgewecke cgewecke changed the title fix(tests): Add BasisModule <> SlippageIssuance integration tests fix:(tests) Add BasisModule <> SlippageIssuance integration tests Mar 22, 2022
@cgewecke cgewecke changed the title fix:(tests) Add BasisModule <> SlippageIssuance integration tests fix(tests): Add BasisModule <> SlippageIssuance integration tests Mar 22, 2022
@cgewecke
Copy link
Contributor

(Closing and re-opening to see if that fixes semantic release bot failure)

@cgewecke cgewecke closed this Mar 22, 2022
@cgewecke cgewecke reopened this Mar 22, 2022
@cgewecke cgewecke changed the title fix(tests): Add BasisModule <> SlippageIssuance integration tests fix(tests): Add BasisModule <> SlippageIssuance Integration Tests Mar 22, 2022
@cgewecke cgewecke changed the title fix(tests): Add BasisModule <> SlippageIssuance Integration Tests fix(tests): Add BasisModule <> SlippageIssuance integration tests Mar 22, 2022
@cgewecke cgewecke closed this Mar 22, 2022
@cgewecke cgewecke reopened this Mar 22, 2022
@cgewecke cgewecke changed the title fix(tests): Add BasisModule <> SlippageIssuance integration tests fix(tests): Add BasisModule <> SlippageIssuance Integration Tests Mar 22, 2022
@0xSachinK 0xSachinK requested review from bweick and cgewecke and removed request for bweick March 22, 2022 17:53
Copy link
Contributor

@cgewecke cgewecke left a comment

Choose a reason for hiding this comment

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

I wonder if we should use this to look at scenarios that are more specific to the Basis module. Its moduleIssuance and component hooks are identical with PerpV2LeverageModuleV2 which already runs all these tests.

Might be interesting to remove cases duplicated by the other test file and look at:

  • redemption where funding is non-zero
  • what happens when calling methods like withdrawFundingAndAccrueFees
  • using getRedemptionAdjustments in a redemption flow.
  • reproducing the revert Iosiro reported when depositing after a withdrawal
  • setting the performance fee after withdrawing with different amounts.

I know some of these are annoying to set very specific expectations for but it seems useful to exercise different scenarios and make sure there are no surprises when methods with new logic are called in combination.

@0xSachinK What do you think?

@0xSachinK
Copy link
Contributor Author

0xSachinK commented Mar 24, 2022

@cgewecke

  1. Added in f66a973d4.
  2. Tests for withdrawFundingAndAccrueFees are added as part of unit tests.
  3. How do we use getRedemptionAdjustments in the redemption flow? Can you give a specific example? We do have tests for getRedemptionAdjustments as part of unit tests.
  4. Added tests for depositing entire withdrawn amount in b46101. I was unable to reproduce the bug reported by iosiro, but working on it.
  5. Added tests for setting performance fee after pushing tracked settled funding to zero by withdrawing and funding in 897a00b.

@cgewecke
Copy link
Contributor

How do we use getRedemptionAdjustments in the redemption flow? Can you give a specific example? We do have tests for getRedemptionAdjustments as part of unit tests

I'm thinking of something that models what happens at set-ui...

// Displayed
units = slippageIssuanceModule
  .callStatic
  .getRequiredComponentRedemptionUnitsOffChain(setToken, quantity);

// Real
slippageIssuanceModule.redeem(setToken, quantity)

// Test
Does displayed units match the redeem transaction outcome?

Does that make sense?

@0xSachinK
Copy link
Contributor Author

0xSachinK commented Mar 24, 2022

@cgewecke Added in 9b88be4

@0xSachinK 0xSachinK force-pushed the sachin/basis-sim-integration-tests branch from 7fa3e3e to f33678c Compare April 11, 2022 12:41
@0xSachinK
Copy link
Contributor Author

0xSachinK commented Apr 11, 2022

Edited PR description to track all fixes.
Rebased branch to master.

@0xSachinK 0xSachinK requested a review from cgewecke April 11, 2022 12:42
Copy link
Contributor

@cgewecke cgewecke left a comment

Choose a reason for hiding this comment

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

This is looking really good. I think the only remaining question is about the revert Iosiro triggered when depositing after a withdrawal. They suggested we airdrop into the Set (from Telegram):

WDYT about this and should we consider using Airdrop module or something to manage it?

EDIT - sorry now I see you've addressed this in the audit PR.

// tested in the PerpV2BasisTradingModule unit tests (test/protocol/modules/perpV2BasisTradingModule.spec.ts). And the
// functionality to set external position unit before issuance, has been tested in the PerpV2LeverageModuleV2 <> SlippageIssuanceModule
// integration tests (test/integration/perpV2LeverageV2SlippageIssuance.spec.ts). Hence we will not restest them here.
describe("#issuance", () => {});
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@cgewecke cgewecke self-requested a review April 11, 2022 16:59
Copy link
Contributor

@cgewecke cgewecke left a comment

Choose a reason for hiding this comment

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

LGTM! I guess we could merge here and rebase #232 against it in case additional integration tests would be helpful there.

@cgewecke cgewecke changed the title fix(tests): Add BasisModule <> SlippageIssuance Integration Tests chore(tests): Add BasisModule <> SlippageIssuance Integration Tests Apr 11, 2022
@0xSachinK 0xSachinK merged commit 361728a into master Apr 11, 2022
@0xSachinK 0xSachinK deleted the sachin/basis-sim-integration-tests branch April 11, 2022 17:43
@cgewecke
Copy link
Contributor

🎉 This PR is included in version 0.9.0-hhat.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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