Search in sources :

Example 1 with LogResult

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);
}
Also used : EventEmitter(org.hyperledger.besu.tests.web3j.generated.EventEmitter) LogResult(org.web3j.protocol.core.methods.response.EthLog.LogResult) LogFilterJsonParameter(org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter) Test(org.junit.Test)

Example 2 with LogResult

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);
}
Also used : EventEmitter(org.hyperledger.besu.tests.web3j.generated.EventEmitter) LogResult(org.web3j.protocol.core.methods.response.EthLog.LogResult) LogFilterJsonParameter(org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter) Test(org.junit.Test)

Example 3 with LogResult

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);
}
Also used : EthLog(org.web3j.protocol.core.methods.response.EthLog) Log(org.web3j.protocol.core.methods.response.Log) ArrayList(java.util.ArrayList) EthLog(org.web3j.protocol.core.methods.response.EthLog) LogResult(org.web3j.protocol.core.methods.response.EthLog.LogResult)

Example 4 with LogResult

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);
}
Also used : EventEmitter(org.hyperledger.besu.tests.web3j.generated.EventEmitter) LogResult(org.web3j.protocol.core.methods.response.EthLog.LogResult) PrivateTransactionReceipt(org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt) LogFilterJsonParameter(org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter) Test(org.junit.Test)

Example 5 with LogResult

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);
}
Also used : ArrayList(java.util.ArrayList) EthLog(org.web3j.protocol.core.methods.response.EthLog) LogResult(org.web3j.protocol.core.methods.response.EthLog.LogResult)

Aggregations

LogResult (org.web3j.protocol.core.methods.response.EthLog.LogResult)6 LogFilterJsonParameter (org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter)3 EventEmitter (org.hyperledger.besu.tests.web3j.generated.EventEmitter)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 EthLog (org.web3j.protocol.core.methods.response.EthLog)2 Log (org.exoplatform.services.log.Log)1 ExoWalletStatistic (org.exoplatform.wallet.statistic.ExoWalletStatistic)1 PrivateTransactionReceipt (org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt)1 DefaultBlockParameterNumber (org.web3j.protocol.core.DefaultBlockParameterNumber)1 org.web3j.protocol.core.methods.response (org.web3j.protocol.core.methods.response)1 Log (org.web3j.protocol.core.methods.response.Log)1