Skip to content

Commit

Permalink
test(scale): wait between sending each two messages randomly
Browse files Browse the repository at this point in the history
This seems more like a real scenario.
  • Loading branch information
mkermani144 committed Apr 15, 2024
1 parent 91d7bb0 commit 7b2a730
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/scaling/src/node/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ const MessageCounter = {
},
};

const wait = () =>
new Promise((resolve) => {
setTimeout(resolve, 1 + Math.random() * 9);
});

const messages = Array.from({ length: 10 }).map(
(_, index) => `Ping#${index}:${process.env.NODE_PEER_ID!.slice(-5)}`,
);
Expand All @@ -43,6 +48,7 @@ setInterval(async () => {
`tried to send a message to ${peer.slice(-5)} but failed due to error: ${error}`,
);
}
await wait();
}
}
}
Expand Down

0 comments on commit 7b2a730

Please sign in to comment.