Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <[email protected]>
  • Loading branch information
fab-10 committed Oct 23, 2023
1 parent bf8eba4 commit 4716d89
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.metrics.StubMetricsSystem;
import org.hyperledger.besu.testutil.DeterministicEthScheduler;
import org.hyperledger.besu.testutil.TestClock;
import org.hyperledger.besu.util.number.Fraction;

Expand Down Expand Up @@ -131,6 +130,8 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
EthContext ethContext;

@Mock EthScheduler ethScheduler;

private final Address coinbase = genesisAllocations(getPosGenesisConfigFile()).findFirst().get();

private MiningParameters miningParameters =
Expand Down Expand Up @@ -179,7 +180,6 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
CompletableFuture<Void> blockCreationTask = CompletableFuture.completedFuture(null);

private final BadBlockManager badBlockManager = spy(new BadBlockManager());
private final EthScheduler ethScheduler = new DeterministicEthScheduler();

@BeforeEach
public void setUp() {
Expand All @@ -206,13 +206,16 @@ public void setUp() {
genesisState.writeStateTo(mutable);
mutable.persist(null);

// when(proposalBuilderExecutor.buildProposal(any()))
// .thenAnswer(
// invocation -> {
// final Runnable runnable = invocation.getArgument(0);
// blockCreationTask = CompletableFuture.runAsync(runnable);
// return blockCreationTask;
// });
when(ethScheduler.scheduleBlockCreationTask(any()))
.thenAnswer(
invocation -> {
final Runnable runnable = invocation.getArgument(0);
if (!invocation.toString().contains("MergeCoordinator")) {
return CompletableFuture.runAsync(runnable);
}
blockCreationTask = CompletableFuture.runAsync(runnable);
return blockCreationTask;
});

MergeConfigOptions.setMergeEnabled(true);

Expand Down Expand Up @@ -648,7 +651,7 @@ public void shouldNotStartAnotherBlockCreationJobIfCalledAgainWithTheSamePayload
doAnswer(
invocation -> {
if (retries.getAndIncrement() < 5) {
// a new transaction every time a block is built
// add a new transaction every time a block is built
transactions.addTransaction(
createLocalTransaction(retries.get() - 1), Optional.empty());
} else {
Expand Down

0 comments on commit 4716d89

Please sign in to comment.