Create BroadcastReader based on quorum (#424)

This commit is contained in:
KirillPamPam
2024-02-21 15:26:44 +04:00
committed by GitHub
parent b23a5dc619
commit 8f0700a6b4
2 changed files with 60 additions and 1 deletions

View File

@@ -0,0 +1,57 @@
package io.emeraldpay.dshackle.reader
import io.emeraldpay.dshackle.quorum.BroadcastQuorum
import io.emeraldpay.dshackle.quorum.MaximumValueQuorum
import io.emeraldpay.dshackle.upstream.Multistream
import io.emeraldpay.dshackle.upstream.Selector
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import org.mockito.kotlin.mock
import org.springframework.cloud.sleuth.Tracer
class RpcReaderFactoryTest {
private val defaultFactory = RpcReaderFactory.Default()
@ParameterizedTest
@MethodSource("data")
fun `create BroadcastReader for MaximumValueQuorum and BroadcastQuorum`(
rpcReaderData: RpcReaderFactory.RpcReaderData,
) {
val reader = defaultFactory.create(rpcReaderData)
assertTrue(reader is BroadcastReader)
}
companion object {
private val ms = mock<Multistream>()
private val tracer = mock<Tracer>()
@JvmStatic
fun data(): List<Arguments> {
return listOf(
Arguments.of(
RpcReaderFactory.RpcReaderData(
ms,
"method",
Selector.empty,
MaximumValueQuorum(),
null,
tracer,
),
),
Arguments.of(
RpcReaderFactory.RpcReaderData(
ms,
"method",
Selector.empty,
BroadcastQuorum(),
null,
tracer,
),
),
)
}
}
}