Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Jan 19, 2025
1 parent 58ac0da commit 0cf7826
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions yarn-project/p2p/src/services/reqresp/reqresp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,16 @@ describe('ReqResp', () => {
void nodes[2].req.stop();

// send from the first node
const res = await nodes[0].req.sendRequest(ReqRespSubProtocol.PING, PING_REQUEST);
let res = await nodes[0].req.sendRequest(ReqRespSubProtocol.PING, PING_REQUEST);

// It will randomly try to connect, then hit the correct node
if (!res) {
// The peer chosen is randomly selected, and the node above wont respond, so if
// we wait and try again, there will only be one node to chose from
await sleep(500);
res = await nodes[0].req.sendRequest(ReqRespSubProtocol.PING, PING_REQUEST);
}

// It will randomly try to connect, then hit the correct node
expect(res?.toBuffer().toString('utf-8')).toEqual('pong');
});

Expand Down

0 comments on commit 0cf7826

Please sign in to comment.