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

✨ Feature Request: Add ERC20 Approval Test Cases to Smart Sessions Test Suite #124

Open
2 tasks done
joepegler opened this issue Nov 24, 2024 · 0 comments
Open
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@joepegler
Copy link
Collaborator

Feature or Improvement Description

Add test cases to toSmartSessionValidator.test.ts that demonstrate and validate ERC20 token approvals using Smart Sessions, including verification of allowances after successful approval operations.

Benefits & Outcomes

  • Validate Token Integration: Ensure Smart Sessions work correctly with standard ERC20 token operations.
  • Demonstrate Common Use Case: Token approvals are a fundamental DeFi operation that needs thorough testing.
  • Enhance Test Coverage: Add critical test cases for token-related functionality.
  • Provide Example Code: Offer developers a reference implementation for token approvals using Smart Sessions.
  • Ensure Security: Verify that allowances are set correctly and permissions work as intended.

Implementation Ideas

  1. Add New Test Cases

Add the following test cases to src/sdk/modules/smartSessionsValidator/toSmartSessionsValidator.test.ts. The test should:

  • Create a session for ERC20 token approval
  • Execute an approval transaction using the session
  • Verify the allowance before and after the approval
  • Include proper error handling and assertions
  1. Add Required Imports and Constants

Add the USDC token ABI import to the test file and ensure all necessary constants are defined in the testAddresses object, including the USDC token address for the test network.

  1. Update Test Setup

Update the test setup to include USDC token address and any additional configuration needed for token testing. Use the existing USDC deployment on the test network.

  1. Testing Considerations
  • Verify initial allowance is zero
  • Test approval with different amounts
  • Verify final allowance matches approved amount
  • Include error cases (e.g., insufficient permissions)
  • Test allowance updates
  • Verify session permissions are correctly scoped
  1. Documentation
  • Add clear comments explaining the test flow
  • Document any special considerations for token approvals
  • Include examples of expected behaviors
  • Update test documentation with new cases

References


  • I agree to follow this project's Code of Conduct.

Any References?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct.
@joepegler joepegler added the enhancement New feature or request label Nov 24, 2024
@joepegler joepegler self-assigned this Nov 24, 2024
@joepegler joepegler added bug Something isn't working and removed enhancement New feature or request labels Nov 24, 2024
@joepegler joepegler changed the title # ✨ Feature Request: Add ERC20 Approval Test Cases to Smart Sessions Test Suite ✨ Feature Request: Add ERC20 Approval Test Cases to Smart Sessions Test Suite Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant