problem: chain backed by single grpc upstream is unavailable
This commit is contained in:
@@ -58,6 +58,9 @@ class CurrentUpstreams(
|
||||
} else {
|
||||
current.addUpstream(up)
|
||||
}
|
||||
if (!callTargets.containsKey(chain)) {
|
||||
setupDefaultMethods(chain)
|
||||
}
|
||||
log.info("Upstream ${change.upstream.getId()} with chain $chain has been added")
|
||||
}
|
||||
}
|
||||
@@ -84,12 +87,13 @@ class CurrentUpstreams(
|
||||
}
|
||||
|
||||
override fun getDefaultMethods(chain: Chain): CallMethods {
|
||||
var current = callTargets[chain]
|
||||
if (current == null) {
|
||||
current = QuorumBasedMethods(objectMapper, chain)
|
||||
callTargets[chain] = current
|
||||
}
|
||||
return current
|
||||
return callTargets[chain] ?: return setupDefaultMethods(chain)
|
||||
}
|
||||
|
||||
fun setupDefaultMethods(chain: Chain): QuorumBasedMethods {
|
||||
val created = QuorumBasedMethods(objectMapper, chain)
|
||||
callTargets[chain] = created
|
||||
return created
|
||||
}
|
||||
|
||||
override fun isAvailable(chain: Chain): Boolean {
|
||||
|
||||
@@ -52,4 +52,22 @@ class CurrentUpstreamsSpec extends Specification {
|
||||
current.getUpstream(Chain.ETHEREUM).getAll().toSet() == [up3].toSet()
|
||||
current.getUpstream(Chain.ETHEREUM_CLASSIC).getAll().toSet() == [up2].toSet()
|
||||
}
|
||||
|
||||
def "available after adding"() {
|
||||
setup:
|
||||
def current = new CurrentUpstreams(TestingCommons.objectMapper())
|
||||
def up1 = new EthereumUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api(Stub(ReactorRpcClient)))
|
||||
|
||||
when:
|
||||
def act = current.isAvailable(Chain.ETHEREUM)
|
||||
then:
|
||||
!act
|
||||
|
||||
when:
|
||||
current.update(new UpstreamChange(Chain.ETHEREUM, up1, UpstreamChange.ChangeType.ADDED))
|
||||
act = current.isAvailable(Chain.ETHEREUM)
|
||||
|
||||
then:
|
||||
act
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user