feat: add unit tests for BalancesService and enhance wallet limit refresh logic#2689
feat: add unit tests for BalancesService and enhance wallet limit refresh logic#2689
Conversation
📝 WalkthroughWalkthroughThis change implements trial job cancellation functionality in the BalancesService. When ending user trials, the system now cancels trial-related background jobs through a new pattern-based cancellation method in JobQueueService, with comprehensive test coverage across all affected components. Changes
Sequence Diagram(s)sequenceDiagram
participant BS as BalancesService
participant JQS as JobQueueService
participant DB as Database
BS->>BS: refreshUserWalletLimits()
alt endTrial is true and wallet is trialing
BS->>BS: cancelTrialJobsByWalletId(walletId)
BS->>JQS: cancelCreatedByPattern({<br/> name: 'CloseTrialDeployment',<br/> pattern: walletId pattern<br/>})
JQS->>DB: UPDATE jobs SET state='cancelled'<br/>WHERE singleton_key LIKE pattern
DB-->>JQS: cancelled job IDs
JQS->>JQS: log JOBS_CANCELLED_BY_PATTERN event
BS->>JQS: cancelCreatedByPattern({<br/> name: 'NotificationJob',<br/> pattern: walletId pattern<br/>})
JQS->>DB: UPDATE jobs SET state='cancelled'<br/>WHERE singleton_key LIKE pattern
DB-->>JQS: cancelled job IDs
JQS->>JQS: log JOBS_CANCELLED_BY_PATTERN event
end
alt limits changed or endTrial is true
BS->>BS: Update wallet limits and/or isTrialing
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Summary by CodeRabbit
Bug Fixes
Tests