@@ -5,7 +5,7 @@ import { CallRequest, Cbor } from "@dfinity/agent";
5
5
import { IDL } from "@dfinity/candid" ;
6
6
import { Principal } from "@dfinity/principal" ;
7
7
8
- import IcWebSocket , { MAX_ALLOWED_NETWORK_LATENCY_MS , createWsConfig } from "./ic-websocket" ;
8
+ import IcWebSocket , { COMMUNICATION_LATENCY_BOUND_MS , createWsConfig } from "./ic-websocket" ;
9
9
import { generateRandomIdentity } from "./identity" ;
10
10
import {
11
11
CanisterWsMessageArguments ,
@@ -241,7 +241,7 @@ describe("IcWebsocket class", () => {
241
241
mockWsServer . send ( encodeHandshakeMessage ( VALID_HANDSHAKE_MESSAGE_FROM_GATEWAY ) ) ;
242
242
243
243
// advance the open timeout
244
- await jest . advanceTimersByTimeAsync ( 2 * MAX_ALLOWED_NETWORK_LATENCY_MS ) ;
244
+ await jest . advanceTimersByTimeAsync ( 2 * COMMUNICATION_LATENCY_BOUND_MS ) ;
245
245
246
246
expect ( icWs [ "_isConnectionEstablished" ] ) . toEqual ( false ) ;
247
247
expect ( onOpen ) . not . toHaveBeenCalled ( ) ;
@@ -313,15 +313,15 @@ describe("IcWebsocket class", () => {
313
313
await sleep ( 100 ) ;
314
314
315
315
// wait for the open timeout so that it expires
316
- await sleep ( 2 * MAX_ALLOWED_NETWORK_LATENCY_MS ) ;
316
+ await sleep ( 2 * COMMUNICATION_LATENCY_BOUND_MS ) ;
317
317
318
318
expect ( onOpen ) . toHaveBeenCalled ( ) ;
319
319
expect ( icWs [ "_isConnectionEstablished" ] ) . toEqual ( true ) ;
320
320
expect ( onError ) . not . toHaveBeenCalled ( ) ;
321
321
expect ( icWs . readyState ) . toEqual ( WebSocket . OPEN ) ;
322
322
// make sure onmessage callback is not called when receiving the first message
323
323
expect ( onMessage ) . not . toHaveBeenCalled ( ) ;
324
- } , 3 * MAX_ALLOWED_NETWORK_LATENCY_MS ) ;
324
+ } , 3 * COMMUNICATION_LATENCY_BOUND_MS ) ;
325
325
326
326
it ( "onmessage is called when a valid message is received" , async ( ) => {
327
327
const onMessage = jest . fn ( ) ;
@@ -563,7 +563,7 @@ describe("Messages acknowledgement", () => {
563
563
await mockWsServer . nextMessage ;
564
564
565
565
// make the ack timeout expire
566
- await jest . advanceTimersByTimeAsync ( ackMessageIntervalMs + MAX_ALLOWED_NETWORK_LATENCY_MS ) ;
566
+ await jest . advanceTimersByTimeAsync ( ackMessageIntervalMs + COMMUNICATION_LATENCY_BOUND_MS ) ;
567
567
568
568
const ackTimeoutError = new Error ( `Ack message timeout. Not received ack for sequence numbers: ${ [ BigInt ( 1 ) ] } ` ) ;
569
569
expect ( onError ) . toHaveBeenCalledWith ( new ErrorEvent ( "error" , { error : ackTimeoutError } ) ) ;
@@ -610,7 +610,7 @@ describe("Messages acknowledgement", () => {
610
610
await mockWsServer . nextMessage ;
611
611
612
612
// make the ack timeout expire
613
- await jest . advanceTimersByTimeAsync ( ackMessageIntervalMs + MAX_ALLOWED_NETWORK_LATENCY_MS ) ;
613
+ await jest . advanceTimersByTimeAsync ( ackMessageIntervalMs + COMMUNICATION_LATENCY_BOUND_MS ) ;
614
614
615
615
// send the ack message from the canister
616
616
// when the ack timeout is already expired
@@ -667,7 +667,7 @@ describe("Messages acknowledgement", () => {
667
667
console . log ( "sent ack message from canister" ) ;
668
668
669
669
// make the ack timeout expire
670
- await jest . advanceTimersByTimeAsync ( ackMessageIntervalMs + MAX_ALLOWED_NETWORK_LATENCY_MS ) ;
670
+ await jest . advanceTimersByTimeAsync ( ackMessageIntervalMs + COMMUNICATION_LATENCY_BOUND_MS ) ;
671
671
672
672
// first message has been acknowledged correctly,
673
673
// as the error only reports the missing ack for the keep alive response
0 commit comments