Skip to content

[P3] Add a success-path unit test for ContractService.getDonorCountOnChain #1151

Description

@cyber-punk112

Description

ContractService.getDonorCountOnChain(poolId) in src/contract/contract.service.ts parses a Soroban simulation result via scValToNative(retVal). contract.service.spec.ts's describe('getDonorCountOnChain', ...) block only tests the "returns 0 on RPC error" path — the success path, where simulateTransaction resolves with a real retval and the count is correctly extracted, is entirely untested.

Deliverables

  • Add a test that stubs service['rpcServer'].simulateTransaction (via jest.spyOn, following the pattern already used for service['mapError'] in the same file) to resolve with a mock result.result.retval, and asserts getDonorCountOnChain returns the expected number
  • npm run build passes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MediumbackendNestJS server workgood first issueGood for newcomersphase-2Phase 2 beginner-friendly backlog: cleanup, tests, docs, polish

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions