Search in sources :

Example 1 with EthBlockNumber

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);
}
Also used : EthBlockNumber(org.web3j.protocol.core.methods.response.EthBlockNumber)

Example 2 with EthBlockNumber

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)));
}
Also used : EthBlockNumber(org.web3j.protocol.core.methods.response.EthBlockNumber) Test(org.junit.jupiter.api.Test)

Example 3 with EthBlockNumber

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");
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) EthBlockNumber(org.web3j.protocol.core.methods.response.EthBlockNumber) ClientConnectionException(org.web3j.protocol.exceptions.ClientConnectionException) OkHttpClient(okhttp3.OkHttpClient) Request(org.web3j.protocol.core.Request) Test(org.junit.jupiter.api.Test)

Example 4 with EthBlockNumber

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());
}
Also used : EthBlockNumber(org.web3j.protocol.core.methods.response.EthBlockNumber) EVMTest(org.web3j.EVMTest) Test(org.junit.jupiter.api.Test)

Example 5 with EthBlockNumber

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);
}
Also used : EthBlockNumber(org.web3j.protocol.core.methods.response.EthBlockNumber) Step(com.thoughtworks.gauge.Step)

Aggregations

EthBlockNumber (org.web3j.protocol.core.methods.response.EthBlockNumber)8 Step (com.thoughtworks.gauge.Step)4 Test (org.junit.jupiter.api.Test)3 QuorumNetworkProperty (com.quorum.gauge.common.QuorumNetworkProperty)2 QuorumNode (com.quorum.gauge.common.QuorumNode)2 AbstractSpecImplementation (com.quorum.gauge.core.AbstractSpecImplementation)2 NetworkResources (com.quorum.gauge.services.InfrastructureService.NetworkResources)2 DataStoreFactory (com.thoughtworks.gauge.datastore.DataStoreFactory)2 Observable (io.reactivex.Observable)2 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Random (java.util.Random)2 TimeUnit (java.util.concurrent.TimeUnit)2 Collectors (java.util.stream.Collectors)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2