-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create BroadcastReader based on quorum (#424)
- Loading branch information
1 parent
b23a5dc
commit 8f0700a
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/test/kotlin/io/emeraldpay/dshackle/reader/RpcReaderFactoryTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
), | ||
), | ||
) | ||
} | ||
} | ||
} |