use of org.web3j.protocol.core.methods.response.EthLog.LogResult in project besu by hyperledger.
the class PrivGetLogsAcceptanceTest method getLogsUsingBlockRangeFilter.
@Test
public void getLogsUsingBlockRangeFilter() {
final String privacyGroupId = createPrivacyGroup();
final EventEmitter eventEmitterContract = deployEventEmitterContract(privacyGroupId);
/*
Updating the contract value 2 times
*/
updateContractValue(privacyGroupId, eventEmitterContract, 1);
updateContractValue(privacyGroupId, eventEmitterContract, 2);
final LogFilterJsonParameter filter = blockRangeLogFilter("earliest", "latest", eventEmitterContract.getContractAddress());
final List<LogResult> logs = node.execute(privacyTransactions.privGetLogs(privacyGroupId, filter));
/*
We expect one log entry per tx changing the contract value
*/
assertThat(logs).hasSize(2);
}
use of org.web3j.protocol.core.methods.response.EthLog.LogResult in project besu by hyperledger.
the class PrivateLogFilterAcceptanceTest method getFilterLogs.
@Test
public void getFilterLogs() {
final String privacyGroupId = createPrivacyGroup();
final EventEmitter eventEmitterContract = deployEventEmitterContract(privacyGroupId);
final LogFilterJsonParameter filter = blockRangeLogFilter("earliest", "latest", eventEmitterContract.getContractAddress());
final String filterId = node.execute(privacyTransactions.newFilter(privacyGroupId, filter));
updateContractValue(privacyGroupId, eventEmitterContract, 1);
final List<LogResult> logs = node.execute(privacyTransactions.getFilterLogs(privacyGroupId, filterId));
assertThat(logs).hasSize(1);
}
use of org.web3j.protocol.core.methods.response.EthLog.LogResult in project web3j by web3j.
the class LogsFilter method process.
@Override
protected void process(List<LogResult> logResults) {
List<Log> logs = new ArrayList<>(logResults.size());
for (EthLog.LogResult logResult : logResults) {
if (!(logResult instanceof EthLog.LogObject)) {
throw new FilterException("Unexpected result type: " + logResult.get() + " required LogObject");
}
logs.add(((EthLog.LogObject) logResult).get());
}
callback.onEvent(logs);
}
use of org.web3j.protocol.core.methods.response.EthLog.LogResult in project besu by hyperledger.
the class PrivGetLogsAcceptanceTest method getLogsUsingBlockHashFilter.
@Test
public void getLogsUsingBlockHashFilter() {
final String privacyGroupId = createPrivacyGroup();
final EventEmitter eventEmitterContract = deployEventEmitterContract(privacyGroupId);
/*
Updating the contract value 1 times
*/
final PrivateTransactionReceipt updateValueReceipt = updateContractValue(privacyGroupId, eventEmitterContract, 1);
final String blockHash = updateValueReceipt.getBlockHash();
final LogFilterJsonParameter filter = blockHashLogFilter(blockHash, eventEmitterContract.getContractAddress());
final List<LogResult> logs = node.execute(privacyTransactions.privGetLogs(privacyGroupId, filter));
assertThat(logs).hasSize(1);
}
use of org.web3j.protocol.core.methods.response.EthLog.LogResult in project web3j by web3j.
the class BlocksFilter method process.
@Override
protected void process(List<LogResult> logResults) {
List<String> blockHashes = new ArrayList<>(logResults.size());
for (EthLog.LogResult logResult : logResults) {
if (!(logResult instanceof EthLog.Hash)) {
throw new FilterException("Unexpected result type: " + logResult.get() + ", required Hash");
}
blockHashes.add(((EthLog.Hash) logResult).get());
}
callback.onEvent(blockHashes);
}
Aggregations