sui
sui copied to clipboard
test: add method to create the sui coin metadata
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
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 |
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.
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
Hi @josemvcerqueira, have you seen the
coin::mint_for_testing
andbalance::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.
@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.
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 likenew_coin_metadata_for_testing
, andsui::sui
could implement it intest_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
?
I updated the PR based on @damirka's feedback. Please let me know if there are additional changes :)