Skip to content

Commit

Permalink
7311: Replace EthProtocolManagerTestUtil.create(EthScheduler)
Browse files Browse the repository at this point in the history
Signed-off-by: Matilda Clerke <[email protected]>
  • Loading branch information
Matilda-Clerke committed Nov 28, 2024
1 parent c8b6e28 commit 37bba0f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
Expand Down Expand Up @@ -94,12 +95,14 @@ public void setUpUnchangedState() {

tempDir = Files.createTempDir().toPath();
ethProtocolManager =
EthProtocolManagerTestUtil.create(
new EthScheduler(
syncConfig.getDownloaderParallelism(),
syncConfig.getTransactionsParallelism(),
syncConfig.getComputationParallelism(),
metricsSystem));
EthProtocolManagerTestBuilder.builder()
.setEthScheduler(
new EthScheduler(
syncConfig.getDownloaderParallelism(),
syncConfig.getTransactionsParallelism(),
syncConfig.getComputationParallelism(),
metricsSystem))
.build();

peer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager, blockHeader.getNumber());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@
package org.hyperledger.besu.ethereum.eth.manager;

import static com.google.common.base.Preconditions.checkArgument;
import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;

import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.ChainHead;
import org.hyperledger.besu.ethereum.chain.GenesisState;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.snap.SnapProtocolManager;
Expand Down Expand Up @@ -170,13 +166,6 @@ public static EthProtocolManager create(
forkIdManager);
}

public static EthProtocolManager create(final Blockchain blockchain) {
return create(
ProtocolScheduleFixture.MAINNET,
blockchain,
new DeterministicEthScheduler(TimeoutPolicy.NEVER_TIMEOUT));
}

public static EthProtocolManager create(
final ProtocolSchedule protocolSchedule,
final Blockchain blockchain,
Expand All @@ -192,14 +181,6 @@ public static EthProtocolManager create(
ethProtocolConfiguration);
}

public static EthProtocolManager create(final EthScheduler ethScheduler) {
final ProtocolSchedule protocolSchedule = ProtocolScheduleFixture.MAINNET;
final GenesisConfigFile config = GenesisConfigFile.mainnet();
final GenesisState genesisState = GenesisState.fromConfig(config, protocolSchedule);
final Blockchain blockchain = createInMemoryBlockchain(genesisState.getBlock());
return create(protocolSchedule, blockchain, ethScheduler);
}

public static EthProtocolManager create(
final ProtocolSchedule protocolSchedule,
final Blockchain blockchain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.hyperledger.besu.ethereum.eth.manager.ChainState;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer.Responder;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestBuilder;
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
import org.hyperledger.besu.ethereum.eth.manager.exceptions.MaxRetriesReachedException;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
Expand Down Expand Up @@ -130,7 +130,8 @@ public void setup() {
when(context.getProtocolSchedule()).thenReturn(protocolSchedule);
when(context.getBatchSize()).thenReturn(5);

EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create(ethScheduler);
EthProtocolManager ethProtocolManager =
EthProtocolManagerTestBuilder.builder().setEthScheduler(ethScheduler).build();

peer =
RespondingEthPeer.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ class FastWorldStateDownloaderTest {
.build());

final EthProtocolManager ethProtocolManager =
EthProtocolManagerTestUtil.create(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()));
EthProtocolManagerTestBuilder.builder()
.setEthScheduler(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()))
.build();

@AfterEach
public void tearDown() throws Exception {
Expand Down Expand Up @@ -665,7 +667,9 @@ void doesNotRequestKnownStorageTrieNodesFromNetwork() {
@Timeout(value = 60)
void stalledDownloader() {
final EthProtocolManager ethProtocolManager =
EthProtocolManagerTestUtil.create(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()));
EthProtocolManagerTestBuilder.builder()
.setEthScheduler(new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem()))
.build();

// Setup "remote" state
final ForestWorldStateKeyValueStorage remoteStorage =
Expand Down

0 comments on commit 37bba0f

Please sign in to comment.