Fix quorum (#700)

This commit is contained in:
KirillPamPam
2025-08-12 17:36:23 +04:00
committed by GitHub
parent a34f2186cc
commit 0063c89865
2 changed files with 3 additions and 8 deletions

View File

@@ -54,7 +54,6 @@ class ManagedCallMethods(
)
private val quorum: MutableMap<String, Factory<CallQuorum>> = HashMap()
private val staticResponse: MutableMap<String, String> = HashMap()
private val redefined = delegated.keys.filter(enabled::contains).associateWith { true }
init {
enabled.forEach { m ->
@@ -81,7 +80,7 @@ class ManagedCallMethods(
override fun createQuorumFor(method: String): CallQuorum {
return when {
isDelegated(method) && !isRedefined(method) -> delegate.createQuorumFor(method)
isDelegated(method) -> delegate.createQuorumFor(method)
allAllowed.contains(method) -> quorum[method]?.create() ?: defaultQuorum.create()
else -> {
log.warn("Getting quorum for unknown method - $method")
@@ -94,10 +93,6 @@ class ManagedCallMethods(
return delegated[method] ?: false
}
private fun isRedefined(method: String): Boolean {
return redefined[method] ?: false
}
override fun isCallable(method: String): Boolean {
return allAllowed.contains(method)
}

View File

@@ -75,7 +75,7 @@ class ManagedCallMethodsSpec extends Specification {
def delegated = ["eth_test", "eth_test2"] as Set
def delegate = Mock(CallMethods) {
_ * it.getSupportedMethods() >> delegated
0 * it.createQuorumFor("eth_test") >> new BroadcastQuorum()
1 * it.createQuorumFor("eth_test") >> new BroadcastQuorum()
}
def managed = new ManagedCallMethods(
delegate,
@@ -88,7 +88,7 @@ class ManagedCallMethodsSpec extends Specification {
def act = managed.createQuorumFor("eth_test")
then:
act != null
act instanceof AlwaysQuorum
act instanceof BroadcastQuorum
}
def "Use custom quorum if provided"() {