Search in sources :

Example 11 with Log

use of org.hyperledger.besu.evm.log.Log in project besu by hyperledger.

the class LogsQueryTest method multivariateTopicMatchRedundantMultivariateQueryReturnTrue.

@Test
public void multivariateTopicMatchRedundantMultivariateQueryReturnTrue() {
    final Address address = Address.fromHexString("0x1111111111111111111111111111111111111111");
    final LogTopic topic1 = LogTopic.fromHexString("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    final LogTopic topic2 = LogTopic.fromHexString("0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
    final LogTopic topic3 = LogTopic.fromHexString("0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc");
    final List<LogTopic> logTopics = new ArrayList<>();
    logTopics.add(topic1);
    logTopics.add(topic3);
    final List<LogTopic> queryTopics1 = new ArrayList<>();
    queryTopics1.add(topic1);
    queryTopics1.add(topic2);
    final List<LogTopic> queryTopics2 = new ArrayList<>();
    queryTopics2.add(topic1);
    queryTopics2.add(topic2);
    final List<List<LogTopic>> queryParameter = new ArrayList<>();
    queryParameter.add(queryTopics1);
    queryParameter.add(queryTopics2);
    final LogsQuery query = new LogsQuery.Builder().address(address).topics(queryParameter).build();
    final Log log = new Log(address, data, logTopics);
    assertThat(query.matches(log)).isFalse();
}
Also used : Address(org.hyperledger.besu.datatypes.Address) Log(org.hyperledger.besu.evm.log.Log) LogsQuery(org.hyperledger.besu.ethereum.api.query.LogsQuery) ArrayList(java.util.ArrayList) Collections.emptyList(java.util.Collections.emptyList) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) List(java.util.List) LogTopic(org.hyperledger.besu.evm.log.LogTopic) Test(org.junit.Test)

Example 12 with Log

use of org.hyperledger.besu.evm.log.Log in project besu by hyperledger.

the class LogsQueryTest method univariateTopicQueryMismatchReturnFalse.

@Test
public void univariateTopicQueryMismatchReturnFalse() {
    final Address address = Address.fromHexString("0x1111111111111111111111111111111111111111");
    final LogTopic topic = LogTopic.fromHexString("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    final List<LogTopic> topics = Lists.newArrayList(topic);
    final List<List<LogTopic>> topicsQuery = new ArrayList<>();
    topicsQuery.add(topics);
    final LogsQuery query = new LogsQuery.Builder().address(address).topics(topicsQuery).build();
    topics.add(LogTopic.fromHexString("0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"));
    final Log log = new Log(address, data, Lists.newArrayList());
    assertThat(query.matches(log)).isFalse();
}
Also used : Address(org.hyperledger.besu.datatypes.Address) Log(org.hyperledger.besu.evm.log.Log) LogsQuery(org.hyperledger.besu.ethereum.api.query.LogsQuery) ArrayList(java.util.ArrayList) Collections.emptyList(java.util.Collections.emptyList) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) List(java.util.List) LogTopic(org.hyperledger.besu.evm.log.LogTopic) Test(org.junit.Test)

Example 13 with Log

use of org.hyperledger.besu.evm.log.Log in project besu by hyperledger.

the class LogsQueryTest method univariateAddressMatchReturnsTrue.

@Test
public void univariateAddressMatchReturnsTrue() {
    final Address address = Address.fromHexString("0x1111111111111111111111111111111111111111");
    final LogsQuery query = new LogsQuery.Builder().address(address).build();
    final List<LogTopic> topics = new ArrayList<>();
    final Log log = new Log(address, data, topics);
    assertThat(query.couldMatch(LogsBloomFilter.builder().insertLog(log).build())).isTrue();
    assertThat(query.matches(log)).isTrue();
}
Also used : Address(org.hyperledger.besu.datatypes.Address) Log(org.hyperledger.besu.evm.log.Log) LogsQuery(org.hyperledger.besu.ethereum.api.query.LogsQuery) ArrayList(java.util.ArrayList) LogTopic(org.hyperledger.besu.evm.log.LogTopic) Test(org.junit.Test)

Example 14 with Log

use of org.hyperledger.besu.evm.log.Log in project besu by hyperledger.

the class GoQuorumPrivateTxBloomBlockchainQueriesTest method setupClass.

@BeforeClass
public static void setupClass() {
    final Address testAddress = Address.fromHexString("0x123456");
    final Bytes testMessage = Bytes.fromHexString("0x9876");
    final Log testLog = new Log(testAddress, testMessage, List.of());
    testLogsBloomFilter = LogsBloomFilter.builder().insertLog(testLog).build();
    logsQuery = new LogsQuery(List.of(testAddress), List.of());
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) Address(org.hyperledger.besu.datatypes.Address) Log(org.hyperledger.besu.evm.log.Log) BeforeClass(org.junit.BeforeClass)

Example 15 with Log

use of org.hyperledger.besu.evm.log.Log in project besu by hyperledger.

the class GoQuorumPrivateTransactionLogBloomCacherTest method setupClass.

@BeforeClass
public static void setupClass() {
    testAddress = Address.fromHexString("0x123456");
    testMessage = Bytes.fromHexString("0x9876");
    final Log testLog = new Log(testAddress, testMessage, List.of());
    testLogsBloomFilter = LogsBloomFilter.builder().insertLog(testLog).build();
    logsQuery = new LogsQuery(List.of(testAddress), List.of());
}
Also used : Log(org.hyperledger.besu.evm.log.Log) LogsQuery(org.hyperledger.besu.ethereum.api.query.LogsQuery) BeforeClass(org.junit.BeforeClass)

Aggregations

Log (org.hyperledger.besu.evm.log.Log)53 ArrayList (java.util.ArrayList)31 Test (org.junit.Test)30 Address (org.hyperledger.besu.datatypes.Address)24 LogTopic (org.hyperledger.besu.evm.log.LogTopic)22 LogsQuery (org.hyperledger.besu.ethereum.api.query.LogsQuery)18 Bytes (org.apache.tuweni.bytes.Bytes)17 List (java.util.List)13 Collections.emptyList (java.util.Collections.emptyList)12 Collections.singletonList (java.util.Collections.singletonList)12 BlockHeader (org.hyperledger.besu.ethereum.core.BlockHeader)7 BlockWithReceipts (org.hyperledger.besu.ethereum.core.BlockWithReceipts)6 PrecompiledContract (org.hyperledger.besu.evm.precompile.PrecompiledContract)6 Enclave (org.hyperledger.besu.enclave.Enclave)5 ReceiveResponse (org.hyperledger.besu.enclave.types.ReceiveResponse)5 LogResult (org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.LogResult)5 Block (org.hyperledger.besu.ethereum.core.Block)5 Transaction (org.hyperledger.besu.ethereum.core.Transaction)5 TransactionReceipt (org.hyperledger.besu.ethereum.core.TransactionReceipt)5 VersionedPrivateTransaction (org.hyperledger.besu.ethereum.privacy.VersionedPrivateTransaction)4