Java Code Examples for org.web3j.protocol.core.methods.response.EthBlock#setResult()

The following examples show how to use org.web3j.protocol.core.methods.response.EthBlock#setResult() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnsResolverTest.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
private void configureLatestBlock(long timestamp) throws IOException {
    EthBlock.Block block = new EthBlock.Block();
    block.setTimestamp(Numeric.encodeQuantity(BigInteger.valueOf(timestamp)));
    EthBlock ethBlock = new EthBlock();
    ethBlock.setResult(block);

    when(web3jService.send(any(Request.class), eq(EthBlock.class)))
            .thenReturn(ethBlock);
}
 
Example 2
Source File: JsonRpc2_0RxTest.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
private EthBlock createBlock(int number) {
    EthBlock ethBlock = new EthBlock();
    EthBlock.Block block = new EthBlock.Block();
    block.setNumber(Numeric.encodeQuantity(BigInteger.valueOf(number)));

    ethBlock.setResult(block);
    return ethBlock;
}
 
Example 3
Source File: EnsResolverTest.java    From web3j with Apache License 2.0 5 votes vote down vote up
private void configureLatestBlock(long timestamp) throws IOException {
    EthBlock.Block block = new EthBlock.Block();
    block.setTimestamp(Numeric.encodeQuantity(BigInteger.valueOf(timestamp)));
    EthBlock ethBlock = new EthBlock();
    ethBlock.setResult(block);

    when(web3jService.send(any(Request.class), eq(EthBlock.class))).thenReturn(ethBlock);
}
 
Example 4
Source File: JsonRpc2_0RxTest.java    From web3j with Apache License 2.0 5 votes vote down vote up
private EthBlock createBlock(int number) {
    EthBlock ethBlock = new EthBlock();
    EthBlock.Block block = new EthBlock.Block();
    block.setNumber(Numeric.encodeQuantity(BigInteger.valueOf(number)));

    ethBlock.setResult(block);
    return ethBlock;
}
 
Example 5
Source File: JsonRpc2_0RxTest.java    From web3j with Apache License 2.0 5 votes vote down vote up
private EthBlock createBlockWithTransactions(int blockNumber, List<Transaction> transactions) {
    EthBlock ethBlock = new EthBlock();
    EthBlock.Block block = new EthBlock.Block();
    block.setNumber(Numeric.encodeQuantity(BigInteger.valueOf(blockNumber)));

    List<EthBlock.TransactionResult> transactionResults =
            transactions.stream()
                    .map(it -> (EthBlock.TransactionResult<Transaction>) () -> it)
                    .collect(Collectors.toList());
    block.setTransactions(transactionResults);

    ethBlock.setResult(block);
    return ethBlock;
}