Skip to content

test(circle): add table-driven state machine transition tests - #197

Open
BABAT-CODE wants to merge 1 commit into
cocor-tech:masterfrom
BABAT-CODE:test/circle-state-machine-transitions
Open

test(circle): add table-driven state machine transition tests#197
BABAT-CODE wants to merge 1 commit into
cocor-tech:masterfrom
BABAT-CODE:test/circle-state-machine-transitions

Conversation

@BABAT-CODE

Copy link
Copy Markdown
Contributor

Add 14 dedicated tests in packages/circle/src/test.rs covering every legal and illegal (from_status, to_status, operation) tuple in the circle state machine:

State machine transitions under test:
PENDING → ACTIVE (join fills last seat) [legal]
ACTIVE → COMPLETED (all rounds paid) [legal]
ACTIVE → DISPUTED (raise_dispute) [legal]
DISPUTED → ACTIVE (resolve_dispute) [legal]

Illegal transitions (must return typed error, not panic):
COMPLETED + join → NotActive
COMPLETED + contribute → NotActive
COMPLETED + trigger_payout → NotActive
COMPLETED + exit → NotActive
PENDING + trigger_payout → NotActive
PENDING + contribute → NotActive
DISPUTED + second dispute → DisputeAlreadyRaised
DISPUTED + trigger_payout → NotActive
DISPUTED + contribute → NotActive
DISPUTED + join → NotActive

Also tests:
resolve_dispute on circle with no active dispute → NoActiveDispute

Helper functions added:
sm_pending_circle() — builds PENDING state fixture
sm_active_circle() — builds ACTIVE state fixture
sm_completed_circle() — builds COMPLETED state fixture
sm_disputed_circle() — builds DISPUTED state fixture

Fixes: MEDIUM testing gap — no state machine transition coverage

closes #114

Add 14 dedicated tests in packages/circle/src/test.rs covering every
legal and illegal (from_status, to_status, operation) tuple in the
circle state machine:

State machine transitions under test:
  PENDING  → ACTIVE     (join fills last seat)           [legal]
  ACTIVE   → COMPLETED  (all rounds paid)                [legal]
  ACTIVE   → DISPUTED   (raise_dispute)                  [legal]
  DISPUTED → ACTIVE     (resolve_dispute)                [legal]

Illegal transitions (must return typed error, not panic):
  COMPLETED + join            → NotActive
  COMPLETED + contribute      → NotActive
  COMPLETED + trigger_payout  → NotActive
  COMPLETED + exit            → NotActive
  PENDING   + trigger_payout  → NotActive
  PENDING   + contribute      → NotActive
  DISPUTED  + second dispute  → DisputeAlreadyRaised
  DISPUTED  + trigger_payout  → NotActive
  DISPUTED  + contribute      → NotActive
  DISPUTED  + join            → NotActive

Also tests:
  resolve_dispute on circle with no active dispute → NoActiveDispute

Helper functions added:
  sm_pending_circle()   — builds PENDING state fixture
  sm_active_circle()    — builds ACTIVE state fixture
  sm_completed_circle() — builds COMPLETED state fixture
  sm_disputed_circle()  — builds DISPUTED state fixture

Fixes: MEDIUM testing gap — no state machine transition coverage
@drips-wave

drips-wave Bot commented Aug 10, 2026

Copy link
Copy Markdown

@BABAT-CODE Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

test: add invariant tests for circle state transitions

1 participant