use of org.web3j.protocol.core.methods.response.EthBlockNumber in project besu by hyperledger.
the class ContainerTestBase method assertBlockHeight.
private void assertBlockHeight(final Web3j web3j, final int blockHeight) throws IOException {
final EthBlockNumber blockNumberResult = web3j.ethBlockNumber().send();
assertThat(blockNumberResult.getBlockNumber().intValueExact()).isGreaterThanOrEqualTo(blockHeight);
}
use of org.web3j.protocol.core.methods.response.EthBlockNumber in project web3j by web3j.
the class ResponseTest method testEthBlockNumber.
@Test
public void testEthBlockNumber() {
buildResponse("{\n" + " \"id\":83,\n" + " \"jsonrpc\": \"2.0\",\n" + " \"result\": \"0x4b7\"\n" + "}");
EthBlockNumber ethBlockNumber = deserialiseResponse(EthBlockNumber.class);
assertEquals(ethBlockNumber.getBlockNumber(), (BigInteger.valueOf(1207L)));
}
use of org.web3j.protocol.core.methods.response.EthBlockNumber in project web3j by web3j.
the class HttpServiceTest method httpWebException.
@Test
public void httpWebException() throws IOException {
String content = "400 error";
Response response = new Response.Builder().code(400).message("").body(ResponseBody.create(content, null)).request(new okhttp3.Request.Builder().url(HttpService.DEFAULT_URL).build()).protocol(Protocol.HTTP_1_1).build();
OkHttpClient httpClient = Mockito.mock(OkHttpClient.class);
Mockito.when(httpClient.newCall(Mockito.any())).thenAnswer(invocation -> {
Call call = Mockito.mock(Call.class);
Mockito.when(call.execute()).thenReturn(response);
return call;
});
HttpService mockedHttpService = new HttpService(httpClient);
Request<String, EthBlockNumber> request = new Request<>("eth_blockNumber1", Collections.emptyList(), mockedHttpService, EthBlockNumber.class);
try {
mockedHttpService.send(request, EthBlockNumber.class);
} catch (ClientConnectionException e) {
assertEquals(e.getMessage(), "Invalid response received: " + response.code() + "; " + content);
return;
}
fail("No exception");
}
use of org.web3j.protocol.core.methods.response.EthBlockNumber in project web3j by web3j.
the class CoreIT method testEthBlockNumber.
@Test
public void testEthBlockNumber(Web3j web3j) throws Exception {
EthBlockNumber ethBlockNumber = web3j.ethBlockNumber().send();
assertEquals(1, ethBlockNumber.getBlockNumber().signum());
}
use of org.web3j.protocol.core.methods.response.EthBlockNumber in project quorum-acceptance-tests by ConsenSys.
the class Permissions method saveCurrentBlockNumber.
@Step("Save current blocknumber from <node>")
public void saveCurrentBlockNumber(QuorumNetworkProperty.Node node) {
EthBlockNumber blkNumber = utilService.getCurrentBlockNumberFrom(node).blockingFirst();
DataStoreFactory.getScenarioDataStore().put(node.getName() + "blockNumber", blkNumber);
logger.debug("current block number from {} is {}", node.getName(), blkNumber.getBlockNumber().intValue());
assertThat(blkNumber.getBlockNumber().intValue()).isNotEqualTo(0);
}
Aggregations