Skip to content

Fix/testing and features 1147 1067 1151 1141#1259

Merged
Olowodarey merged 6 commits into
Arena1X:mainfrom
tech-adrian:fix/testing-and-features-1147-1067-1151-1141
Jun 29, 2026
Merged

Fix/testing and features 1147 1067 1151 1141#1259
Olowodarey merged 6 commits into
Arena1X:mainfrom
tech-adrian:fix/testing-and-features-1147-1067-1151-1141

Conversation

@tech-adrian

Copy link
Copy Markdown
Contributor

Pull Request: Testing & Features Implementation

Summary

This PR addresses four key issues across the backend and smart contract layers:

Changes

Backend Tests (NestJS)

#1147: SeasonsService.findActive Tests

  • Added tests for no season existing in database
  • Added tests for season window hasn't started (future start_at)
  • Added tests for season already ended
  • Added test for multiple overlapping active seasons (returns latest)
  • Result: 15 tests passing ✓

#1141: ResponseInterceptor Tests

  • Created new spec file with 10 comprehensive test cases
  • Tests verify normal responses are wrapped in success envelope
  • Tests confirm StreamableFile instances bypass wrapping
  • Tests verify 204 and 304 status codes bypass wrapping
  • Tests validate timestamp field is added to wrapped responses
  • Result: 10 tests passing ✓

#1151: EventsGateway Rate-Limiter

  • Implemented socket disconnection when rate limit exceeded
  • Added rate-limiting test suite with 5 tests:
    • Verify 60 messages allowed without disconnect
    • Verify 61st message triggers disconnect
    • Verify per-socket rate limiting isolation
    • Verify rate limit counter cleanup after time window
  • Result: 15 tests passing ✓

Smart Contract (Soroban/Rust)

#1067: Market End-Time Extension Feature

  • Added extend_market_end_time function to market.rs
  • Wired into contract implementation in lib.rs
  • Added MarketAlreadyClosed error type (code 25)
  • Comprehensive validation:
    • Only creator can call
    • Only before market end_time passes
    • New end_time must be strictly later than current
    • Market cannot be resolved, cancelled, or closed
    • Automatically adjusts resolution_time to maintain invariant
  • Added 8 integration tests:
    • Successful extension
    • Resolution time auto-adjustment
    • Creator-only access control
    • Time window validation
    • All market state restrictions
  • Result: 58 market tests passing ✓

Testing

Backend

npm test -- src/seasons/seasons.service.spec.ts          # 15 tests ✓
npm test -- src/common/interceptors/response.interceptor.spec.ts  # 10 tests ✓
npm test -- src/websocket/events.gateway.spec.ts         # 15 tests ✓

All 40 tests passing

Smart Contract

cargo test --test market_tests  # 58 tests ✓

All tests passing, no warnings

Files Changed

Backend:

  • src/seasons/seasons.service.spec.ts - Enhanced findActive tests
  • src/common/interceptors/response.interceptor.spec.ts - New test suite
  • src/websocket/events.gateway.ts - Added socket disconnect
  • src/websocket/events.gateway.spec.ts - Enhanced rate-limiter tests

Smart Contract:

  • src/market.rs - Added extend_market_end_time function
  • src/lib.rs - Wired new function into contract
  • src/errors.rs - Added MarketAlreadyClosed error type
  • tests/market_tests.rs - Added 8 integration tests

Closes

tech-adrian and others added 6 commits June 29, 2026 12:47
…null handling

Tests cover:
- No season exists in database
- Season window hasn't started yet
- Season has already ended
- Multiple overlapping active seasons returns latest

Closes Arena1X#1147

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Tests verify:
- Normal responses wrapped in success envelope
- StreamableFile instances not wrapped
- 204 and 304 status codes bypass wrapping
- Timestamp field added to wrapped responses
- Array and null responses handled correctly

Closes Arena1X#1141

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Implement proper socket disconnection when rate limit is exceeded.
Add tests to verify:
- Socket remains connected after 60 messages
- Socket disconnects on 61st message
- Rate limiting is enforced per-socket
- Rate limit counter resets after time window expires

Closes Arena1X#1151

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Allows market creators to extend the end_time of a market before it closes.

Implementation:
- Add extend_market_end_time function in market.rs
- Wire into lib.rs contract implementation
- Add MarketAlreadyClosed error type
- Automatically adjust resolution_time if needed to maintain invariant

Validation:
- Only creator can call
- Only before market end_time passes
- New end_time must be strictly later than current
- Market cannot be resolved, cancelled, or closed
- Resolution time >= end_time invariant maintained

Tests cover:
- Successful extension
- Resolution time adjustment when needed
- Unauthorized access prevention
- All market state restrictions
- Time range validation

Closes Arena1X#1067

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Fixes:
- Response interceptor: simplify 204/304 status passthrough assertions
- Events gateway: add disconnect mock to socket factory
- Events gateway: fix timer test to properly verify rate limit cleanup

All tests now passing.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Changes:
- Assign MarketAlreadyClosed error code 25 (was conflicting with PredictionNotFound)
- Remove unnecessary `mut` keywords from test variables
- Remove unused variable warnings

All 58 market tests pass successfully.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
insight-arena-4rll Ready Ready Preview, Comment Jun 29, 2026 12:13pm

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@tech-adrian 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

@Olowodarey Olowodarey merged commit fb3b2bc into Arena1X:main Jun 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment