Add SpanReader wrapper for creating additional spans (#155)
This commit is contained in:
@@ -26,6 +26,7 @@ import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import org.springframework.cloud.sleuth.Tracer
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.test.StepVerifier
|
||||
import spock.lang.Specification
|
||||
@@ -47,7 +48,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
Chain.ETHEREUM,
|
||||
[up], Selector.empty
|
||||
)
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum())
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
@@ -78,7 +79,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
Chain.ETHEREUM,
|
||||
[up], Selector.empty
|
||||
)
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum())
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
@@ -115,7 +116,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
Chain.ETHEREUM,
|
||||
[up], Selector.empty
|
||||
)
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum())
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
@@ -147,7 +148,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
Chain.ETHEREUM,
|
||||
[up], Selector.empty
|
||||
)
|
||||
def reader = new QuorumRpcReader(apis, new NonEmptyQuorum(3))
|
||||
def reader = new QuorumRpcReader(apis, new NonEmptyQuorum(3), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
@@ -179,7 +180,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
Chain.ETHEREUM,
|
||||
[up], Selector.empty
|
||||
)
|
||||
def reader = new QuorumRpcReader(apis, new NonEmptyQuorum(3))
|
||||
def reader = new QuorumRpcReader(apis, new NonEmptyQuorum(3), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
@@ -211,7 +212,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
Chain.ETHEREUM,
|
||||
[up], Selector.empty
|
||||
)
|
||||
def reader = new QuorumRpcReader(apis, new NonEmptyQuorum(3))
|
||||
def reader = new QuorumRpcReader(apis, new NonEmptyQuorum(3), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
@@ -244,7 +245,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
Chain.ETHEREUM,
|
||||
[up], Selector.empty
|
||||
)
|
||||
def reader = new QuorumRpcReader(apis, new NonEmptyQuorum(3))
|
||||
def reader = new QuorumRpcReader(apis, new NonEmptyQuorum(3), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
@@ -274,7 +275,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
Chain.ETHEREUM,
|
||||
[up], Selector.empty
|
||||
)
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum())
|
||||
def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
@@ -307,7 +308,7 @@ class QuorumRpcReaderSpec extends Specification {
|
||||
Chain.ETHEREUM,
|
||||
[up], Selector.empty
|
||||
)
|
||||
def reader = new QuorumRpcReader(apis, new NotLaggingQuorum(1))
|
||||
def reader = new QuorumRpcReader(apis, new NotLaggingQuorum(1), Stub(Tracer))
|
||||
|
||||
when:
|
||||
def act = reader.read(new JsonRpcRequest("eth_test", []))
|
||||
|
||||
@@ -131,7 +131,7 @@ class NativeCallSpec extends Specification {
|
||||
|
||||
def nativeCall = nativeCall()
|
||||
nativeCall.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(_) >> Mono.just(new QuorumRpcReader.Result("\"foo\"".bytes, null, 1, Collections.singletonList(ups), null))
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ class NativeCallSpec extends Specification {
|
||||
|
||||
def nativeCall = nativeCall()
|
||||
nativeCall.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_test", [], 10)) >> Mono.empty()
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ class NativeCallSpec extends Specification {
|
||||
|
||||
def nativeCall = nativeCall()
|
||||
nativeCall.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_test", [], 10)) >> Mono.error(
|
||||
new JsonRpcException(JsonRpcResponse.Id.from(12), new JsonRpcError(-32123, "Foo Bar", "Foo Bar Baz"), true)
|
||||
)
|
||||
@@ -613,7 +613,7 @@ class NativeCallSpec extends Specification {
|
||||
}
|
||||
def nativeCall = nativeCall(multistreamHolder)
|
||||
nativeCall.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(_) >> Mono.just(new QuorumRpcReader.Result("\"0xab\"".bytes, null, 1, Collections.singletonList(ups), null))
|
||||
}
|
||||
}
|
||||
@@ -648,7 +648,7 @@ class NativeCallSpec extends Specification {
|
||||
}
|
||||
def nativeCall = nativeCall(multistreamHolder)
|
||||
nativeCall.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(_) >> Mono.just(new QuorumRpcReader.Result("\"0xab\"".bytes, null, 1, Collections.singletonList(ups), null))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,7 @@ package io.emeraldpay.dshackle.test
|
||||
import io.emeraldpay.dshackle.BlockchainType
|
||||
import io.emeraldpay.dshackle.Chain
|
||||
import io.emeraldpay.dshackle.cache.Caches
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.dshackle.upstream.Multistream
|
||||
import io.emeraldpay.dshackle.upstream.MultistreamHolder
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.*
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinMultistream
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinRpcUpstream
|
||||
import io.emeraldpay.dshackle.upstream.calls.CallMethods
|
||||
@@ -32,6 +28,8 @@ import io.emeraldpay.dshackle.upstream.ethereum.EthereumCachingReader
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosRpcUpstream
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.springframework.cloud.sleuth.Tracer
|
||||
import org.springframework.cloud.sleuth.brave.bridge.BraveTracer
|
||||
import reactor.core.scheduler.Schedulers
|
||||
|
||||
class MultistreamHolderMock implements MultistreamHolder {
|
||||
@@ -49,7 +47,10 @@ class MultistreamHolderMock implements MultistreamHolder {
|
||||
if (up instanceof EthereumPosMultiStream) {
|
||||
upstreams[chain] = up
|
||||
} else if (up instanceof EthereumPosRpcUpstream) {
|
||||
upstreams[chain] = new EthereumPosMultiStream(chain, [up as EthereumPosRpcUpstream], Caches.default(), Schedulers.boundedElastic())
|
||||
upstreams[chain] = new EthereumPosMultiStream(
|
||||
chain, [up as EthereumPosRpcUpstream], Caches.default(),
|
||||
Schedulers.boundedElastic(), TestingCommons.tracerMock()
|
||||
)
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported upstream type ${up.class}")
|
||||
}
|
||||
@@ -97,7 +98,7 @@ class MultistreamHolderMock implements MultistreamHolder {
|
||||
Head customHead = null
|
||||
|
||||
EthereumMultistreamMock(@NotNull Chain chain, @NotNull List<EthereumPosRpcUpstream> upstreams, @NotNull Caches caches) {
|
||||
super(chain, upstreams, caches, Schedulers.boundedElastic())
|
||||
super(chain, upstreams, caches, Schedulers.boundedElastic(), new BraveTracer(null, null, null))
|
||||
}
|
||||
|
||||
EthereumMultistreamMock(@NotNull Chain chain, @NotNull List<EthereumPosRpcUpstream> upstreams) {
|
||||
|
||||
@@ -47,6 +47,10 @@ class TestingCommons {
|
||||
return new ApiReaderMock()
|
||||
}
|
||||
|
||||
static TracerMock tracerMock() {
|
||||
return new TracerMock(null, null, null)
|
||||
}
|
||||
|
||||
static EthereumPosRpcUpstreamMock upstream() {
|
||||
return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api())
|
||||
}
|
||||
@@ -84,7 +88,7 @@ class TestingCommons {
|
||||
}
|
||||
|
||||
static Multistream multistream(EthereumPosRpcUpstreamMock up) {
|
||||
return new EthereumPosMultiStream(Chain.ETHEREUM, [up], Caches.default(), Schedulers.boundedElastic()).tap {
|
||||
return new EthereumPosMultiStream(Chain.ETHEREUM, [up], Caches.default(), Schedulers.boundedElastic(), tracerMock()).tap {
|
||||
start()
|
||||
}
|
||||
}
|
||||
@@ -105,11 +109,11 @@ class TestingCommons {
|
||||
}
|
||||
|
||||
static Multistream multistreamWithoutUpstreams(Chain chain) {
|
||||
return new EthereumPosMultiStream(chain, [], emptyCaches().getCaches(chain), Schedulers.boundedElastic())
|
||||
return new EthereumPosMultiStream(chain, [], emptyCaches().getCaches(chain), Schedulers.boundedElastic(), tracerMock())
|
||||
}
|
||||
|
||||
static Multistream multistreamClassicWithoutUpstreams(Chain chain) {
|
||||
return new EthereumMultistream(chain, [], emptyCaches().getCaches(chain), Schedulers.boundedElastic())
|
||||
return new EthereumMultistream(chain, [], emptyCaches().getCaches(chain), Schedulers.boundedElastic(), tracerMock())
|
||||
}
|
||||
|
||||
static FileResolver fileResolver() {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package io.emeraldpay.dshackle.test
|
||||
|
||||
import brave.Tracer
|
||||
import org.springframework.cloud.sleuth.CurrentTraceContext
|
||||
import org.springframework.cloud.sleuth.Span
|
||||
import org.springframework.cloud.sleuth.TraceContext
|
||||
import org.springframework.cloud.sleuth.brave.bridge.BraveBaggageManager
|
||||
import org.springframework.cloud.sleuth.brave.bridge.BraveSpan
|
||||
import org.springframework.cloud.sleuth.brave.bridge.BraveTracer
|
||||
import spock.mock.DetachedMockFactory
|
||||
|
||||
class TracerMock extends BraveTracer {
|
||||
private final spanMock = new SpanMock(null)
|
||||
private static final mockFactory = new DetachedMockFactory()
|
||||
|
||||
TracerMock(Tracer tracer, CurrentTraceContext context, BraveBaggageManager braveBaggageManager) {
|
||||
super(tracer, context, braveBaggageManager)
|
||||
}
|
||||
|
||||
@Override
|
||||
Span nextSpan(Span parent) {
|
||||
return spanMock
|
||||
}
|
||||
|
||||
@Override
|
||||
Span currentSpan() {
|
||||
return spanMock
|
||||
}
|
||||
|
||||
@Override
|
||||
SpanInScope withSpan(Span span) {
|
||||
return mockFactory.Stub(SpanInScope)
|
||||
}
|
||||
|
||||
private static class SpanMock extends BraveSpan {
|
||||
SpanMock(brave.Span delegate) {
|
||||
super(delegate)
|
||||
}
|
||||
|
||||
@Override
|
||||
Span start() {
|
||||
return this
|
||||
}
|
||||
|
||||
@Override
|
||||
Span name(String name) {
|
||||
return this
|
||||
}
|
||||
|
||||
@Override
|
||||
Span tag(String key, String value) {
|
||||
return this
|
||||
}
|
||||
|
||||
@Override
|
||||
void end() {
|
||||
}
|
||||
|
||||
@Override
|
||||
TraceContext context() {
|
||||
return mockFactory.Stub(TraceContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class MultistreamSpec extends Specification {
|
||||
setup:
|
||||
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2"]))
|
||||
def up2 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api(), new DirectCallMethods(["eth_test2", "eth_test3"]))
|
||||
def aggr = new EthereumPosMultiStream(Chain.ETHEREUM, [up1, up2], Caches.default(), Schedulers.boundedElastic())
|
||||
def aggr = new EthereumPosMultiStream(Chain.ETHEREUM, [up1, up2], Caches.default(), Schedulers.boundedElastic(), TestingCommons.tracerMock())
|
||||
when:
|
||||
aggr.onUpstreamsUpdated()
|
||||
def act = aggr.getMethods()
|
||||
@@ -187,7 +187,7 @@ class MultistreamSpec extends Specification {
|
||||
def up1 = TestingCommons.upstream("test-1", "internal")
|
||||
def up2 = TestingCommons.upstream("test-2", "external")
|
||||
def up3 = TestingCommons.upstream("test-3", "external")
|
||||
def multistream = new EthereumPosMultiStream(Chain.ETHEREUM, [up1, up2, up3], Caches.default(), Schedulers.boundedElastic())
|
||||
def multistream = new EthereumPosMultiStream(Chain.ETHEREUM, [up1, up2, up3], Caches.default(), Schedulers.boundedElastic(), TestingCommons.tracerMock())
|
||||
|
||||
expect:
|
||||
multistream.getHead(new Selector.LabelMatcher("provider", ["internal"])).is(up1.ethereumHeadMock)
|
||||
@@ -255,7 +255,7 @@ class MultistreamSpec extends Specification {
|
||||
class TestEthereumPosMultistream extends EthereumPosMultiStream {
|
||||
|
||||
TestEthereumPosMultistream(@NotNull Chain chain, @NotNull List<EthereumPosUpstream> upstreams, @NotNull Caches caches) {
|
||||
super(chain, upstreams, caches, Schedulers.boundedElastic())
|
||||
super(chain, upstreams, caches, Schedulers.boundedElastic(), TestingCommons.tracerMock())
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.emeraldpay.dshackle.data.DefaultContainer
|
||||
import io.emeraldpay.dshackle.quorum.QuorumReaderFactory
|
||||
import io.emeraldpay.dshackle.quorum.QuorumRpcReader
|
||||
import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.ApiSource
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.dshackle.upstream.Multistream
|
||||
@@ -51,10 +52,10 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||
}
|
||||
EthereumDirectReader reader = new EthereumDirectReader(
|
||||
up, Caches.default(), new CurrentBlockCache(), calls
|
||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||
)
|
||||
reader.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByHash", [hash1, false])) >> Mono.just(
|
||||
new QuorumRpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, resolvers, null)
|
||||
@@ -81,10 +82,10 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||
}
|
||||
EthereumDirectReader reader = new EthereumDirectReader(
|
||||
up, Caches.default(), new CurrentBlockCache(), calls
|
||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||
)
|
||||
reader.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByHash", [hash1, false])) >> Mono.just(
|
||||
new QuorumRpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(null), null, 1, resolvers, null
|
||||
@@ -116,10 +117,10 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||
}
|
||||
EthereumDirectReader reader = new EthereumDirectReader(
|
||||
up, Caches.default(), new CurrentBlockCache(), calls
|
||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||
)
|
||||
reader.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x64", false])) >> Mono.just(
|
||||
new QuorumRpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, resolvers, null
|
||||
@@ -152,10 +153,10 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||
}
|
||||
EthereumDirectReader reader = new EthereumDirectReader(
|
||||
up, Caches.default(), new CurrentBlockCache(), calls
|
||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||
)
|
||||
reader.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionByHash", [hash1])) >> Mono.just(
|
||||
new QuorumRpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, resolvers, null
|
||||
@@ -188,10 +189,10 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||
}
|
||||
EthereumDirectReader reader = new EthereumDirectReader(
|
||||
up, Caches.default(), new CurrentBlockCache(), calls
|
||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||
)
|
||||
reader.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionReceipt", [hash1])) >> Mono.just(
|
||||
new QuorumRpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, new ArrayList<Byte>(), null
|
||||
@@ -225,10 +226,10 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
1 * cacheReceipt(Caches.Tag.REQUESTED, { DefaultContainer data -> data.txId.toHex() == hash1.substring(2) && data.height == 100 })
|
||||
}
|
||||
EthereumDirectReader reader = new EthereumDirectReader(
|
||||
up, caches, new CurrentBlockCache(), calls
|
||||
up, caches, new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||
)
|
||||
reader.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionReceipt", [hash1])) >> Mono.just(
|
||||
new QuorumRpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, new ArrayList<Byte>(), null
|
||||
@@ -253,10 +254,10 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||
}
|
||||
EthereumDirectReader reader = new EthereumDirectReader(
|
||||
up, Caches.default(), new CurrentBlockCache(), calls
|
||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||
)
|
||||
reader.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_getTransactionByHash", [hash1])) >> Mono.just(
|
||||
new QuorumRpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes(null), null, 1, resolvers, null
|
||||
@@ -284,10 +285,10 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||
}
|
||||
EthereumDirectReader reader = new EthereumDirectReader(
|
||||
up, Caches.default(), new CurrentBlockCache(), calls
|
||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||
)
|
||||
reader.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBalance", [address1, "latest"])) >> Mono.just(
|
||||
new QuorumRpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes("0x100"), null, 1, resolvers, null
|
||||
@@ -316,10 +317,10 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||
}
|
||||
EthereumDirectReader reader = new EthereumDirectReader(
|
||||
up, Caches.default(), new CurrentBlockCache(), calls
|
||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||
)
|
||||
reader.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBalance", [address1, "0xa8c9bb"])) >> Mono.just(
|
||||
new QuorumRpcReader.Result(
|
||||
Global.objectMapper.writeValueAsBytes("0x100"), null, 1, resolvers, null
|
||||
@@ -356,14 +357,14 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, resolvers, null)
|
||||
)
|
||||
EthereumDirectReader ethereumDirectReader = new EthereumDirectReader(
|
||||
up, Caches.default(), new CurrentBlockCache(), calls
|
||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||
)
|
||||
ethereumDirectReader.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
2 * create(_, _, _) >> Mock(Reader) {
|
||||
2 * create(_, _, _, _) >> Mock(Reader) {
|
||||
2 * read(new JsonRpcRequest("eth_getBlockByHash", [hash1, false])) >>>
|
||||
[Mono.error(new RuntimeException()), Mono.error(new RuntimeException())]
|
||||
}
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByHash", [hash1, false])) >> result
|
||||
}
|
||||
}
|
||||
@@ -398,14 +399,14 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
Global.objectMapper.writeValueAsBytes(json), null, 1, resolvers, null)
|
||||
)
|
||||
EthereumDirectReader ethereumDirectReader = new EthereumDirectReader(
|
||||
up, Caches.default(), new CurrentBlockCache(), calls
|
||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||
)
|
||||
ethereumDirectReader.quorumReaderFactory = Mock(QuorumReaderFactory) {
|
||||
2 * create(_, _, _) >> Mock(Reader) {
|
||||
2 * create(_, _, _, _) >> Mock(Reader) {
|
||||
2 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x64", false])) >>>
|
||||
[Mono.error(new RuntimeException()), Mono.error(new RuntimeException())]
|
||||
}
|
||||
1 * create(_, _, _) >> Mock(Reader) {
|
||||
1 * create(_, _, _, _) >> Mock(Reader) {
|
||||
1 * read(new JsonRpcRequest("eth_getBlockByNumber", ["0x64", false])) >> result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ class EthereumLocalReaderSpec extends Specification {
|
||||
new EthereumCachingReader(
|
||||
TestingCommons.multistream(TestingCommons.api()),
|
||||
Caches.default(),
|
||||
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM))
|
||||
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM)),
|
||||
TestingCommons.tracerMock()
|
||||
),
|
||||
methods,
|
||||
new EmptyHead(),
|
||||
@@ -45,7 +46,8 @@ class EthereumLocalReaderSpec extends Specification {
|
||||
new EthereumCachingReader(
|
||||
TestingCommons.multistream(TestingCommons.api()),
|
||||
Caches.default(),
|
||||
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM))
|
||||
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM)),
|
||||
TestingCommons.tracerMock()
|
||||
),
|
||||
methods,
|
||||
new EmptyHead(),
|
||||
|
||||
Reference in New Issue
Block a user