-
Notifications
You must be signed in to change notification settings - Fork 20
Add xdc fork test for GenericDistributionHelper #287
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `test/reserve/GenericDistributionHelper.e2e.test.ts:275-284` </location>
<code_context>
+ it("should correctly calculate swap amounts using XSWAP pools", async function () {
</code_context>
<issue_to_address>
**suggestion (testing):** Missing test for edge cases in calcGDToSell (e.g., zero input, very large input).
Add tests for calcGDToSell with zero and very large G$ inputs to verify correct handling of boundary conditions.
</issue_to_address>
### Comment 2
<location> `test/reserve/GenericDistributionHelper.e2e.test.ts:322-331` </location>
<code_context>
+ it("should handle swap with correct slippage protection", async function () {
</code_context>
<issue_to_address>
**suggestion (testing):** Missing test for slippage exceeding maxSlippage.
Add a test case where slippage exceeds maxSlippage and verify that the swap is reverted, confirming slippage protection works correctly.
</issue_to_address>
### Comment 3
<location> `test/reserve/GenericDistributionHelper.e2e.test.ts:343` </location>
<code_context>
const maxSlippage = feeSettings.maxSlippage;
</code_context>
<issue_to_address>
**suggestion (code-quality):** Prefer object destructuring when accessing and using properties. ([`use-object-destructuring`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/TypeScript/Default-Rules/use-object-destructuring))
```suggestion
const {maxSlippage} = feeSettings;
```
<br/><details><summary>Explanation</summary>Object destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.
From the [Airbnb Javascript Style Guide](https://airbnb.io/javascript/#destructuring--object)
</details>
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| it("should correctly calculate swap amounts using XSWAP pools", async function () { | ||
| const amountToSell = ethers.utils.parseEther("100"); // 100 G$ | ||
|
|
||
| // Test quote from G$ to CUSD | ||
| const [quoteCUSD, poolsGDCUSD] = await staticOracle.quoteAllAvailablePoolsWithTimePeriod( | ||
| amountToSell, | ||
| goodDollar.address, | ||
| reserveToken.address, | ||
| 60 | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Missing test for edge cases in calcGDToSell (e.g., zero input, very large input).
Add tests for calcGDToSell with zero and very large G$ inputs to verify correct handling of boundary conditions.
| it("should handle swap with correct slippage protection", async function () { | ||
| // This test verifies that the swap respects maxSlippage settings | ||
| const amountToSell = ethers.utils.parseEther("50"); // 50 G$ | ||
|
|
||
| // Get quote | ||
| const [quoteCUSD, ] = await staticOracle.quoteAllAvailablePoolsWithTimePeriod( | ||
| amountToSell, | ||
| goodDollar.address, | ||
| reserveToken.address, | ||
| 60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Missing test for slippage exceeding maxSlippage.
Add a test case where slippage exceeds maxSlippage and verify that the swap is reverted, confirming slippage protection works correctly.
71b4c84 to
d74faa9
Compare
| expect(xdcIncrease.gt(0), "Swap should have increased either WXDC or xdc balance").to.be.true; | ||
| }); | ||
|
|
||
| it("should correctly calculate swap amounts using XSWAP pools", async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are not comparing the quotes to calcgdtosell so you are not actually testing "correctly calculate swap amounts"
| }); | ||
| }); | ||
|
|
||
| it("should handle swap with correct slippage protection", async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are not swaping so you dont actually test slippage protection.
either change the name or modify the logic
Add xdc fork test for GenericDistributionHelper
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
Description
Added a GenericDistributionHelper XDC-fork test to verify that swapping G$ to XDC through xswap is working correctly.
About # (link your issue here)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: