Height matcher to proxy (#340)

This commit is contained in:
KirillPamPam
2023-11-27 14:54:28 +04:00
committed by GitHub
parent d0322a0dab
commit 4dc52091e3
4 changed files with 54 additions and 5 deletions

View File

@@ -32,11 +32,37 @@ class SelectorSpec extends Specification {
private BlockchainOuterClass.Selector selectLabel2Selector = BlockchainOuterClass.Selector.newBuilder()
.setLabelSelector(selectLabel2).build()
def "Convert nothing"() {
def "Convert height selector"() {
setup:
def heightSelector = BlockchainOuterClass.Selector.newBuilder()
.setHeightSelector(
BlockchainOuterClass.HeightSelector.newBuilder()
.setHeight(10000)
.build()
)
.build()
when:
def act = Selector.convertToMatcher(null)
def act = Selector.convertToMatcher(List.of(heightSelector), Stub(Head))
then:
act.class == Selector.AnyLabelMatcher
act == new Selector.MultiMatcher(List.of(new Selector.HeightMatcher(10000)))
}
def "Convert height selector with latest"() {
setup:
def head = Mock(Head) {
1 * getCurrentHeight() >> 15000
}
def heightSelector = BlockchainOuterClass.Selector.newBuilder()
.setHeightSelector(
BlockchainOuterClass.HeightSelector.newBuilder()
.setHeight(-1)
.build()
)
.build()
when:
def act = Selector.convertToMatcher(List.of(heightSelector), head)
then:
act == new Selector.MultiMatcher(List.of(new Selector.HeightMatcher(15000)))
}
def "Convert LABEL match"() {