problem: Proxy doesn't render internal exceptions to JSON RPC errors
This commit is contained in:
@@ -63,9 +63,6 @@ open class WriteRpcJson {
|
|||||||
Mono.empty()
|
Mono.empty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onErrorContinue { t, _ ->
|
|
||||||
log.warn("Failed to convert to JSON", t)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package io.emeraldpay.dshackle.proxy
|
package io.emeraldpay.dshackle.proxy
|
||||||
|
|
||||||
import com.google.protobuf.ByteString
|
|
||||||
import io.emeraldpay.api.proto.BlockchainOuterClass
|
|
||||||
import io.emeraldpay.dshackle.rpc.NativeCall
|
import io.emeraldpay.dshackle.rpc.NativeCall
|
||||||
import io.emeraldpay.dshackle.test.TestingCommons
|
import org.jetbrains.annotations.NotNull
|
||||||
import reactor.core.publisher.Flux
|
import reactor.core.publisher.Flux
|
||||||
import spock.lang.Specification
|
import spock.lang.Specification
|
||||||
|
|
||||||
@@ -143,4 +141,27 @@ class WriteRpcJsonSpec extends Specification {
|
|||||||
act[1] == '{"jsonrpc":"2.0","id":11,"error":{"code":-32002,"message":"oops"}}'
|
act[1] == '{"jsonrpc":"2.0","id":11,"error":{"code":-32002,"message":"oops"}}'
|
||||||
act[2] == '{"jsonrpc":"2.0","id":15,"result":{"hash": "0x2484f459dc"}}'
|
act[2] == '{"jsonrpc":"2.0","id":15,"result":{"hash": "0x2484f459dc"}}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "Write JSON RPC error on exception"() {
|
||||||
|
setup:
|
||||||
|
def writer = new WriteRpcJson() {
|
||||||
|
@Override
|
||||||
|
String toJson(@NotNull ProxyCall call, @NotNull NativeCall.CallResult response) {
|
||||||
|
throw new NativeCall.CallFailure(1, new IllegalStateException("TEST"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def call = new ProxyCall(ProxyCall.RpcType.SINGLE)
|
||||||
|
call.ids[1] = 10
|
||||||
|
def data = [
|
||||||
|
new NativeCall.CallResult(1, '"0x1"'.bytes, null),
|
||||||
|
]
|
||||||
|
when:
|
||||||
|
def act = Flux.fromIterable(data)
|
||||||
|
.transform(writer.toJsons(call))
|
||||||
|
.collectList()
|
||||||
|
.block(Duration.ofSeconds(1))
|
||||||
|
then:
|
||||||
|
act[0] == '{"jsonrpc":"2.0","id":10,"error":{"code":-32003,"message":"TEST"}}'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user