problem: uses only one Head Subscription for Dshackle Upstream even if multiple are provided
This commit is contained in:
@@ -87,7 +87,7 @@ class EthereumGrpcUpstreamSpec extends Specification {
|
||||
.addAllSupportedMethods(["eth_getBlockByHash"])
|
||||
.build())
|
||||
when:
|
||||
new Thread({ Thread.sleep(50); upstream.start() }).start()
|
||||
new Thread({ Thread.sleep(50); upstream.head.start() }).start()
|
||||
def h = upstream.head.getFlux().next().block(Duration.ofSeconds(1))
|
||||
then:
|
||||
callData.chain == Chain.ETHEREUM.id
|
||||
@@ -145,8 +145,8 @@ class EthereumGrpcUpstreamSpec extends Specification {
|
||||
.addAllSupportedMethods(["eth_getBlockByHash"])
|
||||
.build())
|
||||
when:
|
||||
new Thread({ Thread.sleep(50); upstream.start() }).start()
|
||||
def h = upstream.head.getFlux().take(Duration.ofSeconds(1)).last().block()
|
||||
new Thread({ Thread.sleep(50); upstream.head.start() }).start()
|
||||
def h = upstream.head.getFlux().take(Duration.ofSeconds(1)).last().block(Duration.ofSeconds(2))
|
||||
then:
|
||||
upstream.status == UpstreamAvailability.OK
|
||||
h.hash == BlockId.from("0x50d26e119968e791970d84a7bf5d0ec474d3ec2ef85d5ec8915210ac6bc09ad7")
|
||||
@@ -207,9 +207,9 @@ class EthereumGrpcUpstreamSpec extends Specification {
|
||||
.addAllSupportedMethods(["eth_getBlockByHash"])
|
||||
.build())
|
||||
when:
|
||||
new Thread({ Thread.sleep(50); upstream.start() }).start()
|
||||
new Thread({ Thread.sleep(50); upstream.head.start() }).start()
|
||||
finished.get()
|
||||
def h = upstream.head.getFlux().take(Duration.ofSeconds(1)).last().block()
|
||||
def h = upstream.head.getFlux().take(Duration.ofSeconds(1)).last().block(Duration.ofSeconds(2))
|
||||
then:
|
||||
upstream.status == UpstreamAvailability.OK
|
||||
h.hash == BlockId.from("0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec891521a")
|
||||
|
||||
@@ -18,7 +18,6 @@ package io.emeraldpay.dshackle.upstream.grpc
|
||||
import io.emeraldpay.api.proto.BlockchainGrpc
|
||||
import io.emeraldpay.api.proto.BlockchainOuterClass
|
||||
import io.emeraldpay.api.proto.Common
|
||||
import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.dshackle.test.MockGrpcServer
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.DefaultUpstream
|
||||
@@ -28,7 +27,6 @@ import reactor.test.StepVerifier
|
||||
import spock.lang.Specification
|
||||
|
||||
import java.time.Duration
|
||||
import java.util.function.Function
|
||||
|
||||
class GrpcHeadSpec extends Specification {
|
||||
|
||||
@@ -61,6 +59,7 @@ class GrpcHeadSpec extends Specification {
|
||||
def head = new GrpcHead(
|
||||
Chain.BITCOIN,
|
||||
Stub(DefaultUpstream),
|
||||
client,
|
||||
convert, null
|
||||
)
|
||||
when:
|
||||
@@ -69,7 +68,7 @@ class GrpcHeadSpec extends Specification {
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.then { head.start(client) }
|
||||
.then { head.start() }
|
||||
.expectNext(TestingCommons.blockForBitcoin(10)).as("block 10")
|
||||
.expectNext(TestingCommons.blockForBitcoin(11)).as("block 11")
|
||||
.expectNext(TestingCommons.blockForBitcoin(12)).as("block 12")
|
||||
@@ -121,12 +120,13 @@ class GrpcHeadSpec extends Specification {
|
||||
def head = new GrpcHead(
|
||||
Chain.BITCOIN,
|
||||
Stub(DefaultUpstream),
|
||||
client,
|
||||
convert, null
|
||||
)
|
||||
when:
|
||||
def act = head.getFlux()
|
||||
.take(3)
|
||||
head.start(client)
|
||||
head.start()
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
|
||||
Reference in New Issue
Block a user