Skip to content

Commit 4b37339

Browse files
committed
test bugfix
1 parent d51bd2b commit 4b37339

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

yarn-project/p2p/src/client/test/p2p_client.integration_batch_txs.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { times } from '@aztec/foundation/collection';
33
import { Secp256k1Signer } from '@aztec/foundation/crypto';
44
import { Fr } from '@aztec/foundation/fields';
55
import { type Logger, createLogger } from '@aztec/foundation/log';
6+
import { retryUntil } from '@aztec/foundation/retry';
67
import { sleep } from '@aztec/foundation/sleep';
78
import { emptyChainConfig } from '@aztec/stdlib/config';
89
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
@@ -142,11 +143,17 @@ describe('p2p client integration batch txs', () => {
142143
logger,
143144
})
144145
).map(x => x.client);
146+
};
145147

148+
async function makeSureClientsAreStarted() {
146149
// Give the nodes time to discover each other
147150
await sleep(4000);
151+
for (const c of clients) {
152+
await retryUntil(async () => (await c.getPeers()).length == clients.length - 1, 'peers discovered', 12, 0.5);
153+
}
154+
148155
logger.info('Finished waiting for clients to connect');
149-
};
156+
}
150157

151158
it.only('batch requester fetches all missing txs from multiple peers', async () => {
152159
const NUMBER_OF_PEERS = 4;
@@ -188,6 +195,7 @@ describe('p2p client integration batch txs', () => {
188195
}
189196

190197
await setupClients(NUMBER_OF_PEERS, txPoolMocks);
198+
await makeSureClientsAreStarted();
191199

192200
const peerIds = clients.map(client => (client as any).p2pService.node.peerId);
193201
connectionSampler.getPeerListSortedByConnectionCountAsc.mockReturnValue(peerIds);
@@ -206,6 +214,7 @@ describe('p2p client integration batch txs', () => {
206214
5_000,
207215
(client0 as any).p2pService.reqresp,
208216
connectionSampler,
217+
() => Promise.resolve(true),
209218
logger,
210219
);
211220

yarn-project/p2p/src/services/reqresp/batch-tx-requester/missing_txs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class MissingTxMetadataCollection extends Map<string, MissingTxMetadata>
7272
}
7373

7474
public isFetched(txHash: TxHash): boolean {
75-
// If something went' wrong and we don't have txMeta for this hash
75+
// If something went wrong and we don't have txMeta for this hash
7676
// We should not request it, so here we "pretend" that it was fetched
7777
return this.get(txHash.toString())?.fetched ?? true;
7878
}

yarn-project/p2p/src/services/reqresp/batch-tx-requester/reqresp_batch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export class BatchTxRequester {
175175
if (!nextBatchTxRequest) {
176176
this.logger.warn(`Worker loop dumb: Could not create next batch request`);
177177
// We retry with the next peer/batch
178+
console.log(`[${count}] Worker loop dumb: Could not create next batch request for peer ${peerId.toString()}`);
178179
continue;
179180
}
180181

0 commit comments

Comments
 (0)