mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
fix: quic transport mock in quic connection
This commit is contained in:
@ -58,12 +58,6 @@ class QUICConnection(IRawConnection, IMuxedConn):
|
||||
- COMPLETE connection ID management (fixes the original issue)
|
||||
"""
|
||||
|
||||
MAX_CONCURRENT_STREAMS = 256
|
||||
MAX_INCOMING_STREAMS = 1000
|
||||
MAX_OUTGOING_STREAMS = 1000
|
||||
CONNECTION_HANDSHAKE_TIMEOUT = 60.0
|
||||
CONNECTION_CLOSE_TIMEOUT = 10.0
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
quic_connection: QuicConnection,
|
||||
@ -160,6 +154,7 @@ class QUICConnection(IRawConnection, IMuxedConn):
|
||||
self.CONNECTION_HANDSHAKE_TIMEOUT = (
|
||||
transport._config.CONNECTION_HANDSHAKE_TIMEOUT
|
||||
)
|
||||
self.MAX_CONCURRENT_STREAMS = transport._config.MAX_CONCURRENT_STREAMS
|
||||
|
||||
# Performance and monitoring
|
||||
self._connection_start_time = time.time()
|
||||
@ -891,7 +886,6 @@ class QUICConnection(IRawConnection, IMuxedConn):
|
||||
This handles when the peer tells us to stop using a connection ID.
|
||||
"""
|
||||
logger.debug(f"🗑️ CONNECTION ID RETIRED: {event.connection_id.hex()}")
|
||||
logger.debug(f"🗑️ CONNECTION ID RETIRED: {event.connection_id.hex()}")
|
||||
|
||||
# Remove from available IDs and add to retired set
|
||||
self._available_connection_ids.discard(event.connection_id)
|
||||
@ -909,11 +903,9 @@ class QUICConnection(IRawConnection, IMuxedConn):
|
||||
self._stats["connection_id_changes"] += 1
|
||||
else:
|
||||
logger.warning("⚠️ No available connection IDs after retirement!")
|
||||
logger.debug("⚠️ No available connection IDs after retirement!")
|
||||
else:
|
||||
self._current_connection_id = None
|
||||
logger.warning("⚠️ No available connection IDs after retirement!")
|
||||
logger.debug("⚠️ No available connection IDs after retirement!")
|
||||
|
||||
# Update statistics
|
||||
self._stats["connection_ids_retired"] += 1
|
||||
|
||||
@ -12,6 +12,7 @@ import trio
|
||||
|
||||
from libp2p.crypto.ed25519 import create_new_key_pair
|
||||
from libp2p.peer.id import ID
|
||||
from libp2p.transport.quic.config import QUICTransportConfig
|
||||
from libp2p.transport.quic.connection import QUICConnection
|
||||
from libp2p.transport.quic.exceptions import (
|
||||
QUICConnectionClosedError,
|
||||
@ -54,6 +55,12 @@ class TestQUICConnection:
|
||||
mock.reset_stream = Mock()
|
||||
return mock
|
||||
|
||||
@pytest.fixture
|
||||
def mock_quic_transport(self):
|
||||
mock = Mock()
|
||||
mock._config = QUICTransportConfig()
|
||||
return mock
|
||||
|
||||
@pytest.fixture
|
||||
def mock_resource_scope(self):
|
||||
"""Create mock resource scope."""
|
||||
@ -61,7 +68,10 @@ class TestQUICConnection:
|
||||
|
||||
@pytest.fixture
|
||||
def quic_connection(
|
||||
self, mock_quic_connection: Mock, mock_resource_scope: MockResourceScope
|
||||
self,
|
||||
mock_quic_connection: Mock,
|
||||
mock_quic_transport: Mock,
|
||||
mock_resource_scope: MockResourceScope,
|
||||
):
|
||||
"""Create test QUIC connection with enhanced features."""
|
||||
private_key = create_new_key_pair().private_key
|
||||
@ -75,7 +85,7 @@ class TestQUICConnection:
|
||||
local_peer_id=peer_id,
|
||||
is_initiator=True,
|
||||
maddr=Multiaddr("/ip4/127.0.0.1/udp/4001/quic"),
|
||||
transport=Mock(),
|
||||
transport=mock_quic_transport,
|
||||
resource_scope=mock_resource_scope,
|
||||
security_manager=mock_security_manager,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user