Skip to content

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

@joepegler

Description

@joepegler

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions