use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.SignerMetricResult in project besu by hyperledger.
the class QbftGetSignerMetricsTest method getSignerMetricsWithEarliest.
@Test
@SuppressWarnings("unchecked")
public void getSignerMetricsWithEarliest() {
final long startBlock = 0L;
final long endBlock = 3L;
final List<SignerMetricResult> signerMetricResultList = new ArrayList<>();
when(blockchainQueries.headBlockNumber()).thenReturn(endBlock);
LongStream.range(startBlock, endBlock).forEach(value -> signerMetricResultList.add(generateBlock(value)));
final JsonRpcRequestContext request = requestWithParams("earliest", String.valueOf(endBlock));
final JsonRpcSuccessResponse response = (JsonRpcSuccessResponse) method.response(request);
assertThat((Collection<SignerMetricResult>) response.getResult()).containsExactlyInAnyOrderElementsOf(signerMetricResultList);
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.SignerMetricResult in project besu by hyperledger.
the class QbftGetSignerMetricsTest method getSignerMetricsWhenNoParams.
@Test
@SuppressWarnings("unchecked")
public void getSignerMetricsWhenNoParams() {
final long startBlock = 1L;
final long endBlock = 3L;
when(blockchainQueries.headBlockNumber()).thenReturn(endBlock);
final List<SignerMetricResult> signerMetricResultList = new ArrayList<>();
LongStream.range(startBlock, endBlock).forEach(value -> signerMetricResultList.add(generateBlock(value)));
// missing validator
signerMetricResultList.add(new SignerMetricResult(VALIDATORS[0]));
final JsonRpcRequestContext request = requestWithParams();
final JsonRpcSuccessResponse response = (JsonRpcSuccessResponse) method.response(request);
assertThat((Collection<SignerMetricResult>) response.getResult()).containsExactlyInAnyOrderElementsOf(signerMetricResultList);
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.SignerMetricResult in project besu by hyperledger.
the class QbftGetSignerMetricsTest method generateBlock.
private SignerMetricResult generateBlock(final long number) {
final Address proposerAddressBlock = VALIDATORS[(int) (number % VALIDATORS.length)];
final BlockHeader header = new BlockHeaderTestFixture().number(number).buildHeader();
when(blockchainQueries.getBlockHeaderByNumber(number)).thenReturn(Optional.of(header));
when(blockInterface.getProposerOfBlock(header)).thenReturn(proposerAddressBlock);
when(validatorProvider.getValidatorsAfterBlock(header)).thenReturn(Arrays.asList(VALIDATORS));
final SignerMetricResult signerMetricResult = new SignerMetricResult(proposerAddressBlock);
signerMetricResult.incrementeNbBlock();
signerMetricResult.setLastProposedBlockNumber(number);
return signerMetricResult;
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.SignerMetricResult in project besu by hyperledger.
the class CliqueGetSignerMetricsTest method getSignerMetricsWithEarliest.
@Test
@SuppressWarnings("unchecked")
public void getSignerMetricsWithEarliest() {
final long startBlock = 0L;
final long endBlock = 3L;
final List<SignerMetricResult> signerMetricResultList = new ArrayList<>();
when(blockchainQueries.headBlockNumber()).thenReturn(endBlock);
LongStream.range(startBlock, endBlock).forEach(value -> signerMetricResultList.add(generateBlock(value)));
final JsonRpcRequestContext request = requestWithParams("earliest", String.valueOf(endBlock));
final JsonRpcSuccessResponse response = (JsonRpcSuccessResponse) method.response(request);
assertThat((Collection<SignerMetricResult>) response.getResult()).containsExactlyInAnyOrderElementsOf(signerMetricResultList);
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.SignerMetricResult in project besu by hyperledger.
the class CliqueGetSignerMetricsTest method getSignerMetricsWithLatest.
@Test
@SuppressWarnings("unchecked")
public void getSignerMetricsWithLatest() {
final long startBlock = 1L;
final long endBlock = 3L;
final List<SignerMetricResult> signerMetricResultList = new ArrayList<>();
when(blockchainQueries.headBlockNumber()).thenReturn(endBlock);
LongStream.range(startBlock, endBlock).forEach(value -> signerMetricResultList.add(generateBlock(value)));
// missing validator
signerMetricResultList.add(new SignerMetricResult(VALIDATORS[0]));
final JsonRpcRequestContext request = requestWithParams(String.valueOf(startBlock), "latest");
final JsonRpcSuccessResponse response = (JsonRpcSuccessResponse) method.response(request);
assertThat((Collection<SignerMetricResult>) response.getResult()).containsExactlyInAnyOrderElementsOf(signerMetricResultList);
}
Aggregations