fix tests

This commit is contained in:
Maxksim Fomenkov
2022-09-22 14:20:13 +03:00
parent 4bb93023e8
commit b1482fbf5a
2 changed files with 15 additions and 25 deletions

View File

@@ -16,6 +16,7 @@
*/ */
package io.emeraldpay.dshackle.upstream package io.emeraldpay.dshackle.upstream
import com.google.common.annotations.VisibleForTesting
import io.emeraldpay.dshackle.cache.Caches import io.emeraldpay.dshackle.cache.Caches
import io.emeraldpay.dshackle.cache.CachesEnabled import io.emeraldpay.dshackle.cache.CachesEnabled
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
@@ -61,4 +62,8 @@ class MergedHead(
} }
} }
} }
@VisibleForTesting
private fun getSources() =
sources
} }

View File

@@ -203,34 +203,19 @@ class MultistreamSpec extends Specification {
def "Filter upstream matching selector single"() { def "Filter upstream matching selector single"() {
setup: setup:
def up1 = TestingCommons.upstream("test-1", "internal")
def block1 = createBlock(111111) def up2 = TestingCommons.upstream("test-2", "external")
def block2 = createBlock(222222) def up3 = TestingCommons.upstream("test-3", "external")
def block3 = createBlock(222222)
def up1 = TestingCommons.upstream("test-1", "internal").tap {
it.ethereumHeadMock.predefined = Flux.just(block1)
}
def up2 = TestingCommons.upstream("test-2", "external").tap {
it.ethereumHeadMock.predefined = Flux.just(block2)
}
def up3 = TestingCommons.upstream("test-3", "external").tap {
it.ethereumHeadMock.predefined = Flux.just(block3)
}
def multistream = new EthereumPosMultiStream(Chain.ETHEREUM, [up1, up2, up3], Caches.default()) def multistream = new EthereumPosMultiStream(Chain.ETHEREUM, [up1, up2, up3], Caches.default())
expect:
multistream.getHead(new Selector.LabelMatcher("provider", ["internal"])).is(up1.ethereumHeadMock)
multistream.getHead(new Selector.LabelMatcher("provider", ["unknown"])) in EmptyHead
up1.ethereumHeadMock.toString() def head = multistream.getHead(new Selector.LabelMatcher("provider", ["external"]))
head in MergedHead
when: (head as MergedHead).isRunning()
def head = multistream.getHead(new Selector.LabelMatcher("provider", ["internal"])).flux (head as MergedHead).getSources().sort() == [up2.ethereumHeadMock, up3.ethereumHeadMock].sort()
then:
StepVerifier.create(head)
.expectNext(block1)
.expectNext(block1)
.expectComplete()
.verify(Duration.ofSeconds(1))
} }