solution: stream updates to blockchain status

This commit is contained in:
Igor Artamonov
2019-07-26 22:29:19 -04:00
parent 7467e19ea0
commit 64e0ac58fd
9 changed files with 143 additions and 12 deletions

View File

@@ -43,7 +43,7 @@ class EthereumGrpcTransportSpec extends Specification {
def status = transport.execute(batch.items).get()
then:
1 * otherSideUpstreams.ethereumUpstream(Chain.ETHEREUM) >> otherSideAggr
1 * otherSideUpstreams.getUpstream(Chain.ETHEREUM) >> otherSideAggr
1 * otherSideAggr.api >> otherSideApi
status.failed == 0
status.succeed == 1
@@ -87,7 +87,7 @@ class EthereumGrpcTransportSpec extends Specification {
def status = transport.execute(batch.items).get()
then:
1 * otherSideUpstreams.ethereumUpstream(Chain.ETHEREUM) >> otherSideAggr
1 * otherSideUpstreams.getUpstream(Chain.ETHEREUM) >> otherSideAggr
1 * otherSideAggr.api >> otherSideApi
status.failed == 0
status.succeed == 2

View File

@@ -0,0 +1,36 @@
package io.emeraldpay.dshackle.upstream
import spock.lang.Specification
class UpstreamAvailabilitySpec extends Specification {
def "Defined order"() {
expect:
UpstreamAvailability.OK.compareTo(UpstreamAvailability.IMMATURE) < 0
UpstreamAvailability.IMMATURE.compareTo(UpstreamAvailability.SYNCING) < 0
UpstreamAvailability.SYNCING.compareTo(UpstreamAvailability.LAGGING) < 0
UpstreamAvailability.LAGGING.compareTo(UpstreamAvailability.UNAVAILABLE) < 0
UpstreamAvailability.OK.compareTo(UpstreamAvailability.UNAVAILABLE) < 0
UpstreamAvailability.UNAVAILABLE.compareTo(UpstreamAvailability.OK) > 0
}
def "Sort array"() {
setup:
def items = [UpstreamAvailability.OK, UpstreamAvailability.SYNCING, UpstreamAvailability.IMMATURE, UpstreamAvailability.OK]
when:
Collections.sort(items)
then:
items == [UpstreamAvailability.OK, UpstreamAvailability.OK, UpstreamAvailability.IMMATURE, UpstreamAvailability.SYNCING]
}
def "First is most available"() {
expect:
[UpstreamAvailability.UNAVAILABLE, UpstreamAvailability.OK].toSorted().first() == UpstreamAvailability.OK
[UpstreamAvailability.OK, UpstreamAvailability.UNAVAILABLE].toSorted().first() == UpstreamAvailability.OK
[UpstreamAvailability.OK, UpstreamAvailability.LAGGING].toSorted().first() == UpstreamAvailability.OK
[UpstreamAvailability.LAGGING, UpstreamAvailability.UNAVAILABLE].toSorted().first() == UpstreamAvailability.LAGGING
[UpstreamAvailability.OK, UpstreamAvailability.SYNCING].toSorted().first() == UpstreamAvailability.OK
[UpstreamAvailability.SYNCING, UpstreamAvailability.UNAVAILABLE].toSorted().first() == UpstreamAvailability.SYNCING
}
}