Skip to content

feat: add oracle price feed verification integration test #418

@sanmipaul

Description

@sanmipaul

Summary

`contracts/tests/integration_tests.rs` has no test that verifies oracle price feed integration. The pool uses collateral valuations that depend on oracle prices, but no test covers what happens when:

  1. The oracle returns a stale price
  2. The oracle returns zero (divide-by-zero risk)
  3. The oracle price changes between collateral deposit and seizure check
  4. The oracle is unavailable (cross-contract call fails)

Missing Test Cases

  • `test_stale_oracle_price_rejected`: pool should reject collateral valuations from stale oracle feeds
  • `test_oracle_zero_price_handled`: oracle returning 0 should not cause divide-by-zero
  • `test_price_change_between_deposit_and_seizure`: collateral value at seizure time reflects current oracle price
  • `test_oracle_unavailable_fallback`: if oracle call fails, pool should return a safe error

Implementation Notes

  • Use a mock oracle contract in the Soroban test environment
  • The mock should be configurable to return specific prices, timestamps, and errors
  • Tests should set up the mock, perform operations, then verify behavior

Acceptance Criteria

  • Mock oracle contract created for test use
  • All 4 test cases above implemented and passing
  • Tests run in CI without external oracle dependency
  • Each test asserts the specific expected error or behavior

References

  • `contracts/tests/integration_tests.rs`
  • `contracts/pool/src/lib.rs` — oracle price usage in collateral valuation

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programsmart-contractSoroban/Rust contract worktestingTest coverage and quality

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions