use of org.hyperledger.besu.ethereum.api.graphql.internal.pojoadapter.EmptyAccountAdapter in project besu by hyperledger.
the class BlockDataFetcherTest method ibftMiner.
@Test
public void ibftMiner() throws Exception {
// IBFT can mine blocks with a coinbase that is an empty account, hence not stored and returned
// as null. The compromise is to report zeros and empty on query from a block.
final Address testAddress = Address.fromHexString("0xdeadbeef");
when(environment.getArgument(ArgumentMatchers.eq("number"))).thenReturn(1L);
when(environment.getArgument(ArgumentMatchers.eq("hash"))).thenReturn(null);
when(environment.getGraphQlContext()).thenReturn(graphQLContext);
when(graphQLContext.get(GraphQLContextType.BLOCKCHAIN_QUERIES)).thenReturn(query);
when(query.blockByNumber(ArgumentMatchers.anyLong())).thenReturn(Optional.of(new BlockWithMetadata<>(header, null, null, null, 0)));
when(header.getCoinbase()).thenReturn(testAddress);
when(query.getWorldState(anyLong())).thenReturn(Optional.of(mutableWorldState));
final Optional<NormalBlockAdapter> maybeBlock = fetcher.get(environment);
assertThat(maybeBlock).isPresent();
assertThat(maybeBlock.get().getMiner(environment)).isPresent();
assertThat(((EmptyAccountAdapter) maybeBlock.get().getMiner(environment).get()).getBalance()).isPresent();
assertThat(((EmptyAccountAdapter) maybeBlock.get().getMiner(environment).get()).getAddress()).contains(testAddress);
}
Aggregations