From 214abc4722383071e8ab124932aae99024abc068 Mon Sep 17 00:00:00 2001 From: a10zn8 Date: Fri, 16 Dec 2022 15:19:15 +0400 Subject: [PATCH] Revert "problem: timeout on unit tests" --- .../emeraldpay/dshackle/upstream/ethereum/WsConnection.kt | 3 +-- .../dshackle/upstream/ethereum/WsConnectionSpec.groovy | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt index 5373e796..c30f3f89 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt @@ -405,8 +405,7 @@ open class WsConnection( ) val response = Flux.from(rpcReceive.asFlux()) - // send the request _after_ WS subscribes to the responses, otherwise the response may come before the actual subscription and be lost - .doOnRequest { sendRpc(request) } + .doOnSubscribe { sendRpc(request) } .filter { resp -> resp.id.asNumber() == expectedId } .take(Defaults.timeout) .take(1) diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionSpec.groovy index 54849052..18350845 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionSpec.groovy @@ -92,7 +92,7 @@ class WsConnectionSpec extends Specification { it.id.asNumber() == 15L && Global.objectMapper.readValue(it.result, TransactionJson) == tx } .expectComplete() - .verify(Duration.ofSeconds(1)) + .verify(Duration.ofSeconds(5)) } def "Makes a RPC call - return null"() { @@ -115,7 +115,7 @@ class WsConnectionSpec extends Specification { it.resultAsRawString == 'null' } .expectComplete() - .verify(Duration.ofSeconds(1)) + .verify(Duration.ofSeconds(5)) } def "Makes a RPC call - return error"() { @@ -140,6 +140,6 @@ class WsConnectionSpec extends Specification { it.error.code == RpcResponseError.CODE_METHOD_NOT_EXIST && it.error.message == "test" } .expectComplete() - .verify(Duration.ofSeconds(1)) + .verify(Duration.ofSeconds(5)) } }