Skip to content

Add unit tests for treasury address reads#48

Merged
Chucks1093 merged 4 commits into
accesslayerorg:mainfrom
Olowodarey:fee
Mar 26, 2026
Merged

Add unit tests for treasury address reads#48
Chucks1093 merged 4 commits into
accesslayerorg:mainfrom
Olowodarey:fee

Conversation

@Olowodarey

Copy link
Copy Markdown
Contributor

Adds focused unit tests for treasury address read operations, verifying predictable behavior across different states (unset, set, and persistent reads).

Changes

New Unit Tests (3 tests for treasury address)

  1. test_get_treasury_address_returns_none_initially

    • Verifies get_treasury_address returns None when no address is configured
    • Tests the initial/unset state behavior
  2. test_get_treasury_address_returns_set_address

    • Verifies get_treasury_address returns the configured address after setting
    • Tests the basic set-and-read flow
  3. test_get_treasury_address_persists_across_reads

    • Verifies get_treasury_address returns consistent results across multiple reads
    • Tests read-only behavior and state persistence

Additional Test (1 test for creator fee config)

  1. test_get_creator_fee_config_returns_defaults_for_unregistered
    • Verifies get_creator_fee_config returns default values for unregistered creators
    • Completes the not-registered creator read coverage

Test Characteristics

  • Small and direct (each test focuses on one scenario)
  • Clear assertions (expected values are explicit)
  • Scoped to read paths (no state mutation beyond setup)
  • Predictable return behavior (None, Some(address), consistent values)

Testing

All tests pass:

  • ✅ 4 new unit tests (3 treasury + 1 fee config)
  • ✅ 18 existing unit tests continue to pass
  • ✅ 51 integration tests continue to pass
  • ✅ Total: 73 tests passing

Acceptance Criteria

  • ✅ Treasury address read behavior is covered by tests
  • ✅ Assertions are clear and specific (None, Some(address), equality checks)
  • ✅ Tests stay scoped to the read path (read-only operations)

Quality Checks

  • ✅ All tests pass (cargo test)
  • ✅ Code formatted (cargo fmt)
  • ✅ No clippy warnings (cargo clippy)
  • ✅ Test snapshots generated

Design Notes

These unit tests complement the existing integration tests in tests/treasury_address.rs by providing focused, isolated coverage at the unit level. They verify:

  • Initial state returns None
  • Set address is retrievable
  • Multiple reads return consistent results
  • No state mutation occurs during reads

The tests follow the same pattern as other read method tests, ensuring consistency across the test suite.

closes #38
closes #39

- Add test for get_key_balance with unregistered creator (returns 0)
- Add test for is_creator_registered with unregistered creator (returns false)
- Add test for get_total_key_supply with unregistered creator (returns 0)
- Add test for get_key_balance with unregistered wallet (returns 0)
- Add test for get_key_balance with registered creator but unregistered wallet (returns 0)

All tests verify expected behavior for missing creators/wallets
- Add snapshots for 4 new unit tests
- Snapshots verify contract state after read operations on unregistered creators
- Add test for get_treasury_address returns None initially
- Add test for get_treasury_address returns set address
- Add test for get_treasury_address persists across reads
- Add test for get_creator_fee_config returns defaults for unregistered

All tests verify expected read behavior with clear assertions
- Add snapshots for 4 new unit tests
- Snapshots verify contract state for treasury address reads
@drips-wave

drips-wave Bot commented Mar 26, 2026

Copy link
Copy Markdown

@Olowodarey 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 4732583 into accesslayerorg:main Mar 26, 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 treasury address reads Add unit tests for not-registered creator reads

2 participants