fix streaming when response and error present in response (#469)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.emeraldpay.dshackle.upstream.rpcclient.stream
|
||||
|
||||
import io.emeraldpay.dshackle.upstream.ChainCallError
|
||||
import io.emeraldpay.dshackle.upstream.stream.AggregateResponse
|
||||
import io.emeraldpay.dshackle.upstream.stream.Chunk
|
||||
import io.emeraldpay.dshackle.upstream.stream.SingleResponse
|
||||
@@ -71,6 +72,28 @@ class JsonRpcStreamParserTest {
|
||||
.verify(Duration.ofSeconds(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `if first part has result field and error then single response`() {
|
||||
val statusCode = 200
|
||||
val response =
|
||||
@Suppress("ktlint:standard:max-line-length")
|
||||
"{\"id\": 2,\"result\": null, \"error\":{\"code\":-32000,\"message\":\"tracing failed: fee cap less than block base fee\"}}".toByteArray()
|
||||
val stream: Flux<ByteArray> = Flux.just(response)
|
||||
|
||||
StepVerifier.create(streamParser.streamParse(statusCode, stream))
|
||||
.expectNext(
|
||||
SingleResponse(
|
||||
"null".toByteArray(),
|
||||
ChainCallError(
|
||||
-32000,
|
||||
"tracing failed: fee cap less than block base fee",
|
||||
),
|
||||
),
|
||||
)
|
||||
.expectComplete()
|
||||
.verify(Duration.ofSeconds(1))
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataStream")
|
||||
fun `if big result then stream response`(
|
||||
|
||||
Reference in New Issue
Block a user