Skip to content

Add Test for New Goal Locked State #100

@Baskarayelu

Description

@Baskarayelu

Description:

The savings_goals contract creates every new goal with locked: true so that funds cannot be withdrawn until the owner explicitly calls unlock_goal. This prevents accidental withdrawals and enforces the intended flow (create -> add funds -> unlock when ready -> withdraw). If this default were changed or the field misinterpreted, users could withdraw from goals that should still be locked. This issue adds a test that immediately after create_goal the goal is returned with locked == true, and that withdraw_from_goal fails with the expected panic or error before unlock_goal is called.

Requirements

Test scenario: Create a goal as owner (e.g. create_goal(env, owner, name, target_amount, target_date)). Call get_goal(goal_id) and assert goal.locked == true. Without calling unlock_goal, call withdraw_from_goal(owner, goal_id, amount) (after adding some funds to the goal so balance is sufficient); assert the call fails (panic "Cannot withdraw from a locked goal" or equivalent). Optionally call unlock_goal, then withdraw_from_goal, and assert it succeeds and balance decreases.

Acceptance Criteria

  • Test creates a goal and asserts get_goal(...).locked == true.
  • Test asserts withdraw_from_goal fails when the goal is still locked.
  • Test is in savings_goals test suite and runs in CI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave program

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions