problem: eth_chainId is not available

This commit is contained in:
Igor Artamonov
2021-12-24 18:10:03 -05:00
parent 8526c2a3ee
commit f2b471c56f
13 changed files with 56 additions and 30 deletions

View File

@@ -45,9 +45,9 @@ class MultistreamSpec extends Specification {
aggr.onUpstreamsUpdated()
def act = aggr.getMethods()
then:
act.isAllowed("eth_test1")
act.isAllowed("eth_test2")
act.isAllowed("eth_test3")
act.isCallable("eth_test1")
act.isCallable("eth_test2")
act.isCallable("eth_test3")
act.getQuorumFor("eth_test1") instanceof AlwaysQuorum
act.getQuorumFor("eth_test2") instanceof AlwaysQuorum
act.getQuorumFor("eth_test3") instanceof AlwaysQuorum

View File

@@ -17,9 +17,6 @@
package io.emeraldpay.dshackle.upstream.calls
import io.emeraldpay.dshackle.quorum.AlwaysQuorum
import io.emeraldpay.dshackle.upstream.calls.AggregatedCallMethods
import io.emeraldpay.dshackle.upstream.calls.CallMethods
import io.emeraldpay.dshackle.upstream.calls.DirectCallMethods
import spock.lang.Specification
class AggregatedCallMethodsSpec extends Specification {
@@ -29,11 +26,11 @@ class AggregatedCallMethodsSpec extends Specification {
def quorum = new AlwaysQuorum()
def delegate1 = Mock(CallMethods) {
_ * getSupportedMethods() >> ["eth_no_test", "foo_bar"]
1 * isAllowed("eth_test") >> false
1 * isCallable("eth_test") >> false
}
def delegate2 = Mock(CallMethods) {
_ * getSupportedMethods() >> ["eth_test", "foo_bar"]
1 * isAllowed("eth_test") >> true
1 * isCallable("eth_test") >> true
1 * getQuorumFor("eth_test") >> quorum
}
def aggregate = new AggregatedCallMethods([delegate1, delegate2])
@@ -49,22 +46,22 @@ class AggregatedCallMethodsSpec extends Specification {
def delegate2 = new DirectCallMethods(["eth_test", "foo_bar"] as Set)
def aggregate = new AggregatedCallMethods([delegate1, delegate2])
when:
def act = aggregate.isAllowed("eth_test")
def act = aggregate.isCallable("eth_test")
then:
act
when:
act = aggregate.isAllowed("eth_no_test")
act = aggregate.isCallable("eth_no_test")
then:
act
when:
act = aggregate.isAllowed("foo_bar")
act = aggregate.isCallable("foo_bar")
then:
act
when:
act = aggregate.isAllowed("nothing")
act = aggregate.isCallable("nothing")
then:
!act
}
@@ -106,12 +103,12 @@ class AggregatedCallMethodsSpec extends Specification {
setup:
def delegate1 = Mock(CallMethods) {
_ * getSupportedMethods() >> ["eth_no_test", "foo_bar"]
_ * isAllowed(_) >> false
_ * isCallable(_) >> false
1 * isHardcoded("eth_no_test") >> false
}
def delegate2 = Mock(CallMethods) {
_ * getSupportedMethods() >> ["eth_test", "foo_bar"]
_ * isAllowed(_) >> false
_ * isCallable(_) >> false
1 * isHardcoded("eth_test") >> true
}
def aggregate = new AggregatedCallMethods([delegate1, delegate2])

View File

@@ -5,6 +5,15 @@ import spock.lang.Specification
class DefaultEthereumMethodsSpec extends Specification {
def "eth_chainId is available"() {
setup:
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
when:
def act = methods.isAvailable("eth_chainId")
then:
act
}
def "eth_chainId is hardcoded"() {
setup:
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
@@ -14,6 +23,15 @@ class DefaultEthereumMethodsSpec extends Specification {
act
}
def "eth_chainId is not callable"() {
setup:
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
when:
def act = methods.isCallable("eth_chainId")
then:
!act
}
def "Provides hardcoded correct chainId"() {
expect:
new String(new DefaultEthereumMethods(chain).executeHardcoded("eth_chainId")) == id