support null topics and topic position in logs filter (#649)

This commit is contained in:
a10zn8
2025-04-04 17:09:08 +03:00
committed by GitHub
parent 6744e2241c
commit 9ca2c921b5
4 changed files with 55 additions and 20 deletions

View File

@@ -129,10 +129,7 @@ class EthereumEgressSubscriptionSpec extends Specification {
])
then:
act.address == []
act.topics == [
Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
]
thrown(IllegalArgumentException)
}
def "read multi topic logs request"() {
@@ -195,6 +192,7 @@ class EthereumEgressSubscriptionSpec extends Specification {
]
act.topics == [
Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
null,
Hex32.from("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925")
]
}

View File

@@ -104,6 +104,23 @@ class ConnectLogsSpec extends Specification {
"upstream"
)
def log6 = new LogMessage(
Address.from("0x63bc4a36c66c64acb3d695298d492e8c1d909d3f"),
BlockHash.empty(),
100L,
HexData.empty(),
1L,
[
Hex32.from("0x952ba7f163c4a11628f55a4df523b3efddf252ad1be2c89b69c2b068fc378daa"),
Hex32.from("0x00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5640"),
Hex32.from("0x00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5641")
],
TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"),
1L,
false,
"upstream"
)
def "Filter is empty"() {
setup:
def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream(), Schedulers.boundedElastic())
@@ -174,7 +191,7 @@ class ConnectLogsSpec extends Specification {
def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream(), Schedulers.boundedElastic())
when:
def input = Flux.fromIterable([
log1, log2, log3, log4, log5
log1, log2, log3, log4, log5, log6
])
def act = input.transform(connectLogs.filtered(
@@ -187,7 +204,31 @@ class ConnectLogsSpec extends Specification {
.collectList().block()
then:
act.size() == 1
act.size() == 2
act[0] == log5
act[1] == log6
}
def "Filter by address and second topics"() {
setup:
def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream(), Schedulers.boundedElastic())
when:
def input = Flux.fromIterable([
log1, log2, log3, log4, log5, log6
])
def act = input.transform(connectLogs.filtered(
[Address.from("0x63bc4a36c66c64acb3d695298d492e8c1d909d3f")],
[
Hex32.from("0x952ba7f163c4a11628f55a4df523b3efddf252ad1be2c89b69c2b068fc378daa"),
null,
Hex32.from("0x00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5641"),
]
))
.collectList().block()
then:
act.size() == 1
act[0] == log6
}
}