1919import static org .mockito .ArgumentMatchers .any ;
2020import static org .mockito .ArgumentMatchers .anyBoolean ;
2121import static org .mockito .ArgumentMatchers .eq ;
22+ import static org .mockito .Mockito .mock ;
2223import static org .mockito .Mockito .times ;
2324import static org .mockito .Mockito .verify ;
2425import static org .mockito .Mockito .when ;
2526
2627import org .hyperledger .besu .datatypes .Address ;
2728import org .hyperledger .besu .datatypes .Hash ;
2829import org .hyperledger .besu .datatypes .Wei ;
30+ import org .hyperledger .besu .ethereum .ProtocolContext ;
31+ import org .hyperledger .besu .ethereum .chain .MutableBlockchain ;
2932import org .hyperledger .besu .ethereum .core .BlockHeader ;
3033import org .hyperledger .besu .ethereum .core .InMemoryKeyValueStorageProvider ;
3134import org .hyperledger .besu .ethereum .core .Transaction ;
4245import org .hyperledger .besu .ethereum .trie .diffbased .common .trielog .NoOpTrieLogManager ;
4346import org .hyperledger .besu .ethereum .trie .diffbased .common .worldview .accumulator .DiffBasedWorldStateUpdateAccumulator ;
4447import org .hyperledger .besu .ethereum .worldstate .DataStorageConfiguration ;
48+ import org .hyperledger .besu .ethereum .worldstate .WorldStateArchive ;
4549import org .hyperledger .besu .evm .blockhash .BlockHashLookup ;
4650import org .hyperledger .besu .evm .internal .EvmConfiguration ;
4751import org .hyperledger .besu .evm .tracing .OperationTracer ;
6266class ParallelizedConcurrentTransactionProcessorTest {
6367
6468 @ Mock private MainnetTransactionProcessor transactionProcessor ;
69+ @ Mock private BlockHeader chainHeadBlockHeader ;
6570 @ Mock private BlockHeader blockHeader ;
71+ @ Mock ProtocolContext protocolContext ;
6672 @ Mock private Transaction transaction ;
6773 @ Mock private PrivateMetadataUpdater privateMetadataUpdater ;
6874 @ Mock private TransactionCollisionDetector transactionCollisionDetector ;
@@ -89,6 +95,19 @@ void setUp() {
8995 new NoOpTrieLogManager (),
9096 EvmConfiguration .DEFAULT ,
9197 createStatefulConfigWithTrie ());
98+
99+ when (chainHeadBlockHeader .getHash ()).thenReturn (Hash .ZERO );
100+ when (chainHeadBlockHeader .getStateRoot ()).thenReturn (Hash .EMPTY_TRIE_HASH );
101+ when (blockHeader .getParentHash ()).thenReturn (Hash .ZERO );
102+
103+ when (transaction .detachedCopy ()).thenReturn (transaction );
104+
105+ final MutableBlockchain blockchain = mock (MutableBlockchain .class );
106+ when (protocolContext .getBlockchain ()).thenReturn (blockchain );
107+ when (blockchain .getChainHeadHeader ()).thenReturn (chainHeadBlockHeader );
108+ final WorldStateArchive worldStateArchive = mock (WorldStateArchive .class );
109+ when (protocolContext .getWorldStateArchive ()).thenReturn (worldStateArchive );
110+ when (worldStateArchive .getWorldState (any ())).thenReturn (Optional .of (worldState ));
92111 when (transactionCollisionDetector .hasCollision (any (), any (), any (), any ())).thenReturn (false );
93112 }
94113
@@ -105,7 +124,7 @@ void testRunTransaction() {
105124 Collections .emptyList (), 0 , 0 , Bytes .EMPTY , ValidationResult .valid ()));
106125
107126 processor .runTransaction (
108- worldState ,
127+ protocolContext ,
109128 blockHeader ,
110129 0 ,
111130 transaction ,
@@ -151,7 +170,7 @@ void testRunTransactionWithFailure() {
151170 Optional .of (Bytes .EMPTY )));
152171
153172 processor .runTransaction (
154- worldState ,
173+ protocolContext ,
155174 blockHeader ,
156175 0 ,
157176 transaction ,
@@ -180,7 +199,7 @@ void testRunTransactionWithConflict() {
180199 Collections .emptyList (), 0 , 0 , Bytes .EMPTY , ValidationResult .valid ()));
181200
182201 processor .runTransaction (
183- worldState ,
202+ protocolContext ,
184203 blockHeader ,
185204 0 ,
186205 transaction ,
0 commit comments