Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Karim Taam <[email protected]>
  • Loading branch information
matkt committed Feb 17, 2025
1 parent e12adea commit 0a23a9b
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.Transaction;
Expand All @@ -42,6 +45,7 @@
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.NoOpTrieLogManager;
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.blockhash.BlockHashLookup;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.tracing.OperationTracer;
Expand All @@ -62,7 +66,9 @@
class ParallelizedConcurrentTransactionProcessorTest {

@Mock private MainnetTransactionProcessor transactionProcessor;
@Mock private BlockHeader chainHeadBlockHeader;
@Mock private BlockHeader blockHeader;
@Mock ProtocolContext protocolContext;
@Mock private Transaction transaction;
@Mock private PrivateMetadataUpdater privateMetadataUpdater;
@Mock private TransactionCollisionDetector transactionCollisionDetector;
Expand All @@ -89,6 +95,19 @@ void setUp() {
new NoOpTrieLogManager(),
EvmConfiguration.DEFAULT,
createStatefulConfigWithTrie());

when(chainHeadBlockHeader.getHash()).thenReturn(Hash.ZERO);
when(chainHeadBlockHeader.getStateRoot()).thenReturn(Hash.EMPTY_TRIE_HASH);
when(blockHeader.getParentHash()).thenReturn(Hash.ZERO);

when(transaction.detachedCopy()).thenReturn(transaction);

final MutableBlockchain blockchain = mock(MutableBlockchain.class);
when(protocolContext.getBlockchain()).thenReturn(blockchain);
when(blockchain.getChainHeadHeader()).thenReturn(chainHeadBlockHeader);
final WorldStateArchive worldStateArchive = mock(WorldStateArchive.class);
when(protocolContext.getWorldStateArchive()).thenReturn(worldStateArchive);
when(worldStateArchive.getWorldState(any())).thenReturn(Optional.of(worldState));
when(transactionCollisionDetector.hasCollision(any(), any(), any(), any())).thenReturn(false);
}

Expand All @@ -105,7 +124,7 @@ void testRunTransaction() {
Collections.emptyList(), 0, 0, Bytes.EMPTY, ValidationResult.valid()));

processor.runTransaction(
worldState,
protocolContext,
blockHeader,
0,
transaction,
Expand Down Expand Up @@ -151,7 +170,7 @@ void testRunTransactionWithFailure() {
Optional.of(Bytes.EMPTY)));

processor.runTransaction(
worldState,
protocolContext,
blockHeader,
0,
transaction,
Expand Down Expand Up @@ -180,7 +199,7 @@ void testRunTransactionWithConflict() {
Collections.emptyList(), 0, 0, Bytes.EMPTY, ValidationResult.valid()));

processor.runTransaction(
worldState,
protocolContext,
blockHeader,
0,
transaction,
Expand Down

0 comments on commit 0a23a9b

Please sign in to comment.