Skip to content

test: add unit tests for vault interaction methods with mocked StellarSDK dependencies#202

Merged
El-swaggerito merged 2 commits into
Axionvera:mainfrom
shamsss04:shams1
Jul 22, 2026
Merged

test: add unit tests for vault interaction methods with mocked StellarSDK dependencies#202
El-swaggerito merged 2 commits into
Axionvera:mainfrom
shamsss04:shams1

Conversation

@shamsss04

Copy link
Copy Markdown
Contributor

Soroban Vault Boundary Tests

Closes #188

Summary

This PR introduces comprehensive boundary tests for the Soroban Savings Vault module (src/soroban/index.ts). These tests validate that the SDK interacts correctly with the deployed smart contract, handles inputs/outputs precisely, and wraps any simulated or network errors robustly.

Motivation

To ensure the reliability of the PocketPay SDK when interacting with the Soroban smart contracts, we need to guarantee that the depositToVault, withdrawFromVault, and getVaultBalance functions work seamlessly under various network constraints and handle boundaries appropriately.

What's New

New Test Suite (tests/vault.test.ts)

A dedicated unit testing suite was created for the Soroban methods, utilizing robust vi.mock techniques to simulate Horizon/Soroban RPC behavior without any live network dependencies. The mocked operations explicitly document the expected real-network state transformations.

Method Boundaries Tested
depositToVault Contract interaction (deposit), invalid secret validation, success mappings, simulation errors, unhandled RPC wrapper handling.
withdrawFromVault Contract interaction (withdraw), amount validation, success mappings, and transaction submission error handling.
getVaultBalance Contract interaction (get_balance), public key validation, timeout/offline wrapping, and parsing scValToNative back to an XLM string.

Files Changed

File Change
tests/vault.test.ts New — 13 tests covering Vault boundary states, input/output validation, and error mappings.
src/soroban/index.ts (No changes required for tests to pass, existing logic was verified)

Acceptance Criteria

  • Vault boundary tests are added.
  • Expected method names are covered.
  • Input and output shapes are tested.
  • Contract error mapping is tested.
  • Mocked versus real behaviour is documented inside the tests.

Verification

npm run test          # Full test suite - 13/13 passing in tests/vault.test.ts

@El-swaggerito
El-swaggerito merged commit e40a86e into Axionvera:main Jul 22, 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 SDK vault integration boundary tests

3 participants