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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations