fixed tests

This commit is contained in:
Maxksim Fomenkov
2022-09-14 16:00:10 +03:00
parent a7a49425cd
commit f4f34f071e
25 changed files with 68 additions and 44 deletions

View File

@@ -73,9 +73,11 @@ open class NativeSubscribe(
is SilentException.UnsupportedBlockchain -> StatusException(
Status.UNAVAILABLE.withDescription("BLOCKCHAIN UNAVAILABLE: ${t.blockchainId}")
)
is UnsupportedOperationException -> StatusException(
Status.UNIMPLEMENTED.withDescription(t.message)
)
else -> {
log.warn("Unhandled error", t)
StatusException(
@@ -98,7 +100,7 @@ open class NativeSubscribe(
holder.nonce?.also { nonce ->
holder.getSource()?.let {
signer.sign(nonce, result, it)
signer.sign(nonce, result, it)
}?.let {
buildSignature(nonce, it)
}?.also {

View File

@@ -58,7 +58,7 @@ class EthereumWsFactory(
)
}
fun create(id: String, upstream: DefaultUpstream?, validator: EthereumUpstreamValidator?): WsConnection {
fun create(upstream: DefaultUpstream?, validator: EthereumUpstreamValidator?): WsConnection {
require(upstream == null || upstream.getId() == id) {
"Creating instance for different upstream. ${upstream?.getId()} != id"
}

View File

@@ -34,7 +34,7 @@ class EthereumRpcConnector(
init {
if (wsFactory != null) {
// do not set upstream to the WS, since it doesn't control the RPC upstream
conn = wsFactory.create(id, null, null)
conn = wsFactory.create(null, null)
val wsHead = EthereumWsHead(conn, id, forkChoice, blockValidator)
// receive bew blocks through WebSockets, but also periodically verify with RPC in case if WS failed
val rpcHead = EthereumRpcHead(directReader, forkChoice, id, blockValidator, Duration.ofSeconds(60))

View File

@@ -4,12 +4,14 @@ import io.emeraldpay.dshackle.reader.Reader
import io.emeraldpay.dshackle.upstream.BlockValidator
import io.emeraldpay.dshackle.upstream.DefaultUpstream
import io.emeraldpay.dshackle.upstream.Head
import io.emeraldpay.dshackle.upstream.ethereum.*
import io.emeraldpay.dshackle.upstream.ethereum.EthereumUpstreamValidator
import io.emeraldpay.dshackle.upstream.ethereum.EthereumWsFactory
import io.emeraldpay.dshackle.upstream.ethereum.EthereumWsHead
import io.emeraldpay.dshackle.upstream.ethereum.WsConnection
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcWsClient
import io.emeraldpay.grpc.Chain
class EthereumWsConnector(
wsFactory: EthereumWsFactory,
@@ -23,7 +25,7 @@ class EthereumWsConnector(
private val head: EthereumWsHead
init {
conn = wsFactory.create(upstream.getId(), upstream, validator)
conn = wsFactory.create(upstream, validator)
head = EthereumWsHead(conn, upstream.getId(), forkChoice, blockValidator)
api = JsonRpcWsClient(conn)
}