Task 3-3: Integration Test - Crypto Payment (Slash)
Phase: 3 - Testing Priority: Medium Depends on: task-1-1 Reference: docs/BountyHunter-Backend/details/feature-payment-marketplace/SPEC.md
Background
Test Slash crypto payment flow bao gồm signature validation và coin credit.
Test scenarios
Happy path
- [ ]
POST /api/coin/buy-by-cryptovới valid payload → order created,status=PENDING - [ ] Slash webhook
POST /api/webhook/confirm-crypto-paymentvới valid Slash signature → coin credited,status=SUCCESS - [ ] Verify: correct amount credited (crypto amount → coin conversion theo exchange rate hiện tại)
Signature validation
- [ ] Webhook với invalid Slash signature →
SLASH_SIGNATURE_IS_INVALID(hoặc error code tương đương), no DB modification - [ ] Webhook không có signature header → reject
Idempotency
- [ ] Same Slash webhook payload gửi 2 lần (simulate Slash retry) → second call skipped (no double credit)
- [ ] Verify balance: unchanged sau lần 2
Expiry
- [ ] Crypto pending order → mock
CryptoCheckoutExpiredConfigbatch chạy →status=EXPIRED - [ ] Slash webhook sau expiry → status guard blocks, coin not credited
Exchange rate
- [ ]
UpdateExchangeRateConfigbatch cập nhật tỷ giá (mock external rate API) → verify tỷ giá mới được dùng trong order tiếp theo - [ ] Verify: cùng crypto amount với tỷ giá mới → coin amount khác order trước
Verification / Acceptance Criteria
- [ ] Happy path: correct coin amount credited theo conversion formula
- [ ] Invalid signature: rejected, no DB modification
- [ ] Duplicate webhook: idempotent, no double credit
- [ ] Expired order: blocked, not credited
- [ ] Exchange rate update: reflected in subsequent order calculations
Files to Modify
- Test files trong
web/src/test/hoặc integration test module