Search in sources :

Example 16 with LogTopic

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

the class LogsQueryTest method univariateAddressMismatchReturnsFalse.

@Test
public void univariateAddressMismatchReturnsFalse() {
    final Address address1 = Address.fromHexString("0x1111111111111111111111111111111111111111");
    final LogsQuery query = new LogsQuery.Builder().address(address1).build();
    final Address address2 = Address.fromHexString("0x2222222222222222222222222222222222222222");
    final List<LogTopic> topics = new ArrayList<>();
    final Log log = new Log(address2, data, topics);
    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) LogTopic(org.hyperledger.besu.evm.log.LogTopic) Test(org.junit.Test)

Example 17 with LogTopic

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

the class LogsQueryTest method multivariateTopicMatchMultivariateQueryReturnTrue.

@Test
public void multivariateTopicMatchMultivariateQueryReturnTrue() {
    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 LogTopic topic4 = LogTopic.fromHexString("0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd");
    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(topic3);
    queryTopics2.add(topic4);
    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.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) 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 18 with LogTopic

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

the class LogsQueryTest method multivariateSurplusTopicMatchMultivariateQueryReturnTrue_01.

/**
 * [A, B] "A in first position AND B in second position (and anything after)"
 */
@Test
public void multivariateSurplusTopicMatchMultivariateQueryReturnTrue_01() {
    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(topic2);
    final List<LogTopic> queryTopics = new ArrayList<>();
    queryTopics.add(topic1);
    queryTopics.add(topic3);
    final List<List<LogTopic>> queryParameter = new ArrayList<>();
    queryParameter.add(queryTopics);
    final LogsQuery query = new LogsQuery.Builder().address(address).topics(queryParameter).build();
    final Log log = new Log(address, data, logTopics);
    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) 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 19 with LogTopic

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

the class LogsQueryTest method multivariateAddressMismatchReturnsFalse.

@Test
public void multivariateAddressMismatchReturnsFalse() {
    final Address address1 = Address.fromHexString("0x1111111111111111111111111111111111111111");
    final Address address2 = Address.fromHexString("0x2222222222222222222222222222222222222222");
    final LogsQuery query = new LogsQuery.Builder().addresses(address1, address2).build();
    final Address address3 = Address.fromHexString("0x3333333333333333333333333333333333333333");
    final List<LogTopic> topics = new ArrayList<>();
    final Log log = new Log(address3, data, topics);
    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) LogTopic(org.hyperledger.besu.evm.log.LogTopic) Test(org.junit.Test)

Example 20 with LogTopic

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

the class LogsQueryTest method multivariateSurplusTopicMatchMultivariateNullQueryReturnTrue.

/**
 * [null, B] "anything in first position AND B in second position (and anything after)"
 */
@Test
public void multivariateSurplusTopicMatchMultivariateNullQueryReturnTrue() {
    final Address address1 = Address.fromHexString("0x1111111111111111111111111111111111111111");
    final LogTopic topic1 = LogTopic.fromHexString("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    final LogTopic topic2 = LogTopic.fromHexString("0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
    final LogTopic topic3 = LogTopic.fromHexString("0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc");
    final LogTopic topic4 = null;
    final List<LogTopic> logTopics = new ArrayList<>();
    logTopics.add(topic1);
    logTopics.add(topic2);
    logTopics.add(topic3);
    final List<LogTopic> queryTopics = new ArrayList<>();
    queryTopics.add(topic4);
    queryTopics.add(topic2);
    final List<List<LogTopic>> queryParameter = new ArrayList<>();
    queryParameter.add(queryTopics);
    final LogsQuery query = new LogsQuery.Builder().address(address1).topics(queryParameter).build();
    final Log log = new Log(address1, data, logTopics);
    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) 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)

Aggregations

LogTopic (org.hyperledger.besu.evm.log.LogTopic)28 Log (org.hyperledger.besu.evm.log.Log)22 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)20 Address (org.hyperledger.besu.datatypes.Address)19 LogsQuery (org.hyperledger.besu.ethereum.api.query.LogsQuery)19 List (java.util.List)15 Collections.singletonList (java.util.Collections.singletonList)13 Collections.emptyList (java.util.Collections.emptyList)12 LogWithMetadata (org.hyperledger.besu.ethereum.core.LogWithMetadata)5 Hash (org.hyperledger.besu.datatypes.Hash)4 BlockHeader (org.hyperledger.besu.ethereum.core.BlockHeader)3 BlockHeaderTestFixture (org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture)3 PrivateTransactionMetadata (org.hyperledger.besu.ethereum.privacy.storage.PrivateTransactionMetadata)3 Test (org.junit.jupiter.api.Test)3 ImmutableList (com.google.common.collect.ImmutableList)2 Bytes (org.apache.tuweni.bytes.Bytes)2 Bytes32 (org.apache.tuweni.bytes.Bytes32)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 HederaStackedWorldStateUpdater (com.hedera.services.store.contracts.HederaStackedWorldStateUpdater)1