Skip to content

feat: Add comprehensive tests and snapshots for key quote functionali…#62

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
testersweb0-bug:feat/standardized-quote-views
Mar 27, 2026
Merged

feat: Add comprehensive tests and snapshots for key quote functionali…#62
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
testersweb0-bug:feat/standardized-quote-views

Conversation

@testersweb0-bug

Copy link
Copy Markdown
Contributor

Summary

This PR introduces standardized quote formatting and read-only quote views for the creator-keys contract. It ensures consistency between buy and sell quote responses while enabling callers to retrieve accurate pricing and fee breakdowns without mutating contract state.

Closes #55
Closes #56
Closes #57

Key Changes

1. Standardized Quote Formatting

  • Added QuoteResponse struct (Clone, Debug, PartialEq, contracttype)
  • Implemented shared format_quote_response helper to unify buy/sell quote structure
  • Standardized calculation logic:
    • Buytotal = price + fees
    • Selltotal = price - fees

2. Read-Only Quote Methods

  • Added get_buy_quote

    • Returns total payment required for next key purchase
    • Includes full fee breakdown
    • Does not mutate contract state
  • Added get_sell_quote

    • Returns sell value and fee breakdown
    • Rejects with InsufficientBalance if holder has zero keys

3. Test Coverage

  • Added comprehensive tests for:
    • get_buy_quote
    • get_sell_quote
  • Covered edge cases:
    • Zero holder balance
    • Missing config
    • Invalid creator state

Testing

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace

Checklist

  • Linked issue or backlog item
  • Contract behavior and invariants are described clearly
  • Docs updated if contract interfaces or workflows changed
  • Scope stays limited to one contract concern

@drips-wave

drips-wave Bot commented Mar 27, 2026

Copy link
Copy Markdown

@testersweb0-bug 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! 🚀

Learn more about application limits

@Chucks1093 Chucks1093 merged commit 097d3d6 into accesslayerorg:main Mar 27, 2026
1 check passed
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.

Add unit tests for sell quote with zero holder balance Add helper for quote response formatting Add read-only buy quote view method

2 participants