Java Code Examples for org.web3j.protocol.core.methods.response.TransactionReceipt#setLogs()
The following examples show how to use
org.web3j.protocol.core.methods.response.TransactionReceipt#setLogs() .
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: ContractTest.java From client-sdk-java with Apache License 2.0 | 6 votes |
@Test @Ignore public void testProcessEvent() { TransactionReceipt transactionReceipt = new TransactionReceipt(); Log log = new Log(); log.setTopics(Arrays.asList( // encoded function "0xfceb437c298f40d64702ac26411b2316e79f3c28ffa60edfc891ad4fc8ab82ca", // indexed value "0000000000000000000000003d6cb163f7c72d20b0fcd6baae5889329d138a4a")); // non-indexed value log.setData("0000000000000000000000000000000000000000000000000000000000000001"); transactionReceipt.setLogs(Arrays.asList(log)); EventValues eventValues = contract.processEvent(transactionReceipt).get(0); assertThat(eventValues.getIndexedValues(), equalTo(singletonList( new Address("0x3d6cb163f7c72d20b0fcd6baae5889329d138a4a")))); assertThat(eventValues.getNonIndexedValues(), equalTo(singletonList(new Uint256(BigInteger.ONE)))); }
Example 2
Source File: ContractTest.java From etherscan-explorer with GNU General Public License v3.0 | 6 votes |
@Test public void testProcessEvent() { TransactionReceipt transactionReceipt = new TransactionReceipt(); Log log = new Log(); log.setTopics(Arrays.asList( // encoded function "0xfceb437c298f40d64702ac26411b2316e79f3c28ffa60edfc891ad4fc8ab82ca", // indexed value "0000000000000000000000003d6cb163f7c72d20b0fcd6baae5889329d138a4a")); // non-indexed value log.setData("0000000000000000000000000000000000000000000000000000000000000001"); transactionReceipt.setLogs(Arrays.asList(log)); EventValues eventValues = contract.processEvent(transactionReceipt).get(0); assertThat(eventValues.getIndexedValues(), equalTo(singletonList( new Address("0x3d6cb163f7c72d20b0fcd6baae5889329d138a4a")))); assertThat(eventValues.getNonIndexedValues(), equalTo(singletonList(new Uint256(BigInteger.ONE)))); }
Example 3
Source File: ContractTest.java From web3j with Apache License 2.0 | 6 votes |
@Test public void testProcessEvent() { TransactionReceipt transactionReceipt = new TransactionReceipt(); Log log = new Log(); log.setTopics( Arrays.asList( // encoded function "0xfceb437c298f40d64702ac26411b2316e79f3c28ffa60edfc891ad4fc8ab82ca", // indexed value "0000000000000000000000003d6cb163f7c72d20b0fcd6baae5889329d138a4a")); // non-indexed value log.setData("0000000000000000000000000000000000000000000000000000000000000001"); transactionReceipt.setLogs(singletonList(log)); EventValues eventValues = contract.processEvent(transactionReceipt).get(0); assertEquals( singletonList(new Address("0x3d6cb163f7c72d20b0fcd6baae5889329d138a4a")), eventValues.getIndexedValues()); assertEquals(singletonList(new Uint256(BigInteger.ONE)), eventValues.getNonIndexedValues()); }
Example 4
Source File: ContractTest.java From client-sdk-java with Apache License 2.0 | 5 votes |
@Test public void testExtractEventParametersWithLogGivenATransactionReceipt() { final java.util.function.Function<String, Event> eventFactory = name -> new Event(name, emptyList()); final BiFunction<Integer, Event, Log> logFactory = (logIndex, event) -> new Log(false, "" + logIndex, "0", "0x0", "0x0", "0", "0x" + logIndex, "", "", singletonList(EventEncoder.encode(event))); final Event testEvent1 = eventFactory.apply("TestEvent1"); final Event testEvent2 = eventFactory.apply("TestEvent2"); final List<Log> logs = Arrays.asList( logFactory.apply(0, testEvent1), logFactory.apply(1, testEvent2) ); final TransactionReceipt transactionReceipt = new TransactionReceipt(); transactionReceipt.setLogs(logs); final List<Contract.EventValuesWithLog> eventValuesWithLogs1 = contract.extractEventParametersWithLog(testEvent1, transactionReceipt); assertEquals(eventValuesWithLogs1.size(), 1); assertEquals(eventValuesWithLogs1.get(0).getLog(), logs.get(0)); final List<Contract.EventValuesWithLog> eventValuesWithLogs2 = contract.extractEventParametersWithLog(testEvent2, transactionReceipt); assertEquals(eventValuesWithLogs2.size(), 1); assertEquals(eventValuesWithLogs2.get(0).getLog(), logs.get(1)); }
Example 5
Source File: ContractTest.java From etherscan-explorer with GNU General Public License v3.0 | 5 votes |
@Test public void testExtractEventParametersWithLogGivenATransactionReceipt() { final java.util.function.Function<String, Event> eventFactory = name -> new Event(name, emptyList(), emptyList()); final BiFunction<Integer, Event, Log> logFactory = (logIndex, event) -> new Log(false, "" + logIndex, "0", "0x0", "0x0", "0", "0x" + logIndex, "", "", singletonList(EventEncoder.encode(event))); final Event testEvent1 = eventFactory.apply("TestEvent1"); final Event testEvent2 = eventFactory.apply("TestEvent2"); final List<Log> logs = Arrays.asList( logFactory.apply(0, testEvent1), logFactory.apply(1, testEvent2) ); final TransactionReceipt transactionReceipt = new TransactionReceipt(); transactionReceipt.setLogs(logs); final List<Contract.EventValuesWithLog> eventValuesWithLogs1 = contract.extractEventParametersWithLog(testEvent1, transactionReceipt); assertEquals(eventValuesWithLogs1.size(), 1); assertEquals(eventValuesWithLogs1.get(0).getLog(), logs.get(0)); final List<Contract.EventValuesWithLog> eventValuesWithLogs2 = contract.extractEventParametersWithLog(testEvent2, transactionReceipt); assertEquals(eventValuesWithLogs2.size(), 1); assertEquals(eventValuesWithLogs2.get(0).getLog(), logs.get(1)); }
Example 6
Source File: ContractTest.java From web3j with Apache License 2.0 | 5 votes |
@Test public void testProcessEventForLogWithoutTopics() { TransactionReceipt transactionReceipt = new TransactionReceipt(); final Log log = new Log(); log.setTopics(Collections.emptyList()); // non-indexed value log.setData("0000000000000000000000000000000000000000000000000000000000000001"); transactionReceipt.setLogs(singletonList(log)); final List<EventValues> eventValues = contract.processEvent(transactionReceipt); assertTrue(eventValues.isEmpty(), "No events expected"); }
Example 7
Source File: ContractTest.java From web3j with Apache License 2.0 | 4 votes |
@Test public void testExtractEventParametersWithLogGivenATransactionReceipt() { final java.util.function.Function<String, Event> eventFactory = name -> new Event(name, emptyList()); final BiFunction<Integer, Event, Log> logFactory = (logIndex, event) -> new Log( false, "" + logIndex, "0", "0x0", "0x0", "0", "0x" + logIndex, "", "", singletonList(EventEncoder.encode(event))); final Event testEvent1 = eventFactory.apply("TestEvent1"); final Event testEvent2 = eventFactory.apply("TestEvent2"); final List<Log> logs = Arrays.asList(logFactory.apply(0, testEvent1), logFactory.apply(1, testEvent2)); final TransactionReceipt transactionReceipt = new TransactionReceipt(); transactionReceipt.setLogs(logs); final List<Contract.EventValuesWithLog> eventValuesWithLogs1 = contract.extractEventParametersWithLog(testEvent1, transactionReceipt); assertEquals(eventValuesWithLogs1.size(), 1); assertEquals(eventValuesWithLogs1.get(0).getLog(), logs.get(0)); final List<Contract.EventValuesWithLog> eventValuesWithLogs2 = contract.extractEventParametersWithLog(testEvent2, transactionReceipt); assertEquals(eventValuesWithLogs2.size(), 1); assertEquals(eventValuesWithLogs2.get(0).getLog(), logs.get(1)); }