Skip to content

Commit

Permalink
add logs subscription detection fix (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
Termina1 authored Feb 22, 2024
1 parent 560eb6c commit 8306cea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ open class EthereumEgressSubscription(
open val logs = ConnectLogs(upstream, scheduler)
override fun getAvailableTopics(): List<String> {
val subs = if (upstream.getCapabilities().contains(Capability.WS_HEAD)) {
listOf(METHOD_NEW_HEADS, METHOD_LOGS)
// we can't use logs without eth_getLogs method available
if (upstream.getMethods().isAvailable("eth_getLogs")) {
listOf(METHOD_NEW_HEADS, METHOD_LOGS)
} else {
listOf(METHOD_NEW_HEADS)
}
} else {
listOf()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ class EthereumEgressSubscriptionSpec extends Specification {
def ethereumSubscribe3 = new EthereumEgressSubscription(TestingCommons.multistream(up3) as GenericMultistream, Schedulers.boundedElastic(), Stub(PendingTxesSource))
then:
ethereumSubscribe3.getAvailableTopics().toSet() == [EthereumEgressSubscription.METHOD_LOGS, EthereumEgressSubscription.METHOD_NEW_HEADS, EthereumEgressSubscription.METHOD_PENDING_TXES].toSet()
when:
def up4 = TestingCommons.upstream(TestingCommons.api(), "eth_getBlockByNumber")
up4.getConnectorMock().setLiveness(Flux.just(true))
up4.stop()
up4.start()
def ethereumSubscribe4 = new EthereumEgressSubscription(TestingCommons.multistream(up4) as GenericMultistream, Schedulers.boundedElastic(), null)
then:
ethereumSubscribe4.getAvailableTopics().toSet() == [EthereumEgressSubscription.METHOD_NEW_HEADS].toSet()

}
}

0 comments on commit 8306cea

Please sign in to comment.