@Test public void testEthCall() throws Exception { EthCall ethCall = web3j.ethCall(config.buildTransaction(), DefaultBlockParameter.valueOf("latest")).send(); assertThat(DefaultBlockParameterName.LATEST.getValue(), is("latest")); assertThat(ethCall.getValue(), is("0x")); }
@Test public void testEthGetUncleCountByBlockNumber() throws Exception { EthGetUncleCountByBlockNumber ethGetUncleCountByBlockNumber = web3j.ethGetUncleCountByBlockNumber( DefaultBlockParameter.valueOf("latest")).send(); assertThat(ethGetUncleCountByBlockNumber.getUncleCount(), equalTo(config.validBlockUncleCount())); }
@Test public void testEthGetStorageAt() throws Exception { EthGetStorageAt ethGetStorageAt = web3j.ethGetStorageAt( config.validContractAddress(), BigInteger.valueOf(0), DefaultBlockParameter.valueOf("latest")).send(); assertThat(ethGetStorageAt.getData(), is(config.validContractAddressPositionZero())); }
@Test public void testEthGetLogsWithNumericBlockRange() throws Exception { web3j.ethGetLogs(new EthFilter( DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8")), DefaultBlockParameter.valueOf("latest"), "")) .send(); verifyResult( "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getLogs\"," + "\"params\":[{\"topics\":[],\"fromBlock\":\"0xe8\"," + "\"toBlock\":\"latest\",\"address\":[\"\"]}],\"id\":1}"); }
@Test public void testEthGetTransactionByBlockNumberAndIndex() throws Exception { BigInteger index = BigInteger.ONE; EthTransaction ethTransaction = web3j.ethGetTransactionByBlockNumberAndIndex( DefaultBlockParameter.valueOf(config.validBlock()), index).send(); assertTrue(ethTransaction.getTransaction().isPresent()); Transaction transaction = ethTransaction.getTransaction().get(); assertThat(transaction.getBlockHash(), is(config.validBlockHash())); assertThat(transaction.getTransactionIndex(), equalTo(index)); }
@Test public void testEthGetBlockByNumberReturnTransactionObjects() throws Exception { EthBlock ethBlock = web3j.ethGetBlockByNumber( DefaultBlockParameter.valueOf(config.validBlock()), true).send(); EthBlock.Block block = ethBlock.getBlock(); assertNotNull(ethBlock.getBlock()); assertThat(block.getNumber(), equalTo(config.validBlock())); assertThat(block.getTransactions().size(), equalTo(config.validBlockTransactionCount().intValue())); }
@Test public void testEthGetBlockTransactionCountByNumber() throws Exception { EthGetBlockTransactionCountByNumber ethGetBlockTransactionCountByNumber = web3j.ethGetBlockTransactionCountByNumber( DefaultBlockParameter.valueOf(config.validBlock())).send(); assertThat(ethGetBlockTransactionCountByNumber.getTransactionCount(), equalTo(config.validBlockTransactionCount())); }
@Test public void testEthGetBlockByNumberReturnHashObjects() throws Exception { EthBlock ethBlock = web3j.ethGetBlockByNumber( DefaultBlockParameter.valueOf(config.validBlock()), false).send(); EthBlock.Block block = ethBlock.getBlock(); assertNotNull(ethBlock.getBlock()); assertThat(block.getNumber(), equalTo(config.validBlock())); assertThat(block.getTransactions().size(), equalTo(config.validBlockTransactionCount().intValue())); }
@Test public void testEthGetBalance() throws Exception { EthGetBalance ethGetBalance = web3j.ethGetBalance( config.validAccount(), DefaultBlockParameter.valueOf("latest")).send(); assertTrue(ethGetBalance.getBalance().signum() == 1); }
@Test public void testEthGetCode() throws Exception { EthGetCode ethGetCode = web3j.ethGetCode(config.validContractAddress(), DefaultBlockParameter.valueOf(config.validBlock())).send(); assertThat(ethGetCode.getCode(), is(config.validContractCode())); }
@Test public void testClicqueGetSigners() throws Exception { final DefaultBlockParameter blockParameter = DefaultBlockParameter.valueOf("latest"); web3j.clicqueGetSigners(blockParameter).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"clique_getSigners\"," + "\"params\":[\"latest\"],\"id\":1}"); }
@Test public void testEthGetTransactionCount() throws Exception { EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount( config.validAccount(), DefaultBlockParameter.valueOf("latest")).send(); assertTrue(ethGetTransactionCount.getTransactionCount().signum() == 1); }
@Test public void testEthGetBlockTransactionCountByNumber() throws Exception { web3j.ethGetBlockTransactionCountByNumber( DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockTransactionCountByNumber\"," + "\"params\":[\"0xe8\"],\"id\":1}"); }
@Test public void testEthGetCode() throws Exception { web3j.ethGetCode("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", DefaultBlockParameter.valueOf(Numeric.toBigInt("0x2"))).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\"," + "\"params\":[\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\",\"0x2\"],\"id\":1}"); }
@Test public void testEthCall() throws Exception { web3j.ethCall(Transaction.createEthCallTransaction( "0xa70e8dd61c5d32be8058bb8eb970870f07233155", "0xb60e8dd61c5d32be8058bb8eb970870f07233155", "0x0"), DefaultBlockParameter.valueOf("latest")).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_call\"," + "\"params\":[{\"from\":\"0xa70e8dd61c5d32be8058bb8eb970870f07233155\"," + "\"to\":\"0xb60e8dd61c5d32be8058bb8eb970870f07233155\",\"data\":\"0x0\"}," + "\"latest\"],\"id\":1}"); }
@Test public void testEthGetTransactionByBlockNumberAndIndex() throws Exception { web3j.ethGetTransactionByBlockNumberAndIndex( DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionByBlockNumberAndIndex\"," + "\"params\":[\"0x29c\",\"0x0\"],\"id\":1}"); }
@Test public void testEthGetUncleCountByBlockNumber() throws Exception { web3j.ethGetUncleCountByBlockNumber( DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleCountByBlockNumber\"," + "\"params\":[\"0xe8\"],\"id\":1}"); }
@Test public void testEthGetBlockByNumber() throws Exception { web3j.ethGetBlockByNumber( DefaultBlockParameter.valueOf(Numeric.toBigInt("0x1b4")), true).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\"," + "\"params\":[\"0x1b4\",true],\"id\":1}"); }
@Test public void testEthGetUncleByBlockNumberAndIndex() throws Exception { web3j.ethGetUncleByBlockNumberAndIndex( DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleByBlockNumberAndIndex\"," + "\"params\":[\"0x29c\",\"0x0\"],\"id\":1}"); }
@Test public void testEthGetUncleByBlockNumberAndIndex() throws Exception { EthBlock ethBlock = web3j.ethGetUncleByBlockNumberAndIndex( DefaultBlockParameter.valueOf(config.validUncleBlock()), BigInteger.ZERO) .send(); assertNotNull(ethBlock.getBlock()); }