sui icon indicating copy to clipboard operation
sui copied to clipboard

test: add method to create the sui coin metadata

Open josemvcerqueira opened this issue 1 year ago • 2 comments

Description

It adds a test only function to create Sui currency in tests.

Test Plan

How did you test the new or updated feature?

We added a a file to test the function.


If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.

Type of Change (Check all that apply)

  • [ ] protocol change
  • [ ] user-visible impact
  • [ ] breaking change for a client SDKs
  • [ ] breaking change for FNs (FN binary must upgrade)
  • [ ] breaking change for validators or node operators (must upgrade binaries)
  • [ ] breaking change for on-chain data layout
  • [ ] necessitate either a data wipe or data migration

Release notes

josemvcerqueira avatar Oct 26 '23 04:10 josemvcerqueira

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2024 10:37pm
multisig-toolkit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2024 10:37pm
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2024 10:37pm
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2024 10:37pm
sui-kiosk ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2024 10:37pm
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2024 10:37pm

vercel[bot] avatar Oct 26 '23 04:10 vercel[bot]

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Dec 26 '23 01:12 github-actions[bot]

Hi @josemvcerqueira, have you seen the coin::mint_for_testing and balance::create_for_testing helpers? They allow you to create coins and balances for any coin type in the test environment:

https://github.com/MystenLabs/sui/blob/473e4e25615fb47cd788aaba849a372189df52bc/crates/sui-framework/packages/sui-framework/sources/coin.move#L409-L413

https://github.com/MystenLabs/sui/blob/473e4e25615fb47cd788aaba849a372189df52bc/crates/sui-framework/packages/sui-framework/sources/balance.move#L118-L122

amnn avatar Mar 13 '24 13:03 amnn

Hi @josemvcerqueira, have you seen the coin::mint_for_testing and balance::create_for_testing helpers? They allow you to create coins and balances for any coin type in the test environment:

https://github.com/MystenLabs/sui/blob/473e4e25615fb47cd788aaba849a372189df52bc/crates/sui-framework/packages/sui-framework/sources/coin.move#L409-L413

https://github.com/MystenLabs/sui/blob/473e4e25615fb47cd788aaba849a372189df52bc/crates/sui-framework/packages/sui-framework/sources/balance.move#L118-L122

Hello @amnn, yes I have.

This PR is to allow developers to access the CoinMetadata for Sui in tests.

Thank you for the response.

josemvcerqueira avatar Mar 18 '24 04:03 josemvcerqueira

@damirka / @tzakian / @tnowacki, could you double check for me that this seems okay? It looks fine to me, and is serving a niche that I can't think of another way of serving, but given that it's related to SUI initialisation, wanted to get some more eyes on it.

amnn avatar Mar 18 '24 14:03 amnn

Thanks for submitting the PR @josemvcerqueira!

The method you're suggesting won't allow simple tests without TestScenario, and relies on storage. Do you think it would work better if sui::coin had a method like new_coin_metadata_for_testing, and sui::sui could implement it in test_only mode? Eg. sui::sui::new_metadata_for_testing()?

Hello Damir, thank you for your suggestion.

I believe this would be better yes. Should the new sui::sui::new_metadata_for_testing()be a friend-only function for sui::sui similar to sui::balance::destroy_supply?

josemvcerqueira avatar Mar 19 '24 16:03 josemvcerqueira

I updated the PR based on @damirka's feedback. Please let me know if there are additional changes :)

josemvcerqueira avatar Mar 19 '24 22:03 josemvcerqueira