Search in sources :

Example 1 with LogTopic

use of org.hyperledger.besu.evm.log.LogTopic in project hedera-services by hashgraph.

the class EncodingFacadeTest method logBuilderWithTopicsWithDifferentTypes.

@Test
void logBuilderWithTopicsWithDifferentTypes() {
    final var log = EncodingFacade.LogBuilder.logBuilder().forLogger(logger).forEventSignature(TRANSFER_EVENT).forIndexedArgument(senderAddress).forIndexedArgument(20L).forIndexedArgument(BigInteger.valueOf(20)).forIndexedArgument(Boolean.TRUE).forIndexedArgument(false).build();
    final List<LogTopic> topics = new ArrayList<>();
    topics.add(LogTopic.wrap(Bytes.fromHexString("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")));
    topics.add(LogTopic.wrap(Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000008")));
    topics.add(LogTopic.wrap(Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000014")));
    topics.add(LogTopic.wrap(Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000014")));
    topics.add(LogTopic.wrap(Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")));
    topics.add(LogTopic.wrap(Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")));
    assertEquals(new Log(logger, Bytes.EMPTY, topics), log);
}
Also used : Log(org.hyperledger.besu.evm.log.Log) ArrayList(java.util.ArrayList) LogTopic(org.hyperledger.besu.evm.log.LogTopic) Test(org.junit.jupiter.api.Test)

Example 2 with LogTopic

use of org.hyperledger.besu.evm.log.LogTopic in project hedera-services by hashgraph.

the class EncodingFacadeTest method logBuilderWithTopics.

@Test
void logBuilderWithTopics() {
    final var log = EncodingFacade.LogBuilder.logBuilder().forLogger(logger).forEventSignature(TRANSFER_EVENT).forIndexedArgument(senderAddress).forIndexedArgument(recipientAddress).build();
    final List<LogTopic> topics = new ArrayList<>();
    topics.add(LogTopic.wrap(Bytes.fromHexString("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")));
    topics.add(LogTopic.wrap(Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000008")));
    topics.add(LogTopic.wrap(Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000006")));
    assertEquals(new Log(logger, Bytes.EMPTY, topics), log);
}
Also used : Log(org.hyperledger.besu.evm.log.Log) ArrayList(java.util.ArrayList) LogTopic(org.hyperledger.besu.evm.log.LogTopic) Test(org.junit.jupiter.api.Test)

Example 3 with LogTopic

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

the class LogsQueryTest method univariateTopicQueryLogWithoutTopicReturnFalse.

@Test
public void univariateTopicQueryLogWithoutTopicReturnFalse() {
    final Address address = Address.fromHexString("0x1111111111111111111111111111111111111111");
    final LogTopic topic = LogTopic.fromHexString("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    final List<LogTopic> topics = new ArrayList<>();
    topics.add(topic);
    final List<List<LogTopic>> topicsQuery = new ArrayList<>();
    topicsQuery.add(topics);
    final LogsQuery query = new LogsQuery.Builder().address(address).topics(topicsQuery).build();
    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 4 with LogTopic

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

the class LogsQueryTest method multivariateTopicQueryMismatchReturnFalse.

@Test
public void multivariateTopicQueryMismatchReturnFalse() {
    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(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.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 5 with LogTopic

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

the class LogsQueryTest method univariateTopicQueryMatchReturnTrue.

@Test
public void univariateTopicQueryMatchReturnTrue() {
    final Address address = Address.fromHexString("0x1111111111111111111111111111111111111111");
    final LogTopic topic = LogTopic.fromHexString("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    final List<LogTopic> topics = new ArrayList<>();
    topics.add(topic);
    final List<List<LogTopic>> topicsQuery = new ArrayList<>();
    topicsQuery.add(topics);
    final LogsQuery query = new LogsQuery.Builder().address(address).topics(topicsQuery).build();
    final Log log = new Log(address, data, Lists.newArrayList(topic));
    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