diff --git a/packages/programs/data/shared-log/test/sharding.spec.ts b/packages/programs/data/shared-log/test/sharding.spec.ts index f8786d6c3..be35f9a93 100644 --- a/packages/programs/data/shared-log/test/sharding.spec.ts +++ b/packages/programs/data/shared-log/test/sharding.spec.ts @@ -17,6 +17,7 @@ import { checkBounded, checkIfSetupIsUsed, dbgLogs, + slowDownSend, waitForConverged, } from "./utils.js"; import { EventStore } from "./utils/stores/event-store.js"; diff --git a/packages/programs/data/shared-log/test/utils.ts b/packages/programs/data/shared-log/test/utils.ts index 86a513e14..ee08ee4c3 100644 --- a/packages/programs/data/shared-log/test/utils.ts +++ b/packages/programs/data/shared-log/test/utils.ts @@ -45,14 +45,14 @@ export const collectMessagesFn = (log: SharedLog) => { export const slowDownSend = ( from: ProgramClient, to: ProgramClient, - ms = 3000, + ms: number | (() => number) = 3000, ) => { const directsub = from.services.pubsub as DirectSub; for (const [_key, peer] of directsub.peers) { if (peer.publicKey.equals(to.identity.publicKey)) { const writeFn = peer.write.bind(peer); peer.write = async (msg, priority) => { - await delay(ms); + await delay(typeof ms === "number" ? ms : ms()); if (peer.outboundStream) { return writeFn(msg, priority); }