eth_subscribe multiple topics with OR logic (#682)
* eth_subscribe multiple topics with OR logic * test Filter by topics with OR logic
This commit is contained in:
@@ -103,7 +103,7 @@ class EthereumEgressSubscriptionSpec extends Specification {
|
||||
then:
|
||||
act.address == []
|
||||
act.topics == [
|
||||
Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
|
||||
[Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")]
|
||||
]
|
||||
|
||||
when:
|
||||
@@ -113,7 +113,7 @@ class EthereumEgressSubscriptionSpec extends Specification {
|
||||
then:
|
||||
act.address == []
|
||||
act.topics == [
|
||||
Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
|
||||
[Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")]
|
||||
]
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class EthereumEgressSubscriptionSpec extends Specification {
|
||||
def act = ethereumSubscribe.readLogsRequest([
|
||||
topics: [
|
||||
"0x401d083b33d092293333a83829bd824b016326a0",
|
||||
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
|
||||
234234
|
||||
]
|
||||
])
|
||||
|
||||
@@ -146,8 +146,8 @@ class EthereumEgressSubscriptionSpec extends Specification {
|
||||
then:
|
||||
act.address == []
|
||||
act.topics == [
|
||||
Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
|
||||
Hex32.from("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925")
|
||||
[Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")],
|
||||
[Hex32.from("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925")]
|
||||
]
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ class EthereumEgressSubscriptionSpec extends Specification {
|
||||
Address.from("0x298d492e8c1d909d3f63bc4a36c66c64acb3d695")
|
||||
]
|
||||
act.topics == [
|
||||
Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
|
||||
Hex32.from("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925")
|
||||
[Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")],
|
||||
[Hex32.from("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925")]
|
||||
]
|
||||
}
|
||||
|
||||
@@ -191,9 +191,9 @@ class EthereumEgressSubscriptionSpec extends Specification {
|
||||
Address.from("0x298d492e8c1d909d3f63bc4a36c66c64acb3d695")
|
||||
]
|
||||
act.topics == [
|
||||
Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
|
||||
[Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")],
|
||||
null,
|
||||
Hex32.from("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925")
|
||||
[Hex32.from("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925")]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ class ConnectLogsSpec extends Specification {
|
||||
def input = Flux.fromIterable([
|
||||
log1, log2, log3, log4
|
||||
])
|
||||
def act = input.transform(connectLogs.filtered([], [Hex32.from("0x952ba7f163c4a11628f55a4df523b3efddf252ad1be2c89b69c2b068fc378daa")]))
|
||||
def act = input.transform(connectLogs.filtered([], [[Hex32.from("0x952ba7f163c4a11628f55a4df523b3efddf252ad1be2c89b69c2b068fc378daa")]]))
|
||||
.collectList().block()
|
||||
|
||||
then:
|
||||
@@ -178,7 +178,7 @@ class ConnectLogsSpec extends Specification {
|
||||
def input = Flux.fromIterable([
|
||||
log1, log2, log3, log4
|
||||
])
|
||||
def act = input.transform(connectLogs.filtered([Address.from("0x63bc4a36c66c64acb3d695298d492e8c1d909d3f")], [Hex32.from("0x952ba7f163c4a11628f55a4df523b3efddf252ad1be2c89b69c2b068fc378daa")]))
|
||||
def act = input.transform(connectLogs.filtered([Address.from("0x63bc4a36c66c64acb3d695298d492e8c1d909d3f")], [[Hex32.from("0x952ba7f163c4a11628f55a4df523b3efddf252ad1be2c89b69c2b068fc378daa")]]))
|
||||
.collectList().block()
|
||||
|
||||
then:
|
||||
@@ -197,8 +197,8 @@ class ConnectLogsSpec extends Specification {
|
||||
def act = input.transform(connectLogs.filtered(
|
||||
[Address.from("0x63bc4a36c66c64acb3d695298d492e8c1d909d3f")],
|
||||
[
|
||||
Hex32.from("0x952ba7f163c4a11628f55a4df523b3efddf252ad1be2c89b69c2b068fc378daa"),
|
||||
Hex32.from("0x00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5640"),
|
||||
[Hex32.from("0x952ba7f163c4a11628f55a4df523b3efddf252ad1be2c89b69c2b068fc378daa")], // позиция 0
|
||||
[Hex32.from("0x00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5640")] // позиция 1
|
||||
]
|
||||
))
|
||||
.collectList().block()
|
||||
@@ -220,9 +220,9 @@ class ConnectLogsSpec extends Specification {
|
||||
def act = input.transform(connectLogs.filtered(
|
||||
[Address.from("0x63bc4a36c66c64acb3d695298d492e8c1d909d3f")],
|
||||
[
|
||||
Hex32.from("0x952ba7f163c4a11628f55a4df523b3efddf252ad1be2c89b69c2b068fc378daa"),
|
||||
[Hex32.from("0x952ba7f163c4a11628f55a4df523b3efddf252ad1be2c89b69c2b068fc378daa")],
|
||||
null,
|
||||
Hex32.from("0x00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5641"),
|
||||
[Hex32.from("0x00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5641")],
|
||||
]
|
||||
))
|
||||
.collectList().block()
|
||||
@@ -231,4 +231,34 @@ class ConnectLogsSpec extends Specification {
|
||||
act.size() == 1
|
||||
act[0] == log6
|
||||
}
|
||||
|
||||
def "Filter by topics with OR logic"() {
|
||||
setup:
|
||||
def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream(), Schedulers.boundedElastic())
|
||||
def topicA = Hex32.from("0x952ba7f163c4a11628f55a4df523b3efddf252ad1be2c89b69c2b068fc378daa")
|
||||
def topicB = Hex32.from("0x00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5640")
|
||||
|
||||
when:
|
||||
def input = Flux.fromIterable([
|
||||
log3, // has topicA
|
||||
log5, // has topicA + topicB
|
||||
log6, // has topicA + topicB + other
|
||||
log1, // has only different topic
|
||||
log4 // has only topicA
|
||||
])
|
||||
|
||||
def act = input.transform(connectLogs.filtered(
|
||||
[],
|
||||
[
|
||||
[topicA, topicB], // first topic: topicA OR topicB
|
||||
null // second topic: anything
|
||||
]
|
||||
))
|
||||
.collectList().block()
|
||||
|
||||
then:
|
||||
act.size() == 2
|
||||
act.containsAll([ log5, log6])
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user