Skip to content

test(treasury): Add integration test suite via test-consumer pattern#1266

Open
NUMBER72857 wants to merge 1 commit into
MyFanss:mainfrom
NUMBER72857:feat/907-treasury-integration-test
Open

test(treasury): Add integration test suite via test-consumer pattern#1266
NUMBER72857 wants to merge 1 commit into
MyFanss:mainfrom
NUMBER72857:feat/907-treasury-integration-test

Conversation

@NUMBER72857
Copy link
Copy Markdown

Summary

Adds 12 integration tests to the test-consumer crate that drive the treasury contract exclusively through its public TreasuryClient interface — the test-consumer pattern — matching how external contracts (subscription, earnings) call the treasury in production.

Changes

  • test-consumer/src/lib.rs: new treasury_integration submodule with 12 tests
  • No new crate or Cargo.toml changes — test-consumer already declares treasury as a dev-dependency

Test coverage

Group Tests
Initialize once-only guard (second call rejected)
Deposit moves tokens, accumulation, zero rejected
Withdraw credits recipient, overdraft rejected, full withdrawal
Min-balance violation rejected, exact min-balance succeeds
Pause blocks both ops, unpause restores operations

Test-consumer pattern

All tests use TreasuryClient::new(&env, &treasury_id) — no use treasury::* imports of internal types. This is exactly how a subscription contract registers and calls the treasury cross-contract.

Closes #907

…yFanss#907)

- 12 integration tests in test-consumer/src/lib.rs under treasury_integration mod
- Drives Treasury exclusively through TreasuryClient — no internal fn access,
  matching how an external contract (subscription, earnings) would call it
- Coverage: initialize (once-only), deposit accumulation, overdraft rejection,
  zero-amount guard, full withdrawal, min_balance guard (violation + exact),
  pause/unpause lifecycle
- Uses StellarAssetClient for minting and TokenClient to assert on balances
  post-operation — observable state, not internal storage

Closes MyFanss#907
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@NUMBER72857 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

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.

Contract treasury: Add integration test via test-consumer

1 participant