From 0826e647c47fe7b9e7a1646964b4296cf649a246 Mon Sep 17 00:00:00 2001 From: Maksim Fomenkov Date: Thu, 27 Oct 2022 11:37:12 +0300 Subject: [PATCH] eth_filter fix lint and tests --- .../io/emeraldpay/dshackle/upstream/Selector.kt | 1 - .../dshackle/upstream/calls/EthereumCallSelector.kt | 2 +- .../upstream/calls/EthereumCallSelectorSpec.groovy | 13 ++++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt index 483b20db..6c105505 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt @@ -413,6 +413,5 @@ class Selector { if (other !is SameNodeMatcher) return false return other.upstreamHash == upstreamHash } - } } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/EthereumCallSelector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/EthereumCallSelector.kt index 840314ad..79748acf 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/EthereumCallSelector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/EthereumCallSelector.kt @@ -69,7 +69,7 @@ class EthereumCallSelector( return Mono.empty() } val filterId = list[0].toString() - if(filterId.length < 4) { + if (filterId.length < 4) { return Mono.just(Selector.SameNodeMatcher(0.toByte())) } val hashHex = filterId.substring(filterId.length - 2) diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/EthereumCallSelectorSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/EthereumCallSelectorSpec.groovy index 10eb1280..8aded145 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/EthereumCallSelectorSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/EthereumCallSelectorSpec.groovy @@ -193,8 +193,19 @@ class EthereumCallSelectorSpec extends Specification { param | hash '["0xff09"]' | 9 '["0xff"]' | 255 - '[]' | 0 '[""]' | 0 '["0x0"]' | 0 } + + def "Get empty matcher for getFilterChanges method without params"() { + setup: + def callSelector = new EthereumCallSelector(Mock(Reader)) + def head = Mock(Head) + + when: + def act = callSelector.getMatcher("eth_getFilterChanges", "[]", head).block() + + then: + act == null + } }