Skip to content

Commit

Permalink
chore: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Aug 27, 2024
1 parent f38069d commit 6562109
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions yarn-project/end-to-end/src/e2e_p2p_network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ import { type PXEService, createPXEService, getPXEServiceConfig as getRpcConfig

import { jest } from '@jest/globals';
import fs from 'fs';
import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
import { privateKeyToAccount } from 'viem/accounts';

import { MNEMONIC } from './fixtures/fixtures.js';
import {
type NodeContext,
createBootstrapNode,
createNode,
createNodes,
generatePeerIdPrivateKeys,
} from './fixtures/setup_p2p_test.js';
import { setup } from './fixtures/utils.js';
import { getPrivateKeyFromIndex, setup } from './fixtures/utils.js';

// Don't set this to a higher value than 9 because each node will use a different L1 publisher account and anvil seeds
const NUM_NODES = 4;
Expand All @@ -44,19 +43,15 @@ describe('e2e_p2p_network', () => {

// We need the very first node to be the sequencer for this is the one doing everything throughout the setup.
// Without it we will wait forever.
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
const publisherPrivKey = Buffer.from(hdAccount.getHdKey().privateKey!);
const account = privateKeyToAccount(`0x${publisherPrivKey!.toString('hex')}`);
const account = privateKeyToAccount(`0x${getPrivateKeyFromIndex(0)!.toString('hex')}`);

const initialValidators = [EthAddress.fromString(account.address)];

// Add 1 extra validator if in devnet or NUM_NODES if not.
// Each of these will become a validator and sign attestations.
const limit = IS_DEV_NET ? 1 : NUM_NODES;
for (let i = 0; i < limit; i++) {
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: i + 1 });
const publisherPrivKey = Buffer.from(hdAccount.getHdKey().privateKey!);
const account = privateKeyToAccount(`0x${publisherPrivKey!.toString('hex')}`);
const account = privateKeyToAccount(`0x${getPrivateKeyFromIndex(i + 1)!.toString('hex')}`);
initialValidators.push(EthAddress.fromString(account.address));
}

Expand Down

0 comments on commit 6562109

Please sign in to comment.