Skip to content

fix: spl-token-sale-tutorial add missing helper functions in test setup - #26

Open
0xRektified wants to merge 1 commit into
RareSkills:prodfrom
0xRektified:fix/add-missing-helper-functions
Open

fix: spl-token-sale-tutorial add missing helper functions in test setup#26
0xRektified wants to merge 1 commit into
RareSkills:prodfrom
0xRektified:fix/add-missing-helper-functions

Conversation

@0xRektified

Copy link
Copy Markdown

Add missing helper functions in token sale tutorial

Summary

This PR adds the missing helper function definitions (toRawTokenAmount, toDisplayAmount, and lamportsToSol) that are used throughout the test cases but were never defined in the tutorial.

Problem

Users following the tutorial would encounter errors when running the tests because these helper functions are called in multiple places:

  • lamportsToSol(solToSend) and toDisplayAmount(expectedTokenAmount)
  • toRawTokenAmount(1000)
  • toDisplayAmount(currentSupply) and toDisplayAmount(remainingSupply)
  • toRawTokenAmount(20)
  • lamportsToSol() calls

Solution

Added three helper functions at the beginning of the test file (after imports, before the describe block):

  1. toRawTokenAmount(amount: number)
  2. toDisplayAmount(amount: number)
  3. lamportsToSol(lamports: number | anchor.BN)

Testing

Users can now successfully run all test cases without encountering "function not defined" errors.

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