Skip to content

[Backend] — Test: PredictionsService.submit never calls Soroban when market validation fails #1162

Description

@Olowodarey

Background

PredictionsService.submit (src/predictions/predictions.service.ts) validates
the market state (closed, cancelled, expired) before calling
this.sorobanService.submitPrediction. If the Soroban call is reached on an
invalid market, real XLM gets locked on-chain without a corresponding DB row.
There are currently no unit tests confirming the short-circuit behavior — only
the happy path is covered.

Goal

Add unit tests in src/predictions/predictions.service.spec.ts confirming that
SorobanService.submitPrediction is never called when market validation
fails.

Requirements

Create a predictions.service.spec.ts (or extend existing) with the following
cases. Use jest.spyOn(sorobanService, 'submitPrediction') to assert it is not
called.

  1. Market not found: marketsRepository.findOne returns null →...

Metadata

Metadata

Assignees

No one assigned

    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