support object params
This commit is contained in:
@@ -24,6 +24,7 @@ import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import org.springframework.cloud.sleuth.Tracer
|
||||
@@ -42,7 +43,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
_ * getId() >> "id"
|
||||
_ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_test", [])) >> Mono.just(JsonRpcResponse.ok("1"))
|
||||
1 * read(new JsonRpcRequest("eth_test", new ListParams())) >> Mono.just(JsonRpcResponse.ok("1"))
|
||||
}
|
||||
}
|
||||
def apis = new FilteredApis(
|
||||
@@ -52,7 +53,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", new ListParams()))
|
||||
.map {
|
||||
new String(it.value)
|
||||
}
|
||||
@@ -67,7 +68,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def "always-quorum - return upstream error returned"() {
|
||||
setup:
|
||||
def api = Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_test", [])) >>> [
|
||||
1 * read(new JsonRpcRequest("eth_test", new ListParams())) >>> [
|
||||
Mono.just(JsonRpcResponse.error(1, "test"))
|
||||
]
|
||||
}
|
||||
@@ -84,7 +85,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", new ListParams()))
|
||||
.map {
|
||||
new String(it.value)
|
||||
}
|
||||
@@ -100,7 +101,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def "always-quorum - return upstream error thrown"() {
|
||||
setup:
|
||||
def api = Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_test", [])) >>> [
|
||||
1 * read(new JsonRpcRequest("eth_test", new ListParams())) >>> [
|
||||
Mono.error(
|
||||
new RpcException(
|
||||
RpcResponseError.CODE_UPSTREAM_CONNECTION_ERROR,
|
||||
@@ -122,7 +123,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", new ListParams()))
|
||||
.map {
|
||||
new String(it.value)
|
||||
}
|
||||
@@ -142,7 +143,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
_ * getId() >> "id"
|
||||
_ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY
|
||||
_ * getIngressReader() >> Mock(Reader) {
|
||||
2 * read(new JsonRpcRequest("eth_test", [])) >>> [
|
||||
2 * read(new JsonRpcRequest("eth_test", new ListParams())) >>> [
|
||||
Mono.just(JsonRpcResponse.ok("null")),
|
||||
Mono.just(JsonRpcResponse.ok("1"))
|
||||
]
|
||||
@@ -155,7 +156,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def reader = new QuorumRpcReader(apis, new NotNullQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", new ListParams()))
|
||||
.map {
|
||||
new String(it.value)
|
||||
}
|
||||
@@ -175,7 +176,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
_ * getId() >> "id"
|
||||
_ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY
|
||||
_ * getIngressReader() >> Mock(Reader) {
|
||||
2 * read(new JsonRpcRequest("eth_test", [])) >>> [
|
||||
2 * read(new JsonRpcRequest("eth_test", new ListParams())) >>> [
|
||||
Mono.just(JsonRpcResponse.error(1, "test")),
|
||||
Mono.just(JsonRpcResponse.ok("1"))
|
||||
]
|
||||
@@ -188,7 +189,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def reader = new QuorumRpcReader(apis, new NotNullQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", new ListParams()))
|
||||
.map {
|
||||
new String(it.value)
|
||||
}
|
||||
@@ -203,7 +204,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def "non-empty-quorum - error if all failed"() {
|
||||
setup:
|
||||
def api = Mock(Reader) {
|
||||
2 * read(new JsonRpcRequest("eth_test", [])) >>> [
|
||||
2 * read(new JsonRpcRequest("eth_test", new ListParams())) >>> [
|
||||
Mono.just(JsonRpcResponse.error(1, "test")),
|
||||
Mono.just(JsonRpcResponse.error(1, "test")),
|
||||
]
|
||||
@@ -221,7 +222,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def reader = new QuorumRpcReader(apis, new NotNullQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", new ListParams()))
|
||||
.map {
|
||||
new String(it.value)
|
||||
}
|
||||
@@ -235,7 +236,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def "always-quorum - error if failed"() {
|
||||
setup:
|
||||
def api = Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_test", [])) >>> [
|
||||
1 * read(new JsonRpcRequest("eth_test", new ListParams())) >>> [
|
||||
Mono.just(JsonRpcResponse.error(1, "test error")),
|
||||
]
|
||||
}
|
||||
@@ -252,7 +253,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", new ListParams()))
|
||||
.map {
|
||||
new String(it.value)
|
||||
}
|
||||
@@ -274,7 +275,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
_ * isAvailable() >> true
|
||||
_ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY
|
||||
_ * getIngressReader() >> Mock(Reader) {
|
||||
_ * read(new JsonRpcRequest("eth_test", [])) >>> [
|
||||
_ * read(new JsonRpcRequest("eth_test", new ListParams())) >>> [
|
||||
Mono.just(JsonRpcResponse.error(-3010, "test")),
|
||||
]
|
||||
}
|
||||
@@ -286,7 +287,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def reader = new QuorumRpcReader(apis, new NotLaggingQuorum(1), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", new ListParams()))
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
@@ -312,7 +313,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", new ListParams()))
|
||||
.map {
|
||||
new String(it.value)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import org.springframework.cloud.sleuth.Tracer
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.test.StepVerifier
|
||||
@@ -22,7 +23,7 @@ class BroadcastReaderSpec extends Specification {
|
||||
1 * isAvailable() >> true
|
||||
_ * getId() >> "id"
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"]))) >>
|
||||
Mono.just(new JsonRpcResponse(result, null))
|
||||
}
|
||||
}
|
||||
@@ -30,7 +31,7 @@ class BroadcastReaderSpec extends Specification {
|
||||
1 * isAvailable() >> true
|
||||
_ * getId() >> "id"
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"]))) >>
|
||||
Mono.just(new JsonRpcResponse(result, null))
|
||||
}
|
||||
}
|
||||
@@ -38,13 +39,13 @@ class BroadcastReaderSpec extends Specification {
|
||||
1 * isAvailable() >> true
|
||||
_ * getId() >> "id"
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"]))) >>
|
||||
Mono.just(new JsonRpcResponse(result, null))
|
||||
}
|
||||
}
|
||||
def reader = new BroadcastReader([up, up1, up2], new Selector.EmptyMatcher(), null, new BroadcastQuorum(), Stub(Tracer))
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"]))
|
||||
def act = reader.read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"])))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.expectNextMatches {
|
||||
@@ -61,7 +62,7 @@ class BroadcastReaderSpec extends Specification {
|
||||
1 * isAvailable() >> true
|
||||
_ * getId() >> "id"
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"]))) >>
|
||||
Mono.just(new JsonRpcResponse(result, null))
|
||||
}
|
||||
}
|
||||
@@ -69,7 +70,7 @@ class BroadcastReaderSpec extends Specification {
|
||||
1 * isAvailable() >> true
|
||||
_ * getId() >> "id"
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"]))) >>
|
||||
Mono.error(new JsonRpcException(1, "too low"))
|
||||
}
|
||||
}
|
||||
@@ -77,12 +78,12 @@ class BroadcastReaderSpec extends Specification {
|
||||
1 * isAvailable() >> true
|
||||
_ * getId() >> "id"
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"]))) >>
|
||||
Mono.error(new JsonRpcException(1, "too low")) }
|
||||
}
|
||||
def reader = new BroadcastReader([up, up1, up2], new Selector.EmptyMatcher(), null, new BroadcastQuorum(), Stub(Tracer))
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"]))
|
||||
def act = reader.read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"])))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.expectNextMatches {
|
||||
@@ -99,7 +100,7 @@ class BroadcastReaderSpec extends Specification {
|
||||
1 * isAvailable() >> true
|
||||
_ * getId() >> "id"
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"]))) >>
|
||||
Mono.just(new JsonRpcResponse(result, null))
|
||||
}
|
||||
}
|
||||
@@ -115,7 +116,7 @@ class BroadcastReaderSpec extends Specification {
|
||||
}
|
||||
def reader = new BroadcastReader([up, up1, up2], new Selector.EmptyMatcher(), null, new BroadcastQuorum(), Stub(Tracer))
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"]))
|
||||
def act = reader.read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"])))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.expectNextMatches {
|
||||
@@ -131,7 +132,7 @@ class BroadcastReaderSpec extends Specification {
|
||||
1 * isAvailable() >> true
|
||||
_ * getId() >> "id"
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"]))) >>
|
||||
Mono.error(new JsonRpcException(1, "too low"))
|
||||
}
|
||||
}
|
||||
@@ -139,7 +140,7 @@ class BroadcastReaderSpec extends Specification {
|
||||
1 * isAvailable() >> true
|
||||
_ * getId() >> "id"
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"]))) >>
|
||||
Mono.error(new JsonRpcException(1, "too low"))
|
||||
}
|
||||
}
|
||||
@@ -147,13 +148,13 @@ class BroadcastReaderSpec extends Specification {
|
||||
1 * isAvailable() >> true
|
||||
_ * getId() >> "id"
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"]))) >>
|
||||
Mono.error(new JsonRpcException(1, "too low"))
|
||||
}
|
||||
}
|
||||
def reader = new BroadcastReader([up, up1, up2], new Selector.EmptyMatcher(), null, new BroadcastQuorum(), Stub(Tracer))
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"]))
|
||||
def act = reader.read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"])))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.expectError(JsonRpcException.class)
|
||||
@@ -180,7 +181,7 @@ class BroadcastReaderSpec extends Specification {
|
||||
def reader = new BroadcastReader([up, up1, up2], new Selector.EmptyMatcher(), null, new BroadcastQuorum(), Stub(Tracer))
|
||||
when:
|
||||
def act = reader
|
||||
.read(new JsonRpcRequest("eth_sendRawTransaction", ["0x1"]))
|
||||
.read(new JsonRpcRequest("eth_sendRawTransaction", new ListParams(["0x1"])))
|
||||
.switchIfEmpty(Mono.just(new RpcReader.Result(new byte[0], null, 0, null, null)))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
|
||||
@@ -39,6 +39,7 @@ import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import io.emeraldpay.dshackle.upstream.signature.ResponseSigner
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
@@ -75,7 +76,7 @@ class NativeCallSpec extends Specification {
|
||||
|
||||
def "Tries router first"() {
|
||||
def routedApi = Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_test", [])) >> Mono.just(new JsonRpcResponse("1".bytes, null))
|
||||
1 * read(new JsonRpcRequest("eth_test", new ListParams())) >> Mono.just(new JsonRpcResponse("1".bytes, null))
|
||||
}
|
||||
def upstream = Mock(Multistream) {
|
||||
1 * getLocalReader() >> Mono.just(routedApi)
|
||||
@@ -84,7 +85,7 @@ class NativeCallSpec extends Specification {
|
||||
def nativeCall = nativeCall()
|
||||
def ctx = new NativeCall.ValidCallContext<NativeCall.ParsedCallDetails>(
|
||||
1, null, upstream, Selector.empty, new AlwaysQuorum(),
|
||||
new NativeCall.ParsedCallDetails("eth_test", []), "reqId", 1
|
||||
new NativeCall.ParsedCallDetails("eth_test", new ListParams()), "reqId", 1
|
||||
)
|
||||
|
||||
when:
|
||||
@@ -96,7 +97,7 @@ class NativeCallSpec extends Specification {
|
||||
|
||||
def "Return error if router denied the requests"() {
|
||||
def routedApi = Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_test", [])) >> Mono.error(new RpcException(RpcResponseError.CODE_METHOD_NOT_EXIST, "Test message"))
|
||||
1 * read(new JsonRpcRequest("eth_test", new ListParams())) >> Mono.error(new RpcException(RpcResponseError.CODE_METHOD_NOT_EXIST, "Test message"))
|
||||
}
|
||||
def upstream = Mock(Multistream) {
|
||||
1 * getLocalReader() >> Mono.just(routedApi)
|
||||
@@ -105,7 +106,7 @@ class NativeCallSpec extends Specification {
|
||||
def nativeCall = nativeCall()
|
||||
def ctx = new NativeCall.ValidCallContext<NativeCall.ParsedCallDetails>(
|
||||
15, null, upstream, Selector.empty, new AlwaysQuorum(),
|
||||
new NativeCall.ParsedCallDetails("eth_test", []), "reqId", 1
|
||||
new NativeCall.ParsedCallDetails("eth_test", new ListParams()), "reqId", 1
|
||||
)
|
||||
|
||||
when:
|
||||
@@ -134,7 +135,7 @@ class NativeCallSpec extends Specification {
|
||||
}
|
||||
}
|
||||
def call = new NativeCall.ValidCallContext(1, 10, TestingCommons.multistream(TestingCommons.api()), Selector.empty, quorum,
|
||||
new NativeCall.ParsedCallDetails("eth_test", []), "reqId", 1)
|
||||
new NativeCall.ParsedCallDetails("eth_test", new ListParams()), "reqId", 1)
|
||||
|
||||
when:
|
||||
def resp = nativeCall.executeOnRemote(call).block(Duration.ofSeconds(1))
|
||||
@@ -152,11 +153,11 @@ class NativeCallSpec extends Specification {
|
||||
nativeCall.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * attempts() >> new AtomicInteger(1)
|
||||
1 * read(new JsonRpcRequest("eth_test", [], 10)) >> Mono.empty()
|
||||
1 * read(new JsonRpcRequest("eth_test", new ListParams(), 10)) >> Mono.empty()
|
||||
}
|
||||
}
|
||||
def call = new NativeCall.ValidCallContext(1, 10, TestingCommons.multistream(TestingCommons.api()), Selector.empty, quorum,
|
||||
new NativeCall.ParsedCallDetails("eth_test", []), "reqId", 1)
|
||||
new NativeCall.ParsedCallDetails("eth_test", new ListParams()), "reqId", 1)
|
||||
|
||||
when:
|
||||
def resp = nativeCall.executeOnRemote(call)
|
||||
@@ -176,13 +177,13 @@ class NativeCallSpec extends Specification {
|
||||
def nativeCall = nativeCall()
|
||||
nativeCall.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_test", [], 10)) >> Mono.error(
|
||||
1 * read(new JsonRpcRequest("eth_test", new ListParams(), 10)) >> Mono.error(
|
||||
new JsonRpcException(JsonRpcResponse.Id.from(12), new JsonRpcError(-32123, "Foo Bar", "Foo Bar Baz"), null, true, null)
|
||||
)
|
||||
}
|
||||
}
|
||||
def call = new NativeCall.ValidCallContext(12, 10, TestingCommons.multistream(TestingCommons.api()), Selector.empty, quorum,
|
||||
new NativeCall.ParsedCallDetails("eth_test", []), "reqId", 1)
|
||||
new NativeCall.ParsedCallDetails("eth_test", new ListParams()), "reqId", 1)
|
||||
|
||||
when:
|
||||
def resp = nativeCall.executeOnRemote(call).block(Duration.ofSeconds(1))
|
||||
@@ -536,7 +537,7 @@ class NativeCallSpec extends Specification {
|
||||
def act = nativeCall.parseParams(ctx)
|
||||
then:
|
||||
act.id == 1
|
||||
act.payload.params == []
|
||||
act.payload.params == new ListParams()
|
||||
act.payload.method == "eth_test"
|
||||
}
|
||||
|
||||
@@ -549,7 +550,7 @@ class NativeCallSpec extends Specification {
|
||||
def act = nativeCall.parseParams(ctx)
|
||||
then:
|
||||
act.id == 1
|
||||
act.payload.params == []
|
||||
act.payload.params == new ListParams()
|
||||
act.payload.method == "eth_test"
|
||||
}
|
||||
|
||||
@@ -562,7 +563,7 @@ class NativeCallSpec extends Specification {
|
||||
def act = nativeCall.parseParams(ctx)
|
||||
then:
|
||||
act.id == 1
|
||||
act.payload.params == [false]
|
||||
act.payload.params == new ListParams([false])
|
||||
act.payload.method == "eth_test"
|
||||
}
|
||||
|
||||
@@ -575,7 +576,7 @@ class NativeCallSpec extends Specification {
|
||||
def act = nativeCall.parseParams(ctx)
|
||||
then:
|
||||
act.id == 1
|
||||
act.payload.params == [false, 123]
|
||||
act.payload.params == new ListParams([false, 123])
|
||||
act.payload.method == "eth_test"
|
||||
}
|
||||
|
||||
@@ -589,7 +590,7 @@ class NativeCallSpec extends Specification {
|
||||
def act = nativeCall.parseParams(ctx)
|
||||
then:
|
||||
act.id == 1
|
||||
act.payload.params == ["0xab"]
|
||||
act.payload.params == new ListParams(["0xab"])
|
||||
act.payload.method == "eth_getFilterUpdates"
|
||||
}
|
||||
|
||||
@@ -618,7 +619,7 @@ class NativeCallSpec extends Specification {
|
||||
}
|
||||
}
|
||||
def call = new NativeCall.ValidCallContext(1, 10, multistream, Selector.empty, quorum,
|
||||
new NativeCall.ParsedCallDetails("eth_getFilterChanges", []),
|
||||
new NativeCall.ParsedCallDetails("eth_getFilterChanges", new ListParams()),
|
||||
new NativeCall.WithFilterIdDecorator(), new NativeCall.CreateFilterDecorator(), null, false, "reqId", 1)
|
||||
|
||||
when:
|
||||
@@ -654,7 +655,7 @@ class NativeCallSpec extends Specification {
|
||||
}
|
||||
}
|
||||
def call = new NativeCall.ValidCallContext(1, 10, multistream, Selector.empty, quorum,
|
||||
new NativeCall.ParsedCallDetails("eth_getFilterChanges", []),
|
||||
new NativeCall.ParsedCallDetails("eth_getFilterChanges", new ListParams()),
|
||||
new NativeCall.WithFilterIdDecorator(), new NativeCall.CreateFilterDecorator(), null, false, "reqId", 1)
|
||||
|
||||
when:
|
||||
@@ -676,7 +677,7 @@ class NativeCallSpec extends Specification {
|
||||
def ctx = new NativeCall.ValidCallContext<NativeCall.ParsedCallDetails>(10, null,
|
||||
upstream,
|
||||
Selector.empty, new AlwaysQuorum(),
|
||||
new NativeCall.ParsedCallDetails("eth_test", []), "reqId", 1)
|
||||
new NativeCall.ParsedCallDetails("eth_test", new ListParams()), "reqId", 1)
|
||||
when:
|
||||
nativeCall.fetch(ctx)
|
||||
then:
|
||||
@@ -693,7 +694,7 @@ class NativeCallSpec extends Specification {
|
||||
def ctx = new NativeCall.ValidCallContext<NativeCall.ParsedCallDetails>(10, null,
|
||||
upstream,
|
||||
Selector.empty, new AlwaysQuorum(),
|
||||
new NativeCall.ParsedCallDetails("eth_test", []), "reqId", 1)
|
||||
new NativeCall.ParsedCallDetails("eth_test", new ListParams()), "reqId", 1)
|
||||
when:
|
||||
def act = nativeCall.fetch(ctx)
|
||||
then:
|
||||
|
||||
@@ -81,7 +81,7 @@ class ApiReaderMock implements Reader<JsonRpcRequest, JsonRpcResponse> {
|
||||
@Override
|
||||
Mono<JsonRpcResponse> read(JsonRpcRequest request, boolean required = true) {
|
||||
Callable<JsonRpcResponse> call = {
|
||||
def predefined = predefined.find { it.isSame(request.method, request.params) }
|
||||
def predefined = predefined.find { it.isSame(request.method, request.params.list) }
|
||||
byte[] result = null
|
||||
JsonRpcError error = null
|
||||
calls.incrementAndGet()
|
||||
|
||||
@@ -18,6 +18,7 @@ package io.emeraldpay.dshackle.upstream.bitcoin
|
||||
import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import reactor.test.StepVerifier
|
||||
@@ -78,13 +79,13 @@ class BitcoinRpcHeadSpec extends Specification {
|
||||
"""
|
||||
|
||||
def api = Mock(Reader) {
|
||||
_ * read(new JsonRpcRequest("getbestblockhash", [])) >>> [
|
||||
_ * read(new JsonRpcRequest("getbestblockhash", new ListParams())) >>> [
|
||||
Mono.just(new JsonRpcResponse("\"$hash1\"".bytes, null)),
|
||||
Mono.just(new JsonRpcResponse("\"$hash1\"".bytes, null)),
|
||||
Mono.just(new JsonRpcResponse("\"$hash2\"".bytes, null))
|
||||
]
|
||||
_ * read(new JsonRpcRequest("getblock", [hash1])) >> Mono.just(new JsonRpcResponse(block1.bytes, null))
|
||||
_ * read(new JsonRpcRequest("getblock", [hash2])) >> Mono.just(new JsonRpcResponse(block2.bytes, null))
|
||||
_ * read(new JsonRpcRequest("getblock", new ListParams([hash1]))) >> Mono.just(new JsonRpcResponse(block1.bytes, null))
|
||||
_ * read(new JsonRpcRequest("getblock", new ListParams([hash2]))) >> Mono.just(new JsonRpcResponse(block2.bytes, null))
|
||||
}
|
||||
BitcoinRpcHead head = new BitcoinRpcHead(api, new ExtractBlock(), Duration.ofMillis(200), Schedulers.boundedElastic())
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package io.emeraldpay.dshackle.upstream.bitcoin
|
||||
import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.params.MainNetParams
|
||||
import reactor.core.publisher.Mono
|
||||
@@ -29,7 +30,7 @@ class RpcUnspentReaderSpec extends Specification {
|
||||
setup:
|
||||
def json = this.class.getClassLoader().getResourceAsStream("bitcoin/unspent-one-addr.json").bytes
|
||||
def rpcReader = Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("listunspent", [1, 9999999, ["1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"]])) >> Mono.just(JsonRpcResponse.ok(json))
|
||||
1 * read(new JsonRpcRequest("listunspent", new ListParams([1, 9999999, ["1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"]]))) >> Mono.just(JsonRpcResponse.ok(json))
|
||||
}
|
||||
def upstreams = Mock(BitcoinMultistream) {
|
||||
1 * getDirectApi(_) >> Mono.just(rpcReader)
|
||||
@@ -63,7 +64,7 @@ class RpcUnspentReaderSpec extends Specification {
|
||||
setup:
|
||||
def json = this.class.getClassLoader().getResourceAsStream("bitcoin/unspent-two-addr.json").bytes
|
||||
def rpcReader = Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("listunspent", [1, 9999999, ["35hK24tcLEWcgNA4JxpvbkNkoAcDGqQPsP"]])) >> Mono.just(JsonRpcResponse.ok(json))
|
||||
1 * read(new JsonRpcRequest("listunspent", new ListParams([1, 9999999, ["35hK24tcLEWcgNA4JxpvbkNkoAcDGqQPsP"]]))) >> Mono.just(JsonRpcResponse.ok(json))
|
||||
}
|
||||
def upstreams = Mock(BitcoinMultistream) {
|
||||
1 * getDirectApi(_) >> Mono.just(rpcReader)
|
||||
|
||||
@@ -13,6 +13,7 @@ import io.emeraldpay.dshackle.upstream.*
|
||||
import io.emeraldpay.dshackle.upstream.calls.DefaultEthereumMethods
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId
|
||||
@@ -52,7 +53,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
reader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByHash", [hash1, false])) >> Mono.just(
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByHash", new ListParams([hash1, false]))) >> Mono.just(
|
||||
new RpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, resolver, null)
|
||||
)
|
||||
@@ -79,7 +80,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
reader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByHash", [hash1, false])) >> Mono.just(
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByHash", new ListParams([hash1, false]))) >> Mono.just(
|
||||
new RpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(null), null, 1, resolver, null
|
||||
)
|
||||
@@ -112,7 +113,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
reader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x64", false])) >> Mono.just(
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams(["0x64", false]))) >> Mono.just(
|
||||
new RpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, resolver, null
|
||||
)
|
||||
@@ -144,7 +145,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
reader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getLogs", [Map.of("blockHash", hash1)])) >> Mono.just(
|
||||
1 * read(new JsonRpcRequest("eth_getLogs", new ListParams([Map.of("blockHash", hash1)]))) >> Mono.just(
|
||||
new RpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes([json]), null, 1, resolver, null
|
||||
)
|
||||
@@ -177,7 +178,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
reader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionByHash", [hash1])) >> Mono.just(
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionByHash", new ListParams([hash1]))) >> Mono.just(
|
||||
new RpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, resolver, null
|
||||
)
|
||||
@@ -210,7 +211,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
reader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionReceipt", [hash1])) >> Mono.just(
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionReceipt", new ListParams([hash1]))) >> Mono.just(
|
||||
new RpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, resolver, null
|
||||
)
|
||||
@@ -244,7 +245,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
reader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionReceipt", [hash1])) >> Mono.just(
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionReceipt", new ListParams([hash1]))) >> Mono.just(
|
||||
new RpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, resolver, null
|
||||
)
|
||||
@@ -269,7 +270,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
reader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionByHash", [hash1])) >> Mono.just(
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionByHash", new ListParams([hash1]))) >> Mono.just(
|
||||
new RpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(null), null, 1, resolver, null
|
||||
)
|
||||
@@ -299,7 +300,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
reader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBalance", [address1, "latest"])) >> Mono.just(
|
||||
1 * read(new JsonRpcRequest("eth_getBalance", new ListParams([address1, "latest"]))) >> Mono.just(
|
||||
new RpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes("0x100"), null, 1, resolver, null
|
||||
)
|
||||
@@ -330,7 +331,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
reader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBalance", [address1, "0xa8c9bb"])) >> Mono.just(
|
||||
1 * read(new JsonRpcRequest("eth_getBalance", new ListParams([address1, "0xa8c9bb"]))) >> Mono.just(
|
||||
new RpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes("0x100"), null, 1, resolver, null
|
||||
)
|
||||
@@ -368,11 +369,11 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
ethereumDirectReader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
2 * create(_) >> Mock(RpcReader) {
|
||||
2 * read(new JsonRpcRequest("eth_getBlockByHash", [hash1, false])) >>>
|
||||
2 * read(new JsonRpcRequest("eth_getBlockByHash", new ListParams([hash1, false]))) >>>
|
||||
[Mono.error(new RuntimeException()), Mono.error(new RuntimeException())]
|
||||
}
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByHash", [hash1, false])) >> result
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByHash", new ListParams([hash1, false]))) >> result
|
||||
}
|
||||
}
|
||||
when:
|
||||
@@ -408,11 +409,11 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
ethereumDirectReader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
2 * create(_) >> Mock(RpcReader) {
|
||||
2 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x64", false])) >>>
|
||||
2 * read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams(["0x64", false]))) >>>
|
||||
[Mono.error(new RuntimeException()), Mono.error(new RuntimeException())]
|
||||
}
|
||||
1 * create(_) >> Mock(RpcReader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x64", false])) >> result
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams(["0x64", false]))) >> result
|
||||
}
|
||||
}
|
||||
when:
|
||||
@@ -441,7 +442,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
)
|
||||
reader.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||
4 * create(_) >> Mock(RpcReader) {
|
||||
4 * read(new JsonRpcRequest("eth_getBalance", [address1, "latest"])) >>>
|
||||
4 * read(new JsonRpcRequest("eth_getBalance", new ListParams([address1, "latest"]))) >>>
|
||||
[Mono.error(new RuntimeException()), Mono.error(new RuntimeException()),
|
||||
Mono.error(new RuntimeException()), Mono.error(new RuntimeException())]
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.emeraldpay.dshackle.upstream.DefaultUpstream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.EthereumLabelsDetector
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import kotlin.Pair
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.test.StepVerifier
|
||||
@@ -52,13 +53,13 @@ class EthereumLabelsDetectorSpec extends Specification {
|
||||
setup:
|
||||
def up = Mock(DefaultUpstream) {
|
||||
1 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("web3_clientVersion", [])) >>
|
||||
1 * read(new JsonRpcRequest("web3_clientVersion", new ListParams())) >>
|
||||
Mono.just(new JsonRpcResponse('no/v1.19.3+e8ac1da4/linux-x64/dotnet7.0.8'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", [])) >>
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", new ListParams())) >>
|
||||
Mono.just(new JsonRpcResponse("\"0x10df3e5\"".getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBalance", ["0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", "0x10dccd5"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_getBalance", new ListParams(["0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", "0x10dccd5"]))) >>
|
||||
Mono.error(new RuntimeException())
|
||||
1 * read(new JsonRpcRequest("eth_getBalance", ["0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", "0x2710"])) >>
|
||||
1 * read(new JsonRpcRequest("eth_getBalance", new ListParams(["0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", "0x2710"]))) >>
|
||||
Mono.just(new JsonRpcResponse("".getBytes(), null))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.emeraldpay.dshackle.upstream.EmptyHead
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.dshackle.upstream.calls.DefaultEthereumMethods
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import org.apache.commons.collections4.functors.ConstantFactory
|
||||
import reactor.core.publisher.Mono
|
||||
@@ -34,7 +35,7 @@ class EthereumLocalReaderSpec extends Specification {
|
||||
null
|
||||
)
|
||||
when:
|
||||
def act = router.read(new JsonRpcRequest("eth_coinbase", [])).block(Duration.ofSeconds(1))
|
||||
def act = router.read(new JsonRpcRequest("eth_coinbase", new ListParams())).block(Duration.ofSeconds(1))
|
||||
then:
|
||||
act.resultAsProcessedString == "0x0000000000000000000000000000000000000000"
|
||||
}
|
||||
@@ -54,7 +55,7 @@ class EthereumLocalReaderSpec extends Specification {
|
||||
null
|
||||
)
|
||||
when:
|
||||
def act = router.read(new JsonRpcRequest("eth_getTransactionByHash", ["test"], 10))
|
||||
def act = router.read(new JsonRpcRequest("eth_getTransactionByHash", new ListParams(["test"]), 10))
|
||||
.block(Duration.ofSeconds(1))
|
||||
then:
|
||||
act == null
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
|
||||
@@ -41,7 +42,6 @@ import static io.emeraldpay.dshackle.upstream.UpstreamAvailability.*
|
||||
import static io.emeraldpay.dshackle.upstream.ValidateUpstreamSettingsResult.UPSTREAM_FATAL_SETTINGS_ERROR
|
||||
import static io.emeraldpay.dshackle.upstream.ValidateUpstreamSettingsResult.UPSTREAM_SETTINGS_ERROR
|
||||
import static io.emeraldpay.dshackle.upstream.ValidateUpstreamSettingsResult.UPSTREAM_VALID
|
||||
import static java.util.Collections.emptyList
|
||||
import io.emeraldpay.dshackle.config.ChainsConfig.ChainConfig
|
||||
|
||||
class EthereumUpstreamValidatorSpec extends Specification {
|
||||
@@ -280,8 +280,8 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
def up = Mock(Upstream) {
|
||||
2 * getIngressReader() >>
|
||||
Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", [])) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x10fd2ae", false])) >>
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", new ListParams())) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams(["0x10fd2ae", false]))) >>
|
||||
Mono.just(new JsonRpcResponse('"result"'.getBytes(), null))
|
||||
}
|
||||
}
|
||||
@@ -300,12 +300,12 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
}.buildOptions()
|
||||
def up = Mock(Upstream) {
|
||||
3 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_call", [new TransactionCallJson(
|
||||
1 * read(new JsonRpcRequest("eth_call", new ListParams([new TransactionCallJson(
|
||||
Address.from("0x32268860cAAc2948Ab5DdC7b20db5a420467Cf96"),
|
||||
HexData.from("0xd8a26e3a00000000000000000000000000000000000000000000000000000000000f4240")
|
||||
), "latest"])) >> Mono.just(new JsonRpcResponse("0x00000000000000000000".getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", [])) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x10fd2ae", false])) >>
|
||||
), "latest"]))) >> Mono.just(new JsonRpcResponse("0x00000000000000000000".getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", new ListParams())) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams(["0x10fd2ae", false]))) >>
|
||||
Mono.just(new JsonRpcResponse('"result"'.getBytes(), null))
|
||||
}
|
||||
}
|
||||
@@ -324,12 +324,12 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
}.buildOptions()
|
||||
def up = Mock(Upstream) {
|
||||
3 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_call", [new TransactionCallJson(
|
||||
1 * read(new JsonRpcRequest("eth_call", new ListParams([new TransactionCallJson(
|
||||
Address.from("0x32268860cAAc2948Ab5DdC7b20db5a420467Cf96"),
|
||||
HexData.from("0xd8a26e3a00000000000000000000000000000000000000000000000000000000000f4240")
|
||||
), "latest"])) >> Mono.just(new JsonRpcResponse(null, new JsonRpcError(1, "Too long")))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", [])) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x10fd2ae", false])) >>
|
||||
), "latest"]))) >> Mono.just(new JsonRpcResponse(null, new JsonRpcError(1, "Too long")))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", new ListParams())) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams(["0x10fd2ae", false]))) >>
|
||||
Mono.just(new JsonRpcResponse('"result"'.getBytes(), null))
|
||||
}
|
||||
}
|
||||
@@ -348,10 +348,10 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
}.buildOptions()
|
||||
def up = Mock(Upstream) {
|
||||
4 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_chainId", emptyList())) >> Mono.just(new JsonRpcResponse('"0x1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("net_version", emptyList())) >> Mono.just(new JsonRpcResponse('"1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", [])) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x10fd2ae", false])) >>
|
||||
1 * read(new JsonRpcRequest("eth_chainId", new ListParams())) >> Mono.just(new JsonRpcResponse('"0x1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("net_version", new ListParams())) >> Mono.just(new JsonRpcResponse('"1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", new ListParams())) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams(["0x10fd2ae", false]))) >>
|
||||
Mono.just(new JsonRpcResponse('"result"'.getBytes(), null))
|
||||
}
|
||||
}
|
||||
@@ -370,10 +370,10 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
}.buildOptions()
|
||||
def up = Mock(Upstream) {
|
||||
4 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_chainId", emptyList())) >> Mono.just(new JsonRpcResponse('"0x1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("net_version", emptyList())) >> Mono.just(new JsonRpcResponse('"1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", [])) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x10fd2ae", false])) >>
|
||||
1 * read(new JsonRpcRequest("eth_chainId", new ListParams())) >> Mono.just(new JsonRpcResponse('"0x1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("net_version", new ListParams())) >> Mono.just(new JsonRpcResponse('"1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", new ListParams())) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams(["0x10fd2ae", false]))) >>
|
||||
Mono.just(new JsonRpcResponse('"result"'.getBytes(), null))
|
||||
}
|
||||
}
|
||||
@@ -390,14 +390,14 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
def options = ChainOptions.PartialOptions.getDefaults().buildOptions()
|
||||
def up = Mock(Upstream) {
|
||||
5 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_chainId", emptyList())) >> Mono.just(new JsonRpcResponse('"0x1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("net_version", emptyList())) >> Mono.just(new JsonRpcResponse('"1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_call", [new TransactionCallJson(
|
||||
1 * read(new JsonRpcRequest("eth_chainId", new ListParams())) >> Mono.just(new JsonRpcResponse('"0x1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("net_version", new ListParams())) >> Mono.just(new JsonRpcResponse('"1"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_call", new ListParams([new TransactionCallJson(
|
||||
Address.from("0x32268860cAAc2948Ab5DdC7b20db5a420467Cf96"),
|
||||
HexData.from("0xd8a26e3a00000000000000000000000000000000000000000000000000000000000f4240")
|
||||
), "latest"])) >> Mono.just(new JsonRpcResponse("0x00000000000000000000".getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", [])) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x10fd2ae", false])) >>
|
||||
), "latest"]))) >> Mono.just(new JsonRpcResponse("0x00000000000000000000".getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", new ListParams())) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams(["0x10fd2ae", false]))) >>
|
||||
Mono.just(new JsonRpcResponse('"result"'.getBytes(), null))
|
||||
}
|
||||
}
|
||||
@@ -414,14 +414,14 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
def options = ChainOptions.PartialOptions.getDefaults().buildOptions()
|
||||
def up = Mock(Upstream) {
|
||||
5 * getIngressReader() >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_chainId", emptyList())) >> Mono.just(new JsonRpcResponse(null, new JsonRpcError(1, "Too long")))
|
||||
1 * read(new JsonRpcRequest("net_version", emptyList())) >> Mono.just(new JsonRpcResponse(null, new JsonRpcError(1, "Too long")))
|
||||
1 * read(new JsonRpcRequest("eth_call", [new TransactionCallJson(
|
||||
1 * read(new JsonRpcRequest("eth_chainId", new ListParams())) >> Mono.just(new JsonRpcResponse(null, new JsonRpcError(1, "Too long")))
|
||||
1 * read(new JsonRpcRequest("net_version", new ListParams())) >> Mono.just(new JsonRpcResponse(null, new JsonRpcError(1, "Too long")))
|
||||
1 * read(new JsonRpcRequest("eth_call", new ListParams([new TransactionCallJson(
|
||||
Address.from("0x32268860cAAc2948Ab5DdC7b20db5a420467Cf96"),
|
||||
HexData.from("0xd8a26e3a00000000000000000000000000000000000000000000000000000000000f4240")
|
||||
), "latest"])) >> Mono.just(new JsonRpcResponse(null, new JsonRpcError(1, "Too long")))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", [])) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x10fd2ae", false])) >>
|
||||
), "latest"]))) >> Mono.just(new JsonRpcResponse(null, new JsonRpcError(1, "Too long")))
|
||||
1 * read(new JsonRpcRequest("eth_blockNumber", new ListParams())) >> Mono.just(new JsonRpcResponse('"0x10ff9be"'.getBytes(), null))
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams(["0x10fd2ae", false]))) >>
|
||||
Mono.just(new JsonRpcResponse('"result"'.getBytes(), null))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.forkchoice.AlwaysForkChoice
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionRefJson
|
||||
import reactor.core.publisher.Flux
|
||||
@@ -61,7 +62,7 @@ class GenericWsHeadSpec extends Specification {
|
||||
}
|
||||
|
||||
def reader = Mock(Reader) {
|
||||
1 * it.read(new JsonRpcRequest("eth_getBlockByNumber", List.of("latest", false))) >> Mono.empty()
|
||||
1 * it.read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams("latest", false))) >> Mono.empty()
|
||||
}
|
||||
|
||||
def ws = Mock(WsSubscriptions) {
|
||||
@@ -338,7 +339,7 @@ class GenericWsHeadSpec extends Specification {
|
||||
block.totalDifficulty = BigInteger.ONE
|
||||
|
||||
def reader = Mock(Reader) {
|
||||
1 * it.read(new JsonRpcRequest("eth_getBlockByNumber", List.of("latest", false))) >> Mono.empty()
|
||||
1 * it.read(new JsonRpcRequest("eth_getBlockByNumber", new ListParams("latest", false))) >> Mono.empty()
|
||||
}
|
||||
def subId = "subId"
|
||||
def ws = Mock(WsSubscriptions) {
|
||||
@@ -346,7 +347,7 @@ class GenericWsHeadSpec extends Specification {
|
||||
1 * it.subscribe(_) >> new WsSubscriptions.SubscribeData(
|
||||
Flux.error(new RuntimeException()), "id", new AtomicReference<String>(subId)
|
||||
)
|
||||
1 * it.unsubscribe(new JsonRpcRequest("eth_unsubscribe", List.of(subId), 2, null, null, false)) >>
|
||||
1 * it.unsubscribe(new JsonRpcRequest("eth_unsubscribe", new ListParams(subId), 2, null, null, false)) >>
|
||||
Mono.just(new JsonRpcResponse("".bytes, null))
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.emeraldpay.dshackle.test.MockWSServer
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.DefaultUpstream
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import reactor.test.StepVerifier
|
||||
import spock.lang.Shared
|
||||
@@ -55,7 +56,7 @@ class WsConnectionImplRealSpec extends Specification {
|
||||
def "Can make a RPC request"() {
|
||||
when:
|
||||
conn.connect()
|
||||
def resp = conn.callRpc(new JsonRpcRequest("foo_bar", []))
|
||||
def resp = conn.callRpc(new JsonRpcRequest("foo_bar", new ListParams()))
|
||||
then:
|
||||
StepVerifier.create(resp)
|
||||
.then {
|
||||
@@ -87,7 +88,7 @@ class WsConnectionImplRealSpec extends Specification {
|
||||
server.onNextReply('{"jsonrpc":"2.0","id":100,"result":1}')
|
||||
// reconnects in 2 seconds, give 1 extra
|
||||
Thread.sleep(3_000)
|
||||
def resp = conn.callRpc(new JsonRpcRequest("foo_bar", [])).block(Duration.ofSeconds(1))
|
||||
def resp = conn.callRpc(new JsonRpcRequest("foo_bar", new ListParams())).block(Duration.ofSeconds(1))
|
||||
def act = server.received
|
||||
|
||||
then:
|
||||
@@ -100,7 +101,7 @@ class WsConnectionImplRealSpec extends Specification {
|
||||
conn.connect()
|
||||
conn.reconnectIntervalSeconds = 2
|
||||
|
||||
def resp = conn.callRpc(new JsonRpcRequest("foo_bar", []))
|
||||
def resp = conn.callRpc(new JsonRpcRequest("foo_bar", new ListParams()))
|
||||
|
||||
then:
|
||||
StepVerifier.create(resp)
|
||||
@@ -121,7 +122,7 @@ class WsConnectionImplRealSpec extends Specification {
|
||||
server.onNextReply('{"jsonrpc":"2.0","id":100,"result":1}')
|
||||
Thread.sleep(3_000)
|
||||
|
||||
def resp = conn.callRpc(new JsonRpcRequest("foo_bar", [])).block(Duration.ofSeconds(1))
|
||||
def resp = conn.callRpc(new JsonRpcRequest("foo_bar", new ListParams())).block(Duration.ofSeconds(1))
|
||||
def act = server.received
|
||||
then:
|
||||
act.size() == 1
|
||||
@@ -140,7 +141,7 @@ class WsConnectionImplRealSpec extends Specification {
|
||||
// reconnects in 2 seconds, give 1 extra
|
||||
Thread.sleep(3_000)
|
||||
|
||||
def resp = conn.callRpc(new JsonRpcRequest("foo_bar", []))
|
||||
def resp = conn.callRpc(new JsonRpcRequest("foo_bar", new ListParams()))
|
||||
then:
|
||||
StepVerifier.create(resp)
|
||||
.then {
|
||||
|
||||
@@ -21,6 +21,7 @@ import io.emeraldpay.dshackle.test.GenericUpstreamMock
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.DefaultUpstream
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionJson
|
||||
@@ -58,7 +59,7 @@ class WsConnectionImplSpec extends Specification {
|
||||
|
||||
when:
|
||||
Flux.from(ws.handle(wsApiMock.inbound, wsApiMock.outbound)).subscribe()
|
||||
def act = ws.callRpc(new JsonRpcRequest("eth_getTransactionByHash", ["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"], 15, null, null, false))
|
||||
def act = ws.callRpc(new JsonRpcRequest("eth_getTransactionByHash", new ListParams(["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"]), 15, null, null, false))
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
@@ -90,7 +91,7 @@ class WsConnectionImplSpec extends Specification {
|
||||
|
||||
when:
|
||||
Flux.from(ws.handle(wsApiMock.inbound, wsApiMock.outbound)).subscribe()
|
||||
def act = ws.callRpc(new JsonRpcRequest("eth_getTransactionByHash", ["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"], 15, null, null, false))
|
||||
def act = ws.callRpc(new JsonRpcRequest("eth_getTransactionByHash", new ListParams(["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"]), 15, null, null, false))
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
@@ -124,7 +125,7 @@ class WsConnectionImplSpec extends Specification {
|
||||
|
||||
when:
|
||||
Flux.from(ws.handle(wsApiMock.inbound, wsApiMock.outbound)).subscribe()
|
||||
def act = ws.callRpc(new JsonRpcRequest("eth_getTransactionByHash", ["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"], 15, null, null, false))
|
||||
def act = ws.callRpc(new JsonRpcRequest("eth_getTransactionByHash", new ListParams(["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"]), 15, null, null, false))
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
|
||||
@@ -18,6 +18,7 @@ package io.emeraldpay.dshackle.upstream.ethereum
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcWsMessage
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
import spock.lang.Specification
|
||||
@@ -45,7 +46,7 @@ class WsSubscriptionsImplSpec extends Specification {
|
||||
def ws = new WsSubscriptionsImpl(pool)
|
||||
|
||||
when:
|
||||
def act = ws.subscribe(new JsonRpcRequest("eth_subscribe", ["foo_bar"]))
|
||||
def act = ws.subscribe(new JsonRpcRequest("eth_subscribe", new ListParams(["foo_bar"])))
|
||||
.data
|
||||
.map { new String(it) }
|
||||
.take(3)
|
||||
@@ -55,7 +56,7 @@ class WsSubscriptionsImplSpec extends Specification {
|
||||
act == ["100", "101", "102"]
|
||||
|
||||
1 * conn.callRpc({ JsonRpcRequest req ->
|
||||
req.method == "eth_subscribe" && req.params == ["foo_bar"]
|
||||
req.method == "eth_subscribe" && req.params == new ListParams(["foo_bar"])
|
||||
}) >> Mono.just(new JsonRpcResponse('"0xcff45d00e7"'.bytes, null))
|
||||
1 * conn.getSubscribeResponses() >> answers
|
||||
}
|
||||
@@ -83,7 +84,7 @@ class WsSubscriptionsImplSpec extends Specification {
|
||||
def ws = new WsSubscriptionsImpl(pool)
|
||||
|
||||
when:
|
||||
def act = ws.subscribe(new JsonRpcRequest("eth_subscribe", ["foo_bar"]))
|
||||
def act = ws.subscribe(new JsonRpcRequest("eth_subscribe", new ListParams(["foo_bar"])))
|
||||
.data
|
||||
.map { new String(it) }
|
||||
.take(3)
|
||||
@@ -93,7 +94,7 @@ class WsSubscriptionsImplSpec extends Specification {
|
||||
act == ["100", "101", "102"]
|
||||
|
||||
1 * conn.callRpc({ JsonRpcRequest req ->
|
||||
req.method == "eth_subscribe" && req.params == ["foo_bar"]
|
||||
req.method == "eth_subscribe" && req.params == new ListParams(["foo_bar"])
|
||||
}) >> Mono.just(new JsonRpcResponse('"0xcff45d00e7"'.bytes, null))
|
||||
1 * conn.getSubscribeResponses() >> answers
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.subscribe
|
||||
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.WsSubscriptions
|
||||
import reactor.core.publisher.Flux
|
||||
@@ -42,7 +43,7 @@ class WebsocketPendingTxesSpec extends Specification {
|
||||
.collectList().block(Duration.ofSeconds(1))
|
||||
|
||||
then:
|
||||
1 * ws.subscribe(new JsonRpcRequest("eth_subscribe", ["newPendingTransactions"])) >> new WsSubscriptions.SubscribeData(
|
||||
1 * ws.subscribe(new JsonRpcRequest("eth_subscribe", new ListParams(["newPendingTransactions"]))) >> new WsSubscriptions.SubscribeData(
|
||||
Flux.fromIterable(responses), "id", new AtomicReference<String>("")
|
||||
)
|
||||
txes.collect {it.toHex() } == [
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.emeraldpay.dshackle.Chain
|
||||
import io.emeraldpay.dshackle.test.MockGrpcServer
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import io.grpc.stub.StreamObserver
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -39,7 +40,7 @@ class JsonRpcGrpcClientSpec extends Specification {
|
||||
|
||||
when:
|
||||
def act = client.read(
|
||||
new JsonRpcRequest("test", [])
|
||||
new JsonRpcRequest("test", new ListParams())
|
||||
).block(Duration.ofSeconds(1))
|
||||
|
||||
then:
|
||||
@@ -73,7 +74,7 @@ class JsonRpcGrpcClientSpec extends Specification {
|
||||
|
||||
when:
|
||||
client.read(
|
||||
new JsonRpcRequest("test", [])
|
||||
new JsonRpcRequest("test", new ListParams())
|
||||
).block(Duration.ofSeconds(1))
|
||||
|
||||
then:
|
||||
|
||||
@@ -18,6 +18,7 @@ package io.emeraldpay.dshackle.upstream.rpcclient
|
||||
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import io.micrometer.core.instrument.Counter
|
||||
import io.micrometer.core.instrument.Timer
|
||||
import org.mockserver.integration.ClientAndServer
|
||||
@@ -61,7 +62,7 @@ class JsonRpcHttpClientSpec extends Specification {
|
||||
HttpResponse.response(resp)
|
||||
)
|
||||
when:
|
||||
def act = client.read(new JsonRpcRequest("test", [])).block()
|
||||
def act = client.read(new JsonRpcRequest("test", new ListParams())).block()
|
||||
then:
|
||||
act.error == null
|
||||
new String(act.result) == '"0x98de45"'
|
||||
@@ -80,7 +81,7 @@ class JsonRpcHttpClientSpec extends Specification {
|
||||
)
|
||||
when:
|
||||
def act = client.read(
|
||||
new JsonRpcRequest("ping", [])
|
||||
new JsonRpcRequest("ping", new ListParams())
|
||||
).block(Duration.ofSeconds(1))
|
||||
then:
|
||||
def t = thrown(RuntimeException) // reactor.core.Exceptions$ReactiveException
|
||||
@@ -108,7 +109,7 @@ class JsonRpcHttpClientSpec extends Specification {
|
||||
)
|
||||
when:
|
||||
def act = client.read(
|
||||
new JsonRpcRequest("ping", [])
|
||||
new JsonRpcRequest("ping", new ListParams())
|
||||
).block(Duration.ofSeconds(1))
|
||||
then:
|
||||
def t = thrown(RuntimeException) // reactor.core.Exceptions$ReactiveException
|
||||
|
||||
@@ -17,12 +17,13 @@ package io.emeraldpay.dshackle.upstream.rpcclient
|
||||
|
||||
|
||||
import spock.lang.Specification
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
|
||||
class JsonRpcRequestSpec extends Specification {
|
||||
|
||||
def "Serialize empty params"() {
|
||||
setup:
|
||||
def req = new JsonRpcRequest("test_foo", [])
|
||||
def req = new JsonRpcRequest("test_foo", new ListParams())
|
||||
when:
|
||||
def act = req.toJson()
|
||||
then:
|
||||
@@ -31,7 +32,7 @@ class JsonRpcRequestSpec extends Specification {
|
||||
|
||||
def "Serialize single param"() {
|
||||
setup:
|
||||
def req = new JsonRpcRequest("test_foo", ["0x0000"])
|
||||
def req = new JsonRpcRequest("test_foo", new ListParams(["0x0000"]))
|
||||
when:
|
||||
def act = req.toJson()
|
||||
then:
|
||||
@@ -40,7 +41,7 @@ class JsonRpcRequestSpec extends Specification {
|
||||
|
||||
def "Serialize two params"() {
|
||||
setup:
|
||||
def req = new JsonRpcRequest("test_foo", ["0x0000", false])
|
||||
def req = new JsonRpcRequest("test_foo", new ListParams(["0x0000", false]))
|
||||
when:
|
||||
def act = req.toJson()
|
||||
then:
|
||||
@@ -49,8 +50,8 @@ class JsonRpcRequestSpec extends Specification {
|
||||
|
||||
def "Same requests are equal"() {
|
||||
setup:
|
||||
def req1 = new JsonRpcRequest("test_foo", ["0x0000", false])
|
||||
def req2 = new JsonRpcRequest("test_foo", ["0x0000", false])
|
||||
def req1 = new JsonRpcRequest("test_foo", new ListParams(["0x0000", false]))
|
||||
def req2 = new JsonRpcRequest("test_foo", new ListParams(["0x0000", false]))
|
||||
when:
|
||||
def act = req1.equals(req2)
|
||||
then:
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.emeraldpay.dshackle.upstream.rpcclient
|
||||
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.WsConnection
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.WsConnectionPool
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import reactor.core.Exceptions
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -17,7 +18,7 @@ class JsonRpcWsClientSpec extends Specification {
|
||||
}
|
||||
def client = new JsonRpcWsClient(pool)
|
||||
when:
|
||||
client.read(new JsonRpcRequest("foo_bar", [], 1))
|
||||
client.read(new JsonRpcRequest("foo_bar", new ListParams([]), 1))
|
||||
.block(Duration.ofSeconds(1))
|
||||
then:
|
||||
def t = thrown(Exceptions.ReactiveException)
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.emeraldpay.dshackle.upstream.ethereum.EthereumLowerBoundBlockDetector
|
||||
import io.emeraldpay.dshackle.upstream.polkadot.PolkadotLowerBoundBlockDetector
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.Arguments
|
||||
@@ -87,11 +88,11 @@ class RecursiveLowerBoundBlockDetectorTest {
|
||||
blocks.forEach {
|
||||
if (it == 17964844L) {
|
||||
on {
|
||||
read(JsonRpcRequest("eth_getBalance", listOf("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", it.toHex())))
|
||||
read(JsonRpcRequest("eth_getBalance", ListParams("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", it.toHex())))
|
||||
} doReturn Mono.just(JsonRpcResponse(ByteArray(0), null))
|
||||
} else {
|
||||
on {
|
||||
read(JsonRpcRequest("eth_getBalance", listOf("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", it.toHex())))
|
||||
read(JsonRpcRequest("eth_getBalance", ListParams("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", it.toHex())))
|
||||
} doReturn Mono.error(RuntimeException("missing trie node"))
|
||||
}
|
||||
}
|
||||
@@ -103,17 +104,17 @@ class RecursiveLowerBoundBlockDetectorTest {
|
||||
blocks.forEach {
|
||||
if (it == 17964844L) {
|
||||
on {
|
||||
read(JsonRpcRequest("chain_getBlockHash", listOf(it.toHex())))
|
||||
read(JsonRpcRequest("chain_getBlockHash", ListParams(it.toHex())))
|
||||
} doReturn Mono.just(JsonRpcResponse("\"$hash1\"".toByteArray(), null))
|
||||
on {
|
||||
read(JsonRpcRequest("state_getMetadata", listOf(hash1)))
|
||||
read(JsonRpcRequest("state_getMetadata", ListParams(hash1)))
|
||||
} doReturn Mono.just(JsonRpcResponse(ByteArray(0), null))
|
||||
} else {
|
||||
on {
|
||||
read(JsonRpcRequest("chain_getBlockHash", listOf(it.toHex())))
|
||||
read(JsonRpcRequest("chain_getBlockHash", ListParams(it.toHex())))
|
||||
} doReturn Mono.just(JsonRpcResponse("\"$hash2\"".toByteArray(), null))
|
||||
on {
|
||||
read(JsonRpcRequest("state_getMetadata", listOf(hash2)))
|
||||
read(JsonRpcRequest("state_getMetadata", ListParams(hash2)))
|
||||
} doReturn Mono.error(RuntimeException("State already discarded for"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.emeraldpay.dshackle.reader.JsonRpcReader
|
||||
import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.kotlin.doReturn
|
||||
@@ -19,13 +20,13 @@ class SolanaLowerBoundBlockDetectorTest {
|
||||
@Test
|
||||
fun `get solana lower block and slot`() {
|
||||
val reader = mock<JsonRpcReader> {
|
||||
on { read(JsonRpcRequest("getFirstAvailableBlock", listOf())) } doReturn
|
||||
on { read(JsonRpcRequest("getFirstAvailableBlock", ListParams())) } doReturn
|
||||
Mono.just(JsonRpcResponse("25000000".toByteArray(), null))
|
||||
on {
|
||||
read(
|
||||
JsonRpcRequest(
|
||||
"getBlock",
|
||||
listOf(
|
||||
ListParams(
|
||||
25000000L,
|
||||
mapOf(
|
||||
"showRewards" to false,
|
||||
|
||||
Reference in New Issue
Block a user