problem: doesn't work for private ethereum networks

solution: allow configuring methods with static responses
rel: #96
This commit is contained in:
Rafael Matias
2021-11-12 18:55:41 +01:00
committed by GitHub
parent b6a05d67df
commit ee5b14b300
6 changed files with 74 additions and 6 deletions

View File

@@ -22,8 +22,8 @@ class ConfiguredUpstreamsSpec extends Specification {
)
def methods = new UpstreamsConfig.Methods(
[
new UpstreamsConfig.Method("foo_bar", null),
new UpstreamsConfig.Method("foo_bar", "not_empty")
new UpstreamsConfig.Method("foo_bar", null, null),
new UpstreamsConfig.Method("foo_bar", "not_empty", null)
] as Set,
[] as Set
)
@@ -35,4 +35,27 @@ class ConfiguredUpstreamsSpec extends Specification {
act instanceof ManagedCallMethods
act.getQuorumFor("foo_bar") instanceof NonEmptyQuorum
}
def "Got static response from extra methods"() {
setup:
def currentUpstreams = Mock(CurrentMultistreamHolder) {
_ * getDefaultMethods(Chain.ETHEREUM) >> new DefaultEthereumMethods(Chain.ETHEREUM)
}
def configurer = new ConfiguredUpstreams(
currentUpstreams, Stub(FileResolver), Stub(UpstreamsConfig), Stub(CachesFactory)
)
def methods = new UpstreamsConfig.Methods(
[
new UpstreamsConfig.Method("foo_bar", null, "static_response")
] as Set,
[] as Set
)
def upstream = new UpstreamsConfig.Upstream()
upstream.methods = methods
when:
def act = configurer.buildMethods(upstream, Chain.ETHEREUM)
then:
act instanceof ManagedCallMethods
new String(act.executeHardcoded("foo_bar")) == "\"static_response\""
}
}