Skip to content

Conversation

@raushan728
Copy link

@raushan728 raushan728 commented Dec 25, 2025

Summary
This pull request introduces a dedicated test suite for the BurnChecked instruction within the JavaScript SDK (clients/js). The suite provides full coverage for the instruction, ensuring that both expected behavior and error conditions are strictly validated in accordance with the SPL Token program logic.

Technical Changes

  • New Test File: Created clients/js/test/burnChecked.test.ts.
  • Test Framework: Utilized the Ava testing framework as per repository standards.
  • Infrastructure: Leveraged project-specific setup helpers including createMint, createTokenWithAmount, and signAndSendTransaction to ensure environment consistency.

Test Scenarios Covered

Success Path Validations:

  • Standard Burn: Validates that burning a specified amount with correct decimals accurately updates the account balance and mint supply.
  • Exhaustive Burn: Confirms that burning the entire account balance results in a zero-balance state.
  • Delegated Burn: Verifies that an authorized delegate can perform burns and that the delegatedAmount updates appropriately.
  • Mint Supply Consistency: Confirms that total supply reflects burns accurately across multiple token accounts.
  • Edge Case - Zero Amount: Ensures that burning 0 tokens is handled as a valid, no-op transaction.
  • Precision Scaling: Validates the instruction across different decimal scales, specifically testing 0 (integer) and 18 (high-precision) decimals.

Failure Mode Validations:

  • Decimal Mismatch: Ensures the transaction is rejected when instruction decimals do not match the mint's configuration.
  • Insufficient Funds: Validates rejection when the burn amount exceeds the available account balance.
  • Signature Verification: Confirms that instructions fail if the required authority is not a signer.
  • Delegation Limits: Ensures a delegate cannot burn tokens beyond the amount approved by the owner.

Technical Verification

  • Build Status: Verified via pnpm build in the clients/js directory.
  • Local Validator: Tests were executed against a local solana-test-validator.
  • Execution Command: npx ava dist/test/burnChecked.test.js
  • Results: 10 out of 10 tests passed successfully.

Checklist

  • Code adheres to the architectural patterns of the repository (pipe, signers, etc.).
  • All new tests have been verified to pass on a local validator.
  • Self-review performed to ensure no redundant code or unused imports are present.
  • Documentation and comments follow the established project style.

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.

1 participant