Skip to content

Commit 28fc709

Browse files
committed
mocking for http tests
Signed-off-by: Sally MacFarlane <[email protected]>
1 parent 625f9e7 commit 28fc709

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
import static java.util.concurrent.TimeUnit.MINUTES;
1919
import static org.assertj.core.api.Assertions.assertThat;
2020
import static org.assertj.core.util.Lists.list;
21+
import static org.mockito.Mockito.lenient;
2122
import static org.mockito.Mockito.mock;
2223

2324
import org.hyperledger.besu.config.StubGenesisConfigOptions;
25+
import org.hyperledger.besu.datatypes.Hash;
2426
import org.hyperledger.besu.ethereum.ProtocolContext;
2527
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
2628
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
@@ -37,6 +39,8 @@
3739
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
3840
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
3941
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
42+
import org.hyperledger.besu.ethereum.chain.Blockchain;
43+
import org.hyperledger.besu.ethereum.core.Block;
4044
import org.hyperledger.besu.ethereum.core.MiningConfiguration;
4145
import org.hyperledger.besu.ethereum.core.Synchronizer;
4246
import org.hyperledger.besu.ethereum.eth.EthProtocol;
@@ -131,6 +135,13 @@ public static void initServerAndClient() throws Exception {
131135
final StubGenesisConfigOptions genesisConfigOptions =
132136
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID);
133137

138+
// mocks so that genesis hash is populated
139+
Blockchain blockchain = mock(Blockchain.class);
140+
Block block = mock(Block.class);
141+
lenient().when(blockchainQueries.getBlockchain()).thenReturn(blockchain);
142+
lenient().when(blockchain.getGenesisBlock()).thenReturn(block);
143+
lenient().when(block.getHash()).thenReturn(Hash.EMPTY);
144+
134145
rpcMethods =
135146
new JsonRpcMethodsFactory()
136147
.methods(

0 commit comments

Comments
 (0)