Skip to content

Commit

Permalink
chore: Test starting multiple anvils allocates distinct ports (#11314)
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino authored Jan 20, 2025
1 parent 079a2c4 commit e385ea9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions yarn-project/ethereum/src/test/start_anvil.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { times } from '@aztec/foundation/collection';

import { createPublicClient, http } from 'viem';

import { startAnvil } from './start_anvil.js';
Expand All @@ -22,4 +24,11 @@ describe('start_anvil', () => {
await anvil.stop();
expect(anvil.status).toEqual('idle');
});

it('does not reuse ports when starting multiple instances', async () => {
const anvils = await Promise.all(times(20, () => startAnvil()));
const ports = anvils.map(({ rpcUrl }) => parseInt(new URL(rpcUrl).port));
expect(new Set(ports).size).toEqual(20);
await Promise.all(anvils.map(({ anvil }) => anvil.stop()));
});
});

0 comments on commit e385ea9

Please sign in to comment.