Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test #557

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ChainIdValidator(
}
}
.onErrorResume {
log.error("Error during chain validation", it)
log.error("Error during chain validation of upstream {}, reason - {}", upstream.getId(), it.message)
Mono.just(onError)
}
}
Expand All @@ -197,11 +197,13 @@ class ChainIdValidator(
.read(ChainRequest("eth_chainId", ListParams()))
.retryRandomBackoff(3, Duration.ofMillis(100), Duration.ofMillis(500)) { ctx ->
log.warn(
"error during chainId retrieving for ${upstream.getId()}, iteration ${ctx.iteration()}, " +
"message ${ctx.exception().message}",
"error during chainId retrieving for {}, iteration {}, reason - {}",
upstream.getId(),
ctx.iteration(),
ctx.exception().message,
)
}
.doOnError { log.error("Error during execution 'eth_chainId' - ${it.message} for ${upstream.getId()}") }
.doOnError { log.error("Error during execution 'eth_chainId' - {} for {}", it.message, upstream.getId()) }
.flatMap(ChainResponse::requireStringResult)
}

Expand All @@ -210,11 +212,13 @@ class ChainIdValidator(
.read(ChainRequest("net_version", ListParams()))
.retryRandomBackoff(3, Duration.ofMillis(100), Duration.ofMillis(500)) { ctx ->
log.warn(
"error during netVersion retrieving for ${upstream.getId()}, iteration ${ctx.iteration()}, " +
"message ${ctx.exception().message}",
"error during netVersion retrieving for {}, iteration {}, reason - {}",
upstream.getId(),
ctx.iteration(),
ctx.exception().message,
)
}
.doOnError { log.error("Error during execution 'net_version' - ${it.message} for ${upstream.getId()}") }
.doOnError { log.error("Error during execution 'net_version' - {} for {}", it.message, upstream.getId()) }
.flatMap(ChainResponse::requireStringResult)
}
}
Expand All @@ -237,8 +241,10 @@ class OldBlockValidator(
}
.retryRandomBackoff(3, Duration.ofMillis(100), Duration.ofMillis(500)) { ctx ->
log.warn(
"error during old block retrieving for ${upstream.getId()}, iteration ${ctx.iteration()}, " +
"message ${ctx.exception().message}",
"error during old block retrieving for {}, iteration {}, reason - {}",
upstream.getId(),
ctx.iteration(),
ctx.exception().message,
)
}
.map { result ->
Expand All @@ -251,7 +257,7 @@ class OldBlockValidator(
ValidateUpstreamSettingsResult.UPSTREAM_VALID
}
.onErrorResume {
log.warn("Error during old blocks validation", it)
log.warn("Error during old blocks validation of upstream {}, reason - {}", upstream.getId(), it.message)
Mono.just(ValidateUpstreamSettingsResult.UPSTREAM_VALID)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,9 @@ class GenericWsHeadTest {
Duration.ofSeconds(60),
)

StepVerifier.create(wsHead.getFlux())
StepVerifier.create(wsHead.headLiveness())
.then { wsHead.start() }
.expectNext(BlockContainer.from(block1))
.then {
StepVerifier.create(wsHead.headLiveness())
.expectNext(HeadLivenessState.FATAL_ERROR)
.thenCancel()
.verify(Duration.ofSeconds(2))
}
.expectNext(HeadLivenessState.FATAL_ERROR)
.thenCancel()
.verify(Duration.ofSeconds(3))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionRefJson
import io.emeraldpay.dshackle.upstream.forkchoice.AlwaysForkChoice
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
Expand Down Expand Up @@ -179,21 +180,17 @@ class GenericRpcHeadTest {
Duration.ofSeconds(5),
)

StepVerifier.withVirtualTime { head.getFlux() }
StepVerifier.withVirtualTime { head.headLiveness() }
.expectSubscription()
.then { head.start() }
.expectNoEvent(Duration.ofSeconds(5))
.expectNext(BlockContainer.from(block1))
.expectNoEvent(Duration.ofSeconds(5))
.then {
StepVerifier.create(head.headLiveness())
.expectNext(HeadLivenessState.FATAL_ERROR)
.thenCancel()
.verify(Duration.ofSeconds(3))
}
.expectNext(HeadLivenessState.FATAL_ERROR)
.thenCancel()
.verify(Duration.ofSeconds(3))

assertThat(head.getCurrentHeight()).isEqualTo(10000)

verify(reader, times(2)).read(ChainRequest("eth_getBlockByNumber", ListParams("latest", false)))
verify(reader).read(ChainRequest("eth_chainId", ListParams()))
verify(reader).read(ChainRequest("net_version", ListParams()))
Expand Down
Loading