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

example: Provide ProgramTest example with spl-token CPI #829

Closed
joncinque opened this issue Nov 11, 2020 · 7 comments · Fixed by #3965
Closed

example: Provide ProgramTest example with spl-token CPI #829

joncinque opened this issue Nov 11, 2020 · 7 comments · Fixed by #3965
Labels
good first issue Good for newcomers

Comments

@joncinque
Copy link
Contributor

Program developers will want to write end-to-end tests using other programs, which is not totally possible with unit tests. solana-program-test is extremely useful, so we should have a small example of how to use it. A few things to consider:

  • an example of adding another program's processor function (e.g. spl_token)
  • an example using a builtin (e.g. stake)

Also, there's an error that I ran into while doing this:
error: the #[global_allocator] in solana_measure conflicts with global allocator in: spl_stake_pool

so an extra comment or an FAQ point about that error and how to resolve it would be useful as well, e.g. adding
#![cfg(all(target_arch = "bpf", not(feature = "no-entrypoint")))] in entrypoint.rs to avoid defining global_allocator twice.

tag @jackcmay

@jackcmay
Copy link
Contributor

@joncinque

  • What do you think we should do something simple like two test programs, once calls the other to keep the example super clean (rather then call token)?
  • Does the current cross-program-invocation example cover the builtin example (it calls system program

@mvines
Copy link
Member

mvines commented Nov 12, 2020

I definitely think this example should invoke SPL Token. The first thing people familiar with ERC-20 ask seems to be, "so how do I customize the SPL Token implementation for my application". To which we reply, "please don't, there's a better way".

I conveniently wrote this example earlier today, mvines/solana-bpf-program-template#3, that perhaps can be recycled in whole or part for this issue

@jackcmay
Copy link
Contributor

@mvines What was the intent of writing that example in its own repo and not as an example under SPL?

@mvines
Copy link
Member

mvines commented Nov 12, 2020

Nope. Just wanted to park it somewhere for now, and seemed easiest to add it under my account for now.

@jackcmay
Copy link
Contributor

Cool, I'll add it to the examples

@joncinque
Copy link
Contributor Author

@jackcmay my bad, I put this in late yesterday and hadn't read through all of the examples you've already provided. the cross-program-invocation program is perfect as it is for using builtins. I was thinking the same thing as @mvines regarding an spl-token CPI example, since most people want to work with tokens.

@jackcmay
Copy link
Contributor

@joncinque the global allocator conflict should go away now that SPL is on v1.4.8. I remove the extra checks in this PR: #852

@joncinque joncinque added the good first issue Good for newcomers label May 11, 2022
@joncinque joncinque changed the title example: Provide ProgramTest example example: Provide ProgramTest example with spl-token CPI May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants