Apply method matcher for direct reader (#200)

This commit is contained in:
KirillPamPam
2023-04-11 14:37:17 +04:00
committed by GitHub
parent 9af4b95f8f
commit fc488e1aab
3 changed files with 11 additions and 4 deletions

View File

@@ -127,7 +127,7 @@ class Selector {
fun describeInternal(): String fun describeInternal(): String
} }
class MultiMatcher( data class MultiMatcher(
private val matchers: Collection<Matcher> private val matchers: Collection<Matcher>
) : Matcher { ) : Matcher {
override fun matches(up: Upstream): Boolean { override fun matches(up: Upstream): Boolean {
@@ -156,7 +156,7 @@ class Selector {
} }
} }
class MethodMatcher( data class MethodMatcher(
val method: String val method: String
) : Matcher { ) : Matcher {
override fun matches(up: Upstream): Boolean { override fun matches(up: Upstream): Boolean {

View File

@@ -172,7 +172,12 @@ class EthereumDirectReader(
return Mono.just(quorumReaderFactory) return Mono.just(quorumReaderFactory)
.map { .map {
it.create( it.create(
up.getApiSource(matcher), up.getApiSource(
Selector.Builder()
.withMatcher(matcher)
.forMethod(request.method)
.build()
),
callMethodsFactory.create().createQuorumFor(request.method), callMethodsFactory.create().createQuorumFor(request.method),
// we do not use Signer for internal requests because it doesn't make much sense // we do not use Signer for internal requests because it doesn't make much sense
null, null,

View File

@@ -113,7 +113,9 @@ class EthereumDirectReaderSpec extends Specification {
transactions = [] transactions = []
} }
def up = Mock(Multistream) { def up = Mock(Multistream) {
1 * getApiSource(new Selector.HeightMatcher(100)) >> Stub(ApiSource) 1 * getApiSource(
new Selector.Builder().withMatcher(new Selector.HeightMatcher(100)).forMethod("eth_getBlockByNumber").build()
) >> Stub(ApiSource)
} }
def calls = Mock(Factory) { def calls = Mock(Factory) {
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)