Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@terwey
Copy link
Collaborator

@terwey terwey commented Nov 7, 2025

Add 22 new integration tests covering critical gaps in Hyperliquid WebSocket and BBO functionality:

WebSocket Order Updates (6 tests):

  • Order creation, modification, and cancellation via WebSocket
  • Full and partial fill updates
  • Integration with fill tracker service
  • Multiple concurrent orders handling
  • WebSocket reconnection scenarios

BBO Subscription (10 tests):

  • Basic BBO subscription and data retrieval
  • Multiple coin subscriptions
  • BBO channel broadcasting to multiple subscribers
  • Case-insensitive coin symbol handling
  • Context timeout handling
  • Subscription cleanup on context cancellation
  • BBO data for IOC order pricing
  • Concurrent BBO subscriptions across different coins

Multi-Wallet Support (6 tests):

  • Order isolation between different wallets
  • Concurrent order creation across multiple wallets
  • BBO data sharing across wallet connections
  • Concurrent BBO subscriptions from multiple wallets
  • Combined order operations and BBO subscriptions

These tests address the critical missing coverage identified in the investigation, particularly around real-time WebSocket updates and market data functionality that are essential for production readiness.

Related to multi-wallet Hyperliquid support.

Add 22 new integration tests covering critical gaps in Hyperliquid
WebSocket and BBO functionality:

WebSocket Order Updates (6 tests):
- Order creation, modification, and cancellation via WebSocket
- Full and partial fill updates
- Integration with fill tracker service
- Multiple concurrent orders handling
- WebSocket reconnection scenarios

BBO Subscription (10 tests):
- Basic BBO subscription and data retrieval
- Multiple coin subscriptions
- BBO channel broadcasting to multiple subscribers
- Case-insensitive coin symbol handling
- Context timeout handling
- Subscription cleanup on context cancellation
- BBO data for IOC order pricing
- Concurrent BBO subscriptions across different coins

Multi-Wallet Support (6 tests):
- Order isolation between different wallets
- Concurrent order creation across multiple wallets
- BBO data sharing across wallet connections
- Concurrent BBO subscriptions from multiple wallets
- Combined order operations and BBO subscriptions

These tests address the critical missing coverage identified in the
investigation, particularly around real-time WebSocket updates and
market data functionality that are essential for production readiness.

Related to multi-wallet Hyperliquid support.
@terwey terwey force-pushed the claude/investigate-multi-wallet-hyperliquid-011CUttd5YC1AH2KMtTV8QUu branch from 24fb0f7 to 6c2729c Compare November 7, 2025 18:36
claude and others added 6 commits November 7, 2025 18:42
- Change filltracker.NewService back to filltracker.New
- Remove unused storage import from bbo_integration_test.go
- Remove unused storage import from multi_wallet_integration_test.go
Remove calls to non-existent filltracker methods (SubmitBaseOrder, CurrentPosition).
The test now verifies WebSocket properly passes updates to the tracker via
UpdateStatus, which is the actual integration point.
VenueID type changed from int to string. Update all test files to use
string format for venue IDs (e.g., 'test-venue-1' instead of 1).
Fix remaining int to string conversions for VenueID in concurrent test loops.
The go-hyperliquid SDK WebSocket client defaults to TLS (wss://) but
the mock server runs on HTTP. These tests are temporarily skipped until:
1. The mock server adds non-TLS WebSocket support, OR
2. The go-hyperliquid SDK adds a WsOpt to disable TLS for testing

Issue: WebSocket dial returns 'tls: first record does not look like a TLS handshake'

Tests skipped:
- TestMultiWalletBBOSharing
- TestMultiWalletConcurrentBBOSubscriptions
- TestMultiWalletOrderAndBBOConcurrent
- dep: fix upstream hyperliquid client to support non-TLS Websocket scheme
  - chore: temporarily replace with fork for dependency
@terwey terwey force-pushed the claude/investigate-multi-wallet-hyperliquid-011CUttd5YC1AH2KMtTV8QUu branch from c199ad4 to 0e1e2a5 Compare November 8, 2025 10:02
terwey and others added 12 commits November 8, 2025 14:30
After upgrading hyperliquid-mock from v0.0.3 to v0.1.0, the mock server
now enforces wallet isolation. This caused 25 test failures where tests
created orders with one wallet (from newMockExchange) but queried them
with a different hardcoded wallet (e.g., "0xtest").

Changes:
- Modified newMockExchange() to return both the Exchange and its wallet address
- Updated all Info client instantiations to use the wallet from newMockExchange
- Updated all WebSocket client instantiations to use the wallet from newMockExchange
- Fixed multi-wallet tests to use wallets from newMockExchange instead of hardcoded values

This ensures that Info queries, WebSocket subscriptions, and order operations
all use the same wallet address, respecting the mock server's isolation.

Fixes:
- 16 Info/OrderLifecycle test failures (unknown_cloid errors)
- 4 StatusRefresher test failures
- 5 WebSocket test failures (timeouts waiting for events)

Co-authored-by: Claude <[email protected]>
The test was expecting wallets NOT to see their own orders, which was
based on the old behavior where WebSocket clients subscribed to hardcoded
wallet addresses that differed from the exchange wallets.

With proper wallet isolation, the test should verify:
- Wallet 1 client SEES wallet 1 orders (✓)
- Wallet 1 client does NOT see wallet 2 orders (✓)
- Wallet 2 client SEES wallet 2 orders (✓)
- Wallet 2 client does NOT see wallet 1 orders (✓)

This properly tests wallet isolation: each wallet sees only its own orders.

Co-authored-by: Claude <[email protected]>
This documents the intermittent WebSocket orderUpdates delivery failures
observed with hyperliquid-mock v0.1.0 when multiple wallets connect
concurrently. Includes reproduction steps, suspected root causes, and
debug instrumentation recommendations.

Co-authored-by: Claude <[email protected]>
This version includes the fix for WebSocket race condition when
multiple wallets connect concurrently (see BUG_REPORT_WEBSOCKET_RACE.md).

Note: go.sum needs to be updated via 'go mod tidy' - unable to download
dependencies in current environment.

Co-authored-by: Claude <[email protected]>
The WebSocket race condition has been resolved in hyperliquid-mock v0.1.1.
Added a prominent update notice at the top of the bug report.

Co-authored-by: Claude <[email protected]>
In CI environments, WebSocket subscriptions need a brief moment to fully
establish before orders are created. Without this delay, rapid order
creation can result in missed WebSocket updates due to:
- Subscription not fully registered in mock server
- Goroutine scheduling differences in CI
- Network timing variations

Adding 100ms delay after ws.New() ensures subscription is ready before
test operations begin. This resolves flaky CI failures in:
- TestWebSocketMultipleOrders
- TestWebSocketReconnection

Tests pass consistently locally but fail in CI due to timing differences.
This is a pragmatic fix while mock server implements more robust
subscription handshaking.

Co-authored-by: Claude <[email protected]>
…011CUvWQj6z6hFJFmECjFPAx

fix: align integration tests with hyperliquid-mock wallet isolation
dep: dependency hyperliquid-mock now supports multi-wallet
@terwey terwey marked this pull request as ready for review November 8, 2025 18:39
@terwey terwey merged commit 9dda792 into codex/investigate-multi-wallet-support-for-hyperliquid Nov 8, 2025
1 check passed
@terwey terwey deleted the claude/investigate-multi-wallet-hyperliquid-011CUttd5YC1AH2KMtTV8QUu branch November 8, 2025 18:44
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.

3 participants