Skip to content

test(policies): add comprehensive unit tests for spending policy simulation helper functions - #469

Open
shobhamerabacha-star wants to merge 1 commit into
ASTROIDX556:mainfrom
shobhamerabacha-star:test/spending-policy-simulation-helpers
Open

shobhamerabacha-star wants to merge 1 commit into
ASTROIDX556:mainfrom
shobhamerabacha-star:test/spending-policy-simulation-helpers

Conversation

@shobhamerabacha-star

Copy link
Copy Markdown

Summary

This PR adds comprehensive unit tests covering spending policy simulation helper functions, edge cases, timezone boundaries, zero spending limits, fee sufficiency, and concurrent policy evaluation.

Addressed Issue

Closes #423

Test Coverage Added

  1. Policy Evaluation Helpers (policyEvaluation.test.ts):
    • Proposed transaction schema validation (positive amounts, non-finite checks, 56-char Stellar G-addresses, asset enums).
    • Policy configuration extraction (configFromPolicies) including disabled policy filtering and recipient allowlist parsing.
    • Fail-closed behavior when policy configurations are unconfigured or empty.
    • Exact transaction ceiling checks, daily velocity limits, department budget overflow, and recipient allow-list matching.
  2. Policy Simulation Edge Cases (policySimulationEdgeCases.test.ts):
    • Spending-limit amount boundary classifications (within, at_limit, over, delta calculation).
    • Stellar asset code normalization and plaintext operation parser validation.
    • Low-balance wallet fee sufficiency and network fee depletion edge cases.
  3. Simulation Boundary Extensions (spendingPolicySimulation.test.ts):
    • Timezone boundaries and execution time-window transitions across midnight UTC.
    • Zero spending limit and freeze policy enforcement.
    • Parallel concurrent policy evaluations across simulated agents without state contamination.

Verification

  • 70/70 unit tests passing cleanly via npm test
  • npm run typecheck passes with zero TypeScript errors
  • npm run lint passes cleanly

@vercel

vercel Bot commented Nov 9, 2026

Copy link
Copy Markdown

@shobhamerabacha-star is attempting to deploy a commit to the Cjay's projects Team on Vercel.

A member of the Team first needs to authorize it.

@shobhamerabacha-star
shobhamerabacha-star force-pushed the test/spending-policy-simulation-helpers branch from efc27a3 to 38ecfbf Compare November 10, 2026 12:57

This branch has not been deployed

No deployments
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 comprehensive unit tests for spending policy simulation helper functions

1 participant