Java Code Examples for org.web3j.protocol.core.methods.response.EthCall#setResult()
The following examples show how to use
org.web3j.protocol.core.methods.response.EthCall#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 |
@Test public void testResolve() throws Exception { configureSyncing(false); configureLatestBlock(System.currentTimeMillis() / 1000); // block timestamp is in seconds NetVersion netVersion = new NetVersion(); netVersion.setResult(Byte.toString(ChainId.MAINNET)); String resolverAddress = "0x0000000000000000000000004c641fb9bad9b60ef180c31f56051ce826d21a9a"; String contractAddress = "0x00000000000000000000000019e03255f667bdfd50a32722df860b1eeaf4d635"; EthCall resolverAddressResponse = new EthCall(); resolverAddressResponse.setResult(resolverAddress); EthCall contractAddressResponse = new EthCall(); contractAddressResponse.setResult(contractAddress); when(web3jService.send(any(Request.class), eq(NetVersion.class))) .thenReturn(netVersion); when(web3jService.send(any(Request.class), eq(EthCall.class))) .thenReturn(resolverAddressResponse); when(web3jService.send(any(Request.class), eq(EthCall.class))) .thenReturn(contractAddressResponse); assertThat(ensResolver.resolve("web3j.eth"), is("0x19e03255f667bdfd50a32722df860b1eeaf4d635")); }
Example 2
Source File: EnsResolverTest.java From etherscan-explorer with GNU General Public License v3.0 | 5 votes |
@Test public void testReverseResolve() throws Exception { configureSyncing(false); configureLatestBlock(System.currentTimeMillis() / 1000); // block timestamp is in seconds NetVersion netVersion = new NetVersion(); netVersion.setResult(Byte.toString(ChainId.MAINNET)); String resolverAddress = "0x0000000000000000000000004c641fb9bad9b60ef180c31f56051ce826d21a9a"; String contractName = "0x0000000000000000000000000000000000000000000000000000000000000020" + TypeEncoder.encode(new Utf8String("web3j.eth")); System.err.println(contractName); EthCall resolverAddressResponse = new EthCall(); resolverAddressResponse.setResult(resolverAddress); EthCall contractNameResponse = new EthCall(); contractNameResponse.setResult(contractName); when(web3jService.send(any(Request.class), eq(NetVersion.class))) .thenReturn(netVersion); when(web3jService.send(any(Request.class), eq(EthCall.class))) .thenReturn(resolverAddressResponse); when(web3jService.send(any(Request.class), eq(EthCall.class))) .thenReturn(contractNameResponse); assertThat(ensResolver.reverseResolve("0x19e03255f667bdfd50a32722df860b1eeaf4d635"), is("web3j.eth")); }
Example 3
Source File: ContractTest.java From etherscan-explorer with GNU General Public License v3.0 | 5 votes |
@Test public void testCallSingleValue() throws Exception { // Example taken from FunctionReturnDecoderTest EthCall ethCall = new EthCall(); ethCall.setResult("0x0000000000000000000000000000000000000000000000000000000000000020" + "0000000000000000000000000000000000000000000000000000000000000000"); prepareCall(ethCall); assertThat(contract.callSingleValue().send(), equalTo(new Utf8String(""))); }
Example 4
Source File: ContractTest.java From etherscan-explorer with GNU General Public License v3.0 | 5 votes |
@Test public void testCallSingleValueEmpty() throws Exception { // Example taken from FunctionReturnDecoderTest EthCall ethCall = new EthCall(); ethCall.setResult("0x"); prepareCall(ethCall); assertNull(contract.callSingleValue().send()); }
Example 5
Source File: ContractTest.java From etherscan-explorer with GNU General Public License v3.0 | 5 votes |
@Test public void testCallMultipleValue() throws Exception { EthCall ethCall = new EthCall(); ethCall.setResult("0x0000000000000000000000000000000000000000000000000000000000000037" + "0000000000000000000000000000000000000000000000000000000000000007"); prepareCall(ethCall); assertThat(contract.callMultipleValue().send(), equalTo(Arrays.asList( new Uint256(BigInteger.valueOf(55)), new Uint256(BigInteger.valueOf(7))))); }
Example 6
Source File: ContractTest.java From etherscan-explorer with GNU General Public License v3.0 | 5 votes |
@Test public void testCallMultipleValueEmpty() throws Exception { EthCall ethCall = new EthCall(); ethCall.setResult("0x"); prepareCall(ethCall); assertThat(contract.callMultipleValue().send(), equalTo(emptyList())); }
Example 7
Source File: EnsResolverTest.java From web3j with Apache License 2.0 | 5 votes |
@Test public void testResolve() throws Exception { configureSyncing(false); configureLatestBlock(System.currentTimeMillis() / 1000); // block timestamp is in seconds NetVersion netVersion = new NetVersion(); netVersion.setResult(Long.toString(ChainIdLong.MAINNET)); String resolverAddress = "0x0000000000000000000000004c641fb9bad9b60ef180c31f56051ce826d21a9a"; String contractAddress = "0x00000000000000000000000019e03255f667bdfd50a32722df860b1eeaf4d635"; EthCall resolverAddressResponse = new EthCall(); resolverAddressResponse.setResult(resolverAddress); EthCall contractAddressResponse = new EthCall(); contractAddressResponse.setResult(contractAddress); when(web3jService.send(any(Request.class), eq(NetVersion.class))).thenReturn(netVersion); when(web3jService.send(any(Request.class), eq(EthCall.class))) .thenReturn(resolverAddressResponse); when(web3jService.send(any(Request.class), eq(EthCall.class))) .thenReturn(contractAddressResponse); assertEquals( ensResolver.resolve("web3j.eth"), ("0x19e03255f667bdfd50a32722df860b1eeaf4d635")); }
Example 8
Source File: EnsResolverTest.java From web3j with Apache License 2.0 | 5 votes |
@Test public void testReverseResolve() throws Exception { configureSyncing(false); configureLatestBlock(System.currentTimeMillis() / 1000); // block timestamp is in seconds NetVersion netVersion = new NetVersion(); netVersion.setResult(Long.toString(ChainIdLong.MAINNET)); String resolverAddress = "0x0000000000000000000000004c641fb9bad9b60ef180c31f56051ce826d21a9a"; String contractName = "0x0000000000000000000000000000000000000000000000000000000000000020" + TypeEncoder.encode(new Utf8String("web3j.eth")); System.err.println(contractName); EthCall resolverAddressResponse = new EthCall(); resolverAddressResponse.setResult(resolverAddress); EthCall contractNameResponse = new EthCall(); contractNameResponse.setResult(contractName); when(web3jService.send(any(Request.class), eq(NetVersion.class))).thenReturn(netVersion); when(web3jService.send(any(Request.class), eq(EthCall.class))) .thenReturn(resolverAddressResponse); when(web3jService.send(any(Request.class), eq(EthCall.class))) .thenReturn(contractNameResponse); assertEquals( ensResolver.reverseResolve("0x19e03255f667bdfd50a32722df860b1eeaf4d635"), ("web3j.eth")); }
Example 9
Source File: ContractTest.java From web3j with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void prepareCall(String result) throws IOException { EthCall ethCall = new EthCall(); ethCall.setResult(result); Request<?, EthCall> request = mock(Request.class); when(request.send()).thenReturn(ethCall); when(web3j.ethCall(any(Transaction.class), any(DefaultBlockParameter.class))) .thenReturn((Request) request); }