Pass all matchers to direct reader (#581)
This commit is contained in:
@@ -94,7 +94,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
}
|
||||
}
|
||||
when:
|
||||
def act = reader.blockReader.read(BlockHash.from(hash1))
|
||||
def act = reader.blockReader.read(new EthereumDirectReader.Request<BlockHash>(BlockHash.from(hash1), Selector.empty))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.expectNextMatches { block ->
|
||||
@@ -122,7 +122,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
}
|
||||
}
|
||||
when:
|
||||
def act = reader.blockReader.read(BlockHash.from(hash1))
|
||||
def act = reader.blockReader.read(new EthereumDirectReader.Request<BlockHash>(BlockHash.from(hash1), Selector.empty))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.expectComplete()
|
||||
@@ -155,7 +155,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
}
|
||||
}
|
||||
when:
|
||||
def act = reader.blockByHeightReader.read(100)
|
||||
def act = reader.blockByHeightReader.read(new EthereumDirectReader.Request<Long>(100L, Selector.empty))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.expectNextMatches { block ->
|
||||
@@ -220,7 +220,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
}
|
||||
}
|
||||
when:
|
||||
def act = reader.txReader.read(TransactionId.from(hash1))
|
||||
def act = reader.txReader.read(new EthereumDirectReader.Request<TransactionId>(TransactionId.from(hash1), Selector.empty))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.expectNextMatches { block ->
|
||||
@@ -253,7 +253,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
}
|
||||
}
|
||||
when:
|
||||
def act = reader.receiptReader.read(TransactionId.from(hash1))
|
||||
def act = reader.receiptReader.read(new EthereumDirectReader.Request<TransactionId>(TransactionId.from(hash1), Selector.empty))
|
||||
.block(Duration.ofSeconds(1))
|
||||
.with { new String(it.data) }
|
||||
then:
|
||||
@@ -287,7 +287,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
}
|
||||
}
|
||||
when:
|
||||
def act = reader.receiptReader.read(TransactionId.from(hash1))
|
||||
def act = reader.receiptReader.read(new EthereumDirectReader.Request<TransactionId>(TransactionId.from(hash1), Selector.empty))
|
||||
.block(Duration.ofSeconds(1))
|
||||
.with { new String(it.data) }
|
||||
then:
|
||||
@@ -312,7 +312,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
}
|
||||
}
|
||||
when:
|
||||
def act = reader.txReader.read(TransactionId.from(hash1))
|
||||
def act = reader.txReader.read(new EthereumDirectReader.Request<TransactionId>(TransactionId.from(hash1), Selector.empty))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.expectComplete()
|
||||
@@ -411,7 +411,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
}
|
||||
}
|
||||
when:
|
||||
def act = ethereumDirectReader.blockReader.read(BlockHash.from(hash1))
|
||||
def act = ethereumDirectReader.blockReader.read(new EthereumDirectReader.Request<BlockHash>(BlockHash.from(hash1), Selector.empty))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.expectNextMatches { block ->
|
||||
@@ -451,7 +451,7 @@ class EthereumDirectReaderSpec extends Specification {
|
||||
}
|
||||
}
|
||||
when:
|
||||
def act = ethereumDirectReader.blockByHeightReader.read(100)
|
||||
def act = ethereumDirectReader.blockByHeightReader.read(new EthereumDirectReader.Request<Long>(100L, Selector.empty))
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
.expectNextMatches { block ->
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.EmptyHead
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.calls.DefaultEthereumMethods
|
||||
import io.emeraldpay.dshackle.upstream.ChainRequest
|
||||
import io.emeraldpay.dshackle.upstream.finalization.FinalizationData
|
||||
@@ -69,9 +70,9 @@ class EthereumLocalReaderSpec extends Specification {
|
||||
1 * getCurrentHeight() >> 101L
|
||||
}
|
||||
def reader = Mock(EthereumCachingReader) {
|
||||
_ * blocksByIdAsCont() >> new EmptyReader<>()
|
||||
_ * txByHashAsCont() >> new EmptyReader<>()
|
||||
1 * blocksByHeightAsCont() >> Mock(Reader) {
|
||||
_ * blocksByIdAsCont(Selector.empty) >> new EmptyReader<>()
|
||||
_ * txByHashAsCont(Selector.empty) >> new EmptyReader<>()
|
||||
1 * blocksByHeightAsCont(Selector.empty) >> Mock(Reader) {
|
||||
1 * read(101L) >> Mono.just(
|
||||
new EthereumDirectReader.Result<>(TestingCommons.blockForEthereum(101L), List.of())
|
||||
)
|
||||
@@ -81,7 +82,7 @@ class EthereumLocalReaderSpec extends Specification {
|
||||
def router = new EthereumLocalReader(reader, methods, head, null)
|
||||
|
||||
when:
|
||||
def act = router.getBlockByNumber(["latest", false])
|
||||
def act = router.getBlockByNumber(["latest", false], Selector.empty)
|
||||
|
||||
then:
|
||||
act != null
|
||||
@@ -97,9 +98,9 @@ class EthereumLocalReaderSpec extends Specification {
|
||||
setup:
|
||||
def head = Stub(Head) {}
|
||||
def reader = Mock(EthereumCachingReader) {
|
||||
_ * blocksByIdAsCont() >> new EmptyReader<>()
|
||||
_ * txByHashAsCont() >> new EmptyReader<>()
|
||||
1 * blocksByHeightAsCont() >> Mock(Reader) {
|
||||
_ * blocksByIdAsCont(Selector.empty) >> new EmptyReader<>()
|
||||
_ * txByHashAsCont(Selector.empty) >> new EmptyReader<>()
|
||||
1 * blocksByHeightAsCont(Selector.empty) >> Mock(Reader) {
|
||||
1 * read(0L) >> Mono.just(
|
||||
new EthereumDirectReader.Result<>(TestingCommons.blockForEthereum(0L), List.of())
|
||||
)
|
||||
@@ -109,7 +110,7 @@ class EthereumLocalReaderSpec extends Specification {
|
||||
def router = new EthereumLocalReader(reader, methods, head, null)
|
||||
|
||||
when:
|
||||
def act = router.getBlockByNumber(["earliest", false])
|
||||
def act = router.getBlockByNumber(["earliest", false], Selector.empty)
|
||||
|
||||
then:
|
||||
act != null
|
||||
@@ -125,9 +126,9 @@ class EthereumLocalReaderSpec extends Specification {
|
||||
setup:
|
||||
def head = Stub(Head) {}
|
||||
def reader = Mock(EthereumCachingReader) {
|
||||
_ * blocksByIdAsCont() >> new EmptyReader<>()
|
||||
_ * txByHashAsCont() >> new EmptyReader<>()
|
||||
1 * blocksByHeightAsCont() >> Mock(Reader) {
|
||||
_ * blocksByIdAsCont(Selector.empty) >> new EmptyReader<>()
|
||||
_ * txByHashAsCont(Selector.empty) >> new EmptyReader<>()
|
||||
1 * blocksByHeightAsCont(Selector.empty) >> Mock(Reader) {
|
||||
1 * read(74735L) >> Mono.just(
|
||||
new EthereumDirectReader.Result<>(TestingCommons.blockForEthereum(74735L), List.of())
|
||||
)
|
||||
@@ -137,7 +138,7 @@ class EthereumLocalReaderSpec extends Specification {
|
||||
def router = new EthereumLocalReader(reader, methods, head, null)
|
||||
|
||||
when:
|
||||
def act = router.getBlockByNumber(["0x123ef", false])
|
||||
def act = router.getBlockByNumber(["0x123ef", false], Selector.empty)
|
||||
|
||||
then:
|
||||
act != null
|
||||
@@ -183,15 +184,15 @@ class EthereumLocalReaderSpec extends Specification {
|
||||
setup:
|
||||
def head = Mock(Head)
|
||||
def reader = Mock(EthereumCachingReader) {
|
||||
_ * blocksByIdAsCont() >> new EmptyReader<>()
|
||||
_ * txByHashAsCont() >> new EmptyReader<>()
|
||||
_ * blocksByHeightAsCont() >> new EmptyReader<>()
|
||||
_ * blocksByIdAsCont(Selector.empty) >> new EmptyReader<>()
|
||||
_ * txByHashAsCont(Selector.empty) >> new EmptyReader<>()
|
||||
_ * blocksByHeightAsCont(Selector.empty) >> new EmptyReader<>()
|
||||
}
|
||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
||||
def router = new EthereumLocalReader(reader, methods, head, null)
|
||||
|
||||
when:
|
||||
def act = router.getBlockByNumber(["0x0", true])
|
||||
def act = router.getBlockByNumber(["0x0", true], Selector.empty)
|
||||
|
||||
then:
|
||||
act == null
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.emeraldpay.dshackle.test.GenericUpstreamMock
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.BlockValidator
|
||||
import io.emeraldpay.dshackle.upstream.DefaultUpstream
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.forkchoice.AlwaysForkChoice
|
||||
import io.emeraldpay.dshackle.upstream.ChainRequest
|
||||
@@ -132,7 +133,7 @@ class GenericWsHeadSpec extends Specification {
|
||||
new WsSubscriptions.SubscribeData(Flux.error(new RuntimeException()), "id", new AtomicReference<String>("")),
|
||||
new WsSubscriptions.SubscribeData(Flux.fromIterable([secondHeadBlock]), "id", new AtomicReference<String>(""))
|
||||
]
|
||||
1 * it.unsubscribe(new ChainRequest("eth_unsubscribe", new ListParams(""), 2, null, null, false)) >>
|
||||
1 * it.unsubscribe(new ChainRequest("eth_unsubscribe", new ListParams(""), 2, null, null, false, Selector.empty)) >>
|
||||
Mono.just(new ChainResponse("".bytes, null))
|
||||
}
|
||||
|
||||
@@ -452,7 +453,7 @@ class GenericWsHeadSpec extends Specification {
|
||||
1 * it.subscribe(_) >> new WsSubscriptions.SubscribeData(
|
||||
Flux.error(new RuntimeException()), "id", new AtomicReference<String>(subId)
|
||||
)
|
||||
1 * it.unsubscribe(new ChainRequest("eth_unsubscribe", new ListParams(subId), 2, null, null, false)) >>
|
||||
1 * it.unsubscribe(new ChainRequest("eth_unsubscribe", new ListParams(subId), 2, null, null, false, Selector.empty)) >>
|
||||
Mono.just(new ChainResponse("".bytes, null))
|
||||
}
|
||||
|
||||
|
||||
@@ -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.ChainRequest
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
@@ -59,7 +60,7 @@ class WsConnectionImplSpec extends Specification {
|
||||
|
||||
when:
|
||||
Flux.from(ws.handle(wsApiMock.inbound, wsApiMock.outbound)).subscribe()
|
||||
def act = ws.callRpc(new ChainRequest("eth_getTransactionByHash", new ListParams(["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"]), 15, null, null, false))
|
||||
def act = ws.callRpc(new ChainRequest("eth_getTransactionByHash", new ListParams(["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"]), 15, null, null, false, Selector.empty))
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
@@ -91,7 +92,7 @@ class WsConnectionImplSpec extends Specification {
|
||||
|
||||
when:
|
||||
Flux.from(ws.handle(wsApiMock.inbound, wsApiMock.outbound)).subscribe()
|
||||
def act = ws.callRpc(new ChainRequest("eth_getTransactionByHash", new ListParams(["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"]), 15, null, null, false))
|
||||
def act = ws.callRpc(new ChainRequest("eth_getTransactionByHash", new ListParams(["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"]), 15, null, null, false, Selector.empty))
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
@@ -125,7 +126,7 @@ class WsConnectionImplSpec extends Specification {
|
||||
|
||||
when:
|
||||
Flux.from(ws.handle(wsApiMock.inbound, wsApiMock.outbound)).subscribe()
|
||||
def act = ws.callRpc(new ChainRequest("eth_getTransactionByHash", new ListParams(["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"]), 15, null, null, false))
|
||||
def act = ws.callRpc(new ChainRequest("eth_getTransactionByHash", new ListParams(["0x3ec2ebf5d0ec474d0ac6bc50d2770d8409ad76e119968e7919f85d5ec8915200"]), 15, null, null, false, Selector.empty))
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
|
||||
Reference in New Issue
Block a user