test: add unit & integration tests for get_price at zero supply (#720) - #732
Merged
Chucks1093 merged 1 commit intoAug 25, 2026
Conversation
accesslayerorg#720) - Add get_price entrypoint to CreatorKeysContract as read-only price query helper - Add unit tests in test_issues.rs for supply 0 base price, supply 1 strictly greater price, and no-panic assertions - Add integration tests in tests/get_price_zero_supply.rs covering base price variations, curve presets, read-only state preservation, and pause compatibility Closes accesslayerorg#720
|
@Oluwasuyi-Oluwatimilehin-Daniel Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
At supply
0(when no keys are in circulation for a creator),get_priceshould return the configuredbase_priceconstant — representing the price of the very first key on the bonding curve. At supply1,get_pricemust return a price strictly greater thanbase_pricewhen a positive slope is configured.This PR exposes
get_priceonCreatorKeysContractand adds unit and integration test suites covering all boundary conditions, curve presets, and invariant checks.Closes #720
Changes
1. Contract Entrypoint (
creator-keys/src/lib.rs)pub fn get_price(env: Env, creator: Address, supply: u64) -> Result<i128, ContractError>toCreatorKeysContract.2. Unit Tests (
creator-keys/src/test_issues.rs)test_get_price_at_supply_zero_returns_base_price_and_greater_at_supply_one: Verifies supply 0 returnsbase_price, supply 1 returnsbase_price + slope > base_price, and asserts neither call panics (includingtry_get_price).test_get_price_various_base_prices_at_supply_zero: Checks supply 0 and supply 1 across multiple base prices ([1, 10, 100, 500, 1000, 10000, 50000]).test_get_price_presets_at_supply_zero_and_one: Verifies Linear, Quadratic, and Flat curve presets at supply 0 and 1.3. Integration & Boundary Tests (
creator-keys/tests/get_price_zero_supply.rs)get_price,query_price, andget_buy_quote.ContractError::KeyPriceNotSet) when key price is uninitialized.get_priceremains callable and answers correctly while the contract is paused.Acceptance Criteria Checklist
get_priceandtry_get_price)Verification