slot height matcher implementation (#353)
This commit is contained in:
@@ -68,6 +68,11 @@ class EthereumHeadMock implements Head {
|
||||
return latest?.height
|
||||
}
|
||||
|
||||
@Override
|
||||
Long getCurrentSlotHeight() {
|
||||
return latest?.slot
|
||||
}
|
||||
|
||||
@Override
|
||||
void start() {
|
||||
|
||||
|
||||
@@ -462,7 +462,7 @@ class FilteredApisSpec extends Specification {
|
||||
_ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY
|
||||
_ * isAvailable() >> true
|
||||
_ * getHead() >> Mock(Head) {
|
||||
_ * getCurrentHeight() >> 100000001
|
||||
_ * getCurrentSlotHeight() >> 100000001
|
||||
}
|
||||
_ * getStatus() >> UpstreamAvailability.OK
|
||||
_ * getLabels() >> of(UpstreamsConfig.Labels.fromMap(Map.of("node", "test")))
|
||||
@@ -474,7 +474,7 @@ class FilteredApisSpec extends Specification {
|
||||
_ * getId() >> "id1"
|
||||
_ * getStatus() >> UpstreamAvailability.OK
|
||||
_ * getHead() >> Mock(Head) {
|
||||
_ * getCurrentHeight() >> 100000
|
||||
_ * getCurrentSlotHeight() >> 100000
|
||||
}
|
||||
_ * getLabels() >> of(UpstreamsConfig.Labels.fromMap(Map.of("node", "archive")))
|
||||
}, up
|
||||
@@ -484,7 +484,7 @@ class FilteredApisSpec extends Specification {
|
||||
Chain.ETHEREUM__MAINNET, ups,
|
||||
new Selector.MultiMatcher(
|
||||
of(
|
||||
new Selector.HeightMatcher(100000000),
|
||||
new Selector.SlotMatcher(100000000),
|
||||
new Selector.LabelMatcher("node", of("test"))
|
||||
)
|
||||
)
|
||||
|
||||
@@ -32,6 +32,21 @@ class SelectorSpec extends Specification {
|
||||
private BlockchainOuterClass.Selector selectLabel2Selector = BlockchainOuterClass.Selector.newBuilder()
|
||||
.setLabelSelector(selectLabel2).build()
|
||||
|
||||
def "Convert slot height selector"() {
|
||||
setup:
|
||||
def slotHeightSelector = BlockchainOuterClass.Selector.newBuilder()
|
||||
.setSlotHeightSelector(
|
||||
BlockchainOuterClass.SlotHeightSelector.newBuilder()
|
||||
.setSlotHeight(10000)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
when:
|
||||
def act = Selector.convertToMatcher(List.of(slotHeightSelector), Stub(Head))
|
||||
then:
|
||||
act == new Selector.MultiMatcher(List.of(new Selector.SlotMatcher(10000)))
|
||||
}
|
||||
|
||||
def "Convert height selector"() {
|
||||
setup:
|
||||
def heightSelector = BlockchainOuterClass.Selector.newBuilder()
|
||||
|
||||
Reference in New Issue
Block a user