From 945048a2beb4150b036b3cc8b81fa3719576e263 Mon Sep 17 00:00:00 2001 From: Maxksim Fomenkov Date: Wed, 7 Sep 2022 16:28:49 +0300 Subject: [PATCH 1/5] increase java memory --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5ec8d72f..0bf15f07 100644 --- a/build.gradle +++ b/build.gradle @@ -164,7 +164,7 @@ jib { } } container { - jvmFlags = ['-Xms1024m'] + jvmFlags = ['-Xms1024m', '-Xmx16G'] mainClass = 'io.emeraldpay.dshackle.StarterKt' args = [] ports = ['2448', '2449', '8545'] From 7cb5a45f513647b44e606f6348c5794ede96cba6 Mon Sep 17 00:00:00 2001 From: Maxksim Fomenkov Date: Wed, 7 Sep 2022 16:46:16 +0300 Subject: [PATCH 2/5] java memory percentage --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0bf15f07..03cc3cb6 100644 --- a/build.gradle +++ b/build.gradle @@ -164,7 +164,7 @@ jib { } } container { - jvmFlags = ['-Xms1024m', '-Xmx16G'] + jvmFlags = ['-Xms1024m', '-XX:MaxRAMPercentage=60'] mainClass = 'io.emeraldpay.dshackle.StarterKt' args = [] ports = ['2448', '2449', '8545'] From c64e85e3c40b5d0d166b33f1ca813706141c043d Mon Sep 17 00:00:00 2001 From: Maxksim Fomenkov Date: Thu, 8 Sep 2022 17:31:14 +0300 Subject: [PATCH 3/5] extend http client connections pool --- .../dshackle/upstream/rpcclient/JsonRpcHttpClient.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcHttpClient.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcHttpClient.kt index fb425ebf..8535bdc2 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcHttpClient.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcHttpClient.kt @@ -27,6 +27,7 @@ import io.netty.resolver.DefaultAddressResolverGroup import org.slf4j.LoggerFactory import reactor.core.publisher.Mono import reactor.netty.http.client.HttpClient +import reactor.netty.resources.ConnectionProvider import java.io.ByteArrayInputStream import java.security.KeyStore import java.security.cert.CertificateFactory @@ -53,7 +54,11 @@ class JsonRpcHttpClient( private val httpClient: HttpClient init { - var build = HttpClient.create() + val connectionProvider = ConnectionProvider.builder("dshackleConnectionPool") + .maxConnections(1000) + .pendingAcquireMaxCount(5000) + .build() + var build = HttpClient.create(connectionProvider) .resolver(DefaultAddressResolverGroup.INSTANCE) build = build.headers { h -> From 77b2307c78da092ab730d33a79053296d55b8f43 Mon Sep 17 00:00:00 2001 From: terminal Date: Mon, 12 Sep 2022 17:20:36 +0300 Subject: [PATCH 4/5] update emerald api --- emerald-java-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emerald-java-client b/emerald-java-client index 934a7d0f..a704b789 160000 --- a/emerald-java-client +++ b/emerald-java-client @@ -1 +1 @@ -Subproject commit 934a7d0fd01e2920c3dc1db3097384e17a0166af +Subproject commit a704b789a64b30edba78bf37dae6f4c1497eef2b From b90644b06ae710d46b1cbaca0a022d49614fc52c Mon Sep 17 00:00:00 2001 From: terminal Date: Mon, 12 Sep 2022 18:49:33 +0300 Subject: [PATCH 5/5] fix ehtereum constants, fix tests --- emerald-java-client | 2 +- .../dshackle/config/TokensConfig.kt | 2 +- .../io/emeraldpay/dshackle/rpc/NativeCall.kt | 7 +- .../dshackle/rpc/NativeSubscribe.kt | 2 +- .../dshackle/rpc/TrackERC20Address.kt | 11 +-- .../dshackle/rpc/TrackEthereumAddress.kt | 8 +- .../dshackle/rpc/TrackEthereumTx.kt | 12 +-- .../upstream/ethereum/ERC20Balance.kt | 6 +- .../dshackle/rpc/NativeSubscribeSpec.groovy | 5 +- .../dshackle/rpc/StreamHeadSpec.groovy | 8 +- .../dshackle/rpc/TrackERC20AddressSpec.groovy | 5 +- .../dshackle/rpc/TrackEthereumTxSpec.groovy | 5 +- .../test/EthereumPosRpcUpstreamMock.groovy | 88 +++++++++++++++++++ .../test/MultistreamHolderMock.groovy | 18 ++-- .../dshackle/test/TestingCommons.groovy | 28 +++--- .../CurrentMultistreamHolderSpec.groovy | 15 ++-- .../dshackle/upstream/MultistreamSpec.groovy | 8 +- .../upstream/ethereum/ERC20BalanceSpec.groovy | 5 +- .../ethereum/EthereumReaderSpec.groovy | 7 +- .../ethereum/EthereumSubscribeSpec.groovy | 16 ++-- .../ethereum/subscribe/ConnectLogsSpec.groovy | 9 +- 21 files changed, 185 insertions(+), 82 deletions(-) create mode 100644 src/test/groovy/io/emeraldpay/dshackle/test/EthereumPosRpcUpstreamMock.groovy diff --git a/emerald-java-client b/emerald-java-client index a704b789..a3dde262 160000 --- a/emerald-java-client +++ b/emerald-java-client @@ -1 +1 @@ -Subproject commit a704b789a64b30edba78bf37dae6f4c1497eef2b +Subproject commit a3dde262ffab10749b8f14532765e0d2054fbd98 diff --git a/src/main/kotlin/io/emeraldpay/dshackle/config/TokensConfig.kt b/src/main/kotlin/io/emeraldpay/dshackle/config/TokensConfig.kt index 56debf05..55560767 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/config/TokensConfig.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/config/TokensConfig.kt @@ -41,7 +41,7 @@ class TokensConfig( type == null -> type address.isNullOrBlank() -> "address" blockchain != null && - BlockchainType.from(blockchain!!) == BlockchainType.ETHEREUM && + (BlockchainType.from(blockchain!!) == BlockchainType.ETHEREUM_POS || BlockchainType.from(blockchain!!) == BlockchainType.ETHEREUM) && !Address.isValidAddress(address) -> "address" else -> null } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt b/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt index 81c24851..bcb3dce0 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt @@ -51,7 +51,7 @@ import java.util.EnumMap @Service open class NativeCall( @Autowired private val multistreamHolder: MultistreamHolder, - @Autowired private val signer: ResponseSigner, + @Autowired private val signer: ResponseSigner ) { private val log = LoggerFactory.getLogger(NativeCall::class.java) @@ -62,7 +62,8 @@ open class NativeCall( init { multistreamHolder.observeChains().subscribe { chain -> - if (BlockchainType.from(chain) == BlockchainType.ETHEREUM && !ethereumCallSelectors.containsKey(chain)) { + if ((BlockchainType.from(chain) == BlockchainType.ETHEREUM_POS || BlockchainType.from(chain) == BlockchainType.ETHEREUM) && !ethereumCallSelectors.containsKey(chain) + ) { multistreamHolder.getUpstream(chain)?.let { up -> val reader = up.cast(EthereumMultistream::class.java).getReader() ethereumCallSelectors[chain] = EthereumCallSelector(reader.heightByHash()) @@ -186,7 +187,7 @@ open class NativeCall( } // for ethereum the actual block needed for the call may be specified in the call parameters val callSpecificMatcher: Mono = - if (BlockchainType.from(upstream.chain) == BlockchainType.ETHEREUM) { + if (BlockchainType.from(upstream.chain) == BlockchainType.ETHEREUM_POS || BlockchainType.from(upstream.chain) == BlockchainType.ETHEREUM) { ethereumCallSelectors[chain]?.getMatcher(method, params, upstream.getHead()) } else { null diff --git a/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeSubscribe.kt b/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeSubscribe.kt index a2b7b3b2..20edb41a 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeSubscribe.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeSubscribe.kt @@ -52,7 +52,7 @@ open class NativeSubscribe( fun start(it: BlockchainOuterClass.NativeSubscribeRequest): Publisher { val chain = Chain.byId(it.chainValue) - if (BlockchainType.from(chain) != BlockchainType.ETHEREUM) { + if (BlockchainType.from(chain) != BlockchainType.ETHEREUM_POS && BlockchainType.from(chain) != BlockchainType.ETHEREUM) { return Mono.error(UnsupportedOperationException("Native subscribe is not supported for ${chain.chainCode}")) } val method = it.method diff --git a/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackERC20Address.kt b/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackERC20Address.kt index 5a968c44..0b40d706 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackERC20Address.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackERC20Address.kt @@ -21,7 +21,7 @@ import io.emeraldpay.dshackle.SilentException import io.emeraldpay.dshackle.config.TokensConfig import io.emeraldpay.dshackle.upstream.MultistreamHolder import io.emeraldpay.dshackle.upstream.ethereum.ERC20Balance -import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream import io.emeraldpay.etherjar.domain.Address import io.emeraldpay.etherjar.domain.EventId import io.emeraldpay.etherjar.erc20.ERC20Token @@ -58,7 +58,8 @@ class TrackERC20Address( val asset = token.name!!.lowercase(Locale.getDefault()) val id = TokenId(chain, asset) val definition = TokenDefinition( - chain, asset, + chain, + asset, ERC20Token(Address.from(token.address)) ) tokens[id] = definition @@ -68,7 +69,7 @@ class TrackERC20Address( override fun isSupported(chain: Chain, asset: String): Boolean { return tokens.containsKey(TokenId(chain, asset.lowercase(Locale.getDefault()))) && - BlockchainType.from(chain) == BlockchainType.ETHEREUM && multistreamHolder.isAvailable(chain) + (BlockchainType.from(chain) == BlockchainType.ETHEREUM_POS || BlockchainType.from(chain) == BlockchainType.ETHEREUM) && multistreamHolder.isAvailable(chain) } override fun getBalance(request: BlockchainOuterClass.BalanceRequest): Flux { @@ -121,8 +122,8 @@ class TrackERC20Address( return erc20Balance.getBalance(upstream, addr.token, addr.address) } - fun getUpstream(chain: Chain): EthereumMultistream { - return multistreamHolder.getUpstream(chain)?.cast(EthereumMultistream::class.java) + fun getUpstream(chain: Chain): EthereumPosMultiStream { + return multistreamHolder.getUpstream(chain)?.cast(EthereumPosMultiStream::class.java) ?: throw SilentException.UnsupportedBlockchain(chain) } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackEthereumAddress.kt b/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackEthereumAddress.kt index c9256b3c..7a03d93e 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackEthereumAddress.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackEthereumAddress.kt @@ -21,7 +21,7 @@ import io.emeraldpay.api.proto.Common import io.emeraldpay.dshackle.Defaults import io.emeraldpay.dshackle.SilentException import io.emeraldpay.dshackle.upstream.MultistreamHolder -import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream import io.emeraldpay.etherjar.domain.Address import io.emeraldpay.etherjar.domain.Wei import io.emeraldpay.grpc.BlockchainType @@ -43,7 +43,7 @@ class TrackEthereumAddress( override fun isSupported(chain: Chain, asset: String): Boolean { return asset == "ether" && - BlockchainType.from(chain) == BlockchainType.ETHEREUM && multistreamHolder.isAvailable(chain) + (BlockchainType.from(chain) == BlockchainType.ETHEREUM_POS || BlockchainType.from(chain) == BlockchainType.ETHEREUM) && multistreamHolder.isAvailable(chain) } override fun getBalance(request: BlockchainOuterClass.BalanceRequest): Flux { @@ -89,8 +89,8 @@ class TrackEthereumAddress( } } - fun getUpstream(chain: Chain): EthereumMultistream { - return multistreamHolder.getUpstream(chain)?.cast(EthereumMultistream::class.java) + fun getUpstream(chain: Chain): EthereumPosMultiStream { + return multistreamHolder.getUpstream(chain)?.cast(EthereumPosMultiStream::class.java) ?: throw SilentException.UnsupportedBlockchain(chain) } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackEthereumTx.kt b/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackEthereumTx.kt index 2323e25c..b3cea3cd 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackEthereumTx.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackEthereumTx.kt @@ -22,7 +22,7 @@ import io.emeraldpay.dshackle.SilentException import io.emeraldpay.dshackle.data.BlockContainer import io.emeraldpay.dshackle.data.TxId import io.emeraldpay.dshackle.upstream.MultistreamHolder -import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream import io.emeraldpay.etherjar.domain.BlockHash import io.emeraldpay.etherjar.domain.TransactionId import io.emeraldpay.etherjar.rpc.RpcException @@ -62,7 +62,7 @@ class TrackEthereumTx( private val log = LoggerFactory.getLogger(TrackEthereumTx::class.java) override fun isSupported(chain: Chain): Boolean { - return BlockchainType.from(chain) == BlockchainType.ETHEREUM && multistreamHolder.isAvailable(chain) + return (BlockchainType.from(chain) == BlockchainType.ETHEREUM_POS || BlockchainType.from(chain) == BlockchainType.ETHEREUM) && multistreamHolder.isAvailable(chain) } override fun subscribe(request: BlockchainOuterClass.TxStatusRequest): Flux { @@ -81,12 +81,12 @@ class TrackEthereumTx( } } - fun getUpstream(chain: Chain): EthereumMultistream { - return multistreamHolder.getUpstream(chain)?.cast(EthereumMultistream::class.java) + fun getUpstream(chain: Chain): EthereumPosMultiStream { + return multistreamHolder.getUpstream(chain)?.cast(EthereumPosMultiStream::class.java) ?: throw SilentException.UnsupportedBlockchain(chain) } - fun subscribe(base: TxDetails, up: EthereumMultistream): Flux { + fun subscribe(base: TxDetails, up: EthereumPosMultiStream): Flux { var latestTx = base val untilFound = Mono.just(latestTx) @@ -213,7 +213,7 @@ class TrackEthereumTx( } } - fun updateFromBlock(upstream: EthereumMultistream, tx: TxDetails, blockTx: TransactionJson): Mono { + fun updateFromBlock(upstream: EthereumPosMultiStream, tx: TxDetails, blockTx: TransactionJson): Mono { return if (blockTx.blockNumber != null && blockTx.blockHash != null && blockTx.blockHash != ZERO_BLOCK) { val updated = tx.withStatus( blockHash = blockTx.blockHash, diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/ERC20Balance.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/ERC20Balance.kt index 05d99b8d..e538b3bb 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/ERC20Balance.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/ERC20Balance.kt @@ -38,7 +38,7 @@ open class ERC20Balance { private val log = LoggerFactory.getLogger(ERC20Balance::class.java) } - open fun getBalance(upstreams: EthereumMultistream, token: ERC20Token, address: Address): Mono { + open fun getBalance(upstreams: EthereumPosMultiStream, token: ERC20Token, address: Address): Mono { return upstreams // use only up-to-date upstreams .getApiSource(Selector.HeightMatcher(upstreams.getHead().getCurrentHeight() ?: 0)) @@ -49,7 +49,7 @@ open class ERC20Balance { apis.request(1) return Flux.from(apis) .flatMap { - getBalance(it.cast(EthereumRpcUpstream::class.java), token, address) + getBalance(it.cast(EthereumPosRpcUpstream::class.java), token, address) } .doOnNext { apis.resolve() @@ -57,7 +57,7 @@ open class ERC20Balance { .next() } - open fun getBalance(upstream: EthereumRpcUpstream, token: ERC20Token, address: Address): Mono { + open fun getBalance(upstream: EthereumPosRpcUpstream, token: ERC20Token, address: Address): Mono { return upstream .getApi() .read(prepareEthCall(token, address, upstream.getHead())) diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy index 4e176e2a..888df4b8 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy @@ -19,6 +19,7 @@ import com.google.protobuf.ByteString import io.emeraldpay.api.proto.BlockchainOuterClass import io.emeraldpay.dshackle.test.MultistreamHolderMock import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream import io.emeraldpay.dshackle.upstream.ethereum.EthereumSubscribe import io.emeraldpay.grpc.Chain import reactor.core.publisher.Flux @@ -34,7 +35,7 @@ class NativeSubscribeSpec extends Specification { def subscribe = Mock(EthereumSubscribe) { 1 * it.subscribe("newHeads", null) >> Flux.just("{}") } - def up = Mock(EthereumMultistream) { + def up = Mock(EthereumPosMultiStream) { 1 * it.getSubscribe() >> subscribe } @@ -66,7 +67,7 @@ class NativeSubscribeSpec extends Specification { ok }) >> Flux.just("{}") } - def up = Mock(EthereumMultistream) { + def up = Mock(EthereumPosMultiStream) { 1 * it.getSubscribe() >> subscribe } diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/StreamHeadSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/StreamHeadSpec.groovy index 160becb9..b5880354 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/StreamHeadSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/StreamHeadSpec.groovy @@ -22,10 +22,10 @@ import io.emeraldpay.api.proto.BlockchainOuterClass import io.emeraldpay.api.proto.Common import io.emeraldpay.dshackle.Global import io.emeraldpay.dshackle.data.BlockContainer -import io.emeraldpay.dshackle.test.EthereumRpcUpstreamMock +import io.emeraldpay.dshackle.test.EthereumPosRpcUpstreamMock import io.emeraldpay.dshackle.test.TestingCommons import io.emeraldpay.dshackle.test.MultistreamHolderMock -import io.emeraldpay.dshackle.upstream.ethereum.EthereumRpcUpstream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosRpcUpstream import io.emeraldpay.grpc.Chain import io.emeraldpay.etherjar.domain.BlockHash import io.emeraldpay.etherjar.rpc.json.BlockJson @@ -43,7 +43,7 @@ class StreamHeadSpec extends Specification { def "Errors on unavailable chain"() { setup: - def upstreams = new MultistreamHolderMock(Chain.ETHEREUM, Stub(EthereumRpcUpstream)) + def upstreams = new MultistreamHolderMock(Chain.ETHEREUM, Stub(EthereumPosRpcUpstream)) def streamHead = new StreamHead(upstreams) when: def flux = streamHead.add( @@ -78,7 +78,7 @@ class StreamHeadSpec extends Specification { .build() } - def upstream = new EthereumRpcUpstreamMock(Chain.ETHEREUM, TestingCommons.api()) + def upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, TestingCommons.api()) def upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstream) def streamHead = new StreamHead(upstreams) when: diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy index de15a93e..ecd9d7f1 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy @@ -6,6 +6,7 @@ import io.emeraldpay.dshackle.config.TokensConfig import io.emeraldpay.dshackle.upstream.MultistreamHolder import io.emeraldpay.dshackle.upstream.ethereum.ERC20Balance import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream import io.emeraldpay.dshackle.upstream.ethereum.EthereumSubscribe import io.emeraldpay.dshackle.upstream.ethereum.subscribe.ConnectLogs import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.LogMessage @@ -178,9 +179,9 @@ class TrackERC20AddressSpec extends Specification { def sub = Mock(EthereumSubscribe) { 1 * getLogs() >> logs } - def up = Mock(EthereumMultistream) { + def up = Mock(EthereumPosMultiStream) { 1 * getSubscribe() >> sub - _ * cast(EthereumMultistream) >> { args -> + _ * cast(EthereumPosMultiStream) >> { args -> it } } diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy index 71fedb56..1289714e 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy @@ -27,6 +27,7 @@ import io.emeraldpay.dshackle.test.MultistreamHolderMock import io.emeraldpay.dshackle.upstream.Head import io.emeraldpay.dshackle.upstream.MultistreamHolder import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream import io.emeraldpay.grpc.Chain import io.emeraldpay.etherjar.domain.BlockHash import io.emeraldpay.etherjar.domain.TransactionId @@ -118,7 +119,7 @@ class TrackEthereumTxSpec extends Specification { def apiMock = TestingCommons.api() def upstreamMock = TestingCommons.upstream(apiMock) MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock) - ((EthereumMultistream) upstreams.getUpstream(Chain.ETHEREUM)).head = Mock(Head) { + ((EthereumPosMultiStream) upstreams.getUpstream(Chain.ETHEREUM)).head = Mock(Head) { _ * getFlux() >> Flux.empty() } TrackEthereumTx trackTx = new TrackEthereumTx(upstreams) @@ -130,7 +131,7 @@ class TrackEthereumTxSpec extends Specification { when: def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM, Instant.now(), TransactionId.from(txId), 6) def act = StepVerifier.withVirtualTime( - { trackTx.subscribe(tx, upstreams.getUpstream(Chain.ETHEREUM).cast(EthereumMultistream)) }, + { trackTx.subscribe(tx, upstreams.getUpstream(Chain.ETHEREUM).cast(EthereumPosMultiStream)) }, { scheduler }, 5) diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/EthereumPosRpcUpstreamMock.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/EthereumPosRpcUpstreamMock.groovy new file mode 100644 index 00000000..5d75a195 --- /dev/null +++ b/src/test/groovy/io/emeraldpay/dshackle/test/EthereumPosRpcUpstreamMock.groovy @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2019 ETCDEV GmbH + * Copyright (c) 2020 EmeraldPay, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.emeraldpay.dshackle.test + + +import io.emeraldpay.dshackle.config.UpstreamsConfig +import io.emeraldpay.dshackle.data.BlockContainer +import io.emeraldpay.dshackle.upstream.calls.AggregatedCallMethods +import io.emeraldpay.dshackle.upstream.calls.CallMethods +import io.emeraldpay.dshackle.startup.QuorumForLabels +import io.emeraldpay.dshackle.upstream.calls.DefaultBitcoinMethods +import io.emeraldpay.dshackle.upstream.calls.DefaultEthereumMethods +import io.emeraldpay.dshackle.upstream.calls.DirectCallMethods +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosRpcUpstream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumRpcUpstream +import io.emeraldpay.dshackle.upstream.UpstreamAvailability +import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest +import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse +import io.emeraldpay.dshackle.reader.Reader +import io.emeraldpay.grpc.Chain +import org.jetbrains.annotations.NotNull +import org.reactivestreams.Publisher + + +class EthereumPosRpcUpstreamMock extends EthereumPosRpcUpstream { + EthereumHeadMock ethereumHeadMock + + + static CallMethods allMethods() { + new AggregatedCallMethods([ + new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultBitcoinMethods(), + new DirectCallMethods(["eth_test"]) + ]) + } + + EthereumPosRpcUpstreamMock(@NotNull Chain chain, @NotNull Reader api) { + this(chain, api, allMethods()) + } + + EthereumPosRpcUpstreamMock(@NotNull String id, @NotNull Chain chain, @NotNull Reader api) { + this(id, chain, api, allMethods()) + } + + EthereumPosRpcUpstreamMock(@NotNull Chain chain, @NotNull Reader api, CallMethods methods) { + this("test", chain, api, methods) + } + + EthereumPosRpcUpstreamMock(@NotNull String id, @NotNull Chain chain, @NotNull Reader api, CallMethods methods) { + super(id, chain, + UpstreamsConfig.Options.getDefaults(), + UpstreamsConfig.UpstreamRole.PRIMARY, + methods, + new QuorumForLabels.QuorumItem(1, new UpstreamsConfig.Labels()), + new ConnectorFactoryMock(api, new EthereumHeadMock())) + this.ethereumHeadMock = this.getHead() as EthereumHeadMock + setLag(0) + setStatus(UpstreamAvailability.OK) + start() + } + + void nextBlock(BlockContainer block) { + this.ethereumHeadMock.nextBlock(block) + } + + void setBlocks(Publisher blocks) { + this.ethereumHeadMock.predefined = blocks + } + + @Override + String toString() { + return "Upstream mock ${getId()}" + } +} diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/MultistreamHolderMock.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/MultistreamHolderMock.groovy index 26275da6..cd75af82 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/test/MultistreamHolderMock.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/test/MultistreamHolderMock.groovy @@ -27,6 +27,8 @@ import io.emeraldpay.dshackle.upstream.calls.DefaultEthereumMethods import io.emeraldpay.dshackle.upstream.Upstream import io.emeraldpay.dshackle.upstream.MultistreamHolder import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosRpcUpstream import io.emeraldpay.dshackle.upstream.ethereum.EthereumReader import io.emeraldpay.dshackle.upstream.ethereum.EthereumRpcUpstream import io.emeraldpay.grpc.BlockchainType @@ -45,11 +47,11 @@ class MultistreamHolderMock implements MultistreamHolder { Multistream addUpstream(@NotNull Chain chain, @NotNull Upstream up) { if (!upstreams.containsKey(chain)) { - if (BlockchainType.from(chain) == BlockchainType.ETHEREUM) { - if (up instanceof EthereumMultistream) { + if (BlockchainType.from(chain) == BlockchainType.ETHEREUM_POS) { + if (up instanceof EthereumPosMultiStream) { upstreams[chain] = up - } else if (up instanceof EthereumRpcUpstream) { - upstreams[chain] = new EthereumMultistreamMock(chain, [up as EthereumRpcUpstream], Caches.default()) + } else if (up instanceof EthereumPosRpcUpstream) { + upstreams[chain] = new EthereumPosMultiStream(chain, [up as EthereumPosRpcUpstream], Caches.default()) } else { throw new IllegalArgumentException("Unsupported upstream type ${up.class}") } @@ -99,21 +101,21 @@ class MultistreamHolderMock implements MultistreamHolder { return upstreams.containsKey(chain) } - static class EthereumMultistreamMock extends EthereumMultistream { + static class EthereumMultistreamMock extends EthereumPosMultiStream { EthereumReader customReader = null CallMethods customMethods = null Head customHead = null - EthereumMultistreamMock(@NotNull Chain chain, @NotNull List upstreams, @NotNull Caches caches) { + EthereumMultistreamMock(@NotNull Chain chain, @NotNull List upstreams, @NotNull Caches caches) { super(chain, upstreams, caches) } - EthereumMultistreamMock(@NotNull Chain chain, @NotNull List upstreams) { + EthereumMultistreamMock(@NotNull Chain chain, @NotNull List upstreams) { this(chain, upstreams, Caches.default()) } - EthereumMultistreamMock(@NotNull Chain chain, @NotNull EthereumRpcUpstream upstream) { + EthereumMultistreamMock(@NotNull Chain chain, @NotNull EthereumPosRpcUpstream upstream) { this(chain, [upstream]) } diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy index 5f4662c4..f2cac503 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy @@ -28,6 +28,8 @@ import io.emeraldpay.dshackle.reader.Reader import io.emeraldpay.dshackle.upstream.Multistream import io.emeraldpay.dshackle.upstream.calls.DirectCallMethods import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosRpcUpstream import io.emeraldpay.dshackle.upstream.ethereum.EthereumRpcUpstream import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse @@ -46,36 +48,36 @@ class TestingCommons { return new ApiReaderMock() } - static EthereumRpcUpstreamMock upstream() { - return new EthereumRpcUpstreamMock(Chain.ETHEREUM, api()) + static EthereumPosRpcUpstreamMock upstream() { + return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api()) } - static EthereumRpcUpstreamMock upstream(String id) { - return new EthereumRpcUpstreamMock(id, Chain.ETHEREUM, api()) + static EthereumPosRpcUpstreamMock upstream(String id) { + return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM, api()) } - static EthereumRpcUpstreamMock upstream(String id, Reader api) { - return new EthereumRpcUpstreamMock(id, Chain.ETHEREUM, api) + static EthereumPosRpcUpstreamMock upstream(String id, Reader api) { + return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM, api) } - static EthereumRpcUpstreamMock upstream(Reader api) { - return new EthereumRpcUpstreamMock(Chain.ETHEREUM, api) + static EthereumPosRpcUpstreamMock upstream(Reader api) { + return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api) } - static EthereumRpcUpstreamMock upstream(Reader api, String method) { + static EthereumPosRpcUpstreamMock upstream(Reader api, String method) { return upstream(api, [method]) } - static EthereumRpcUpstreamMock upstream(Reader api, List methods) { - return new EthereumRpcUpstreamMock(Chain.ETHEREUM, api, new DirectCallMethods(methods)) + static EthereumPosRpcUpstreamMock upstream(Reader api, List methods) { + return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api, new DirectCallMethods(methods)) } static Multistream multistream(Reader api) { return multistream(upstream(api)) } - static Multistream multistream(EthereumRpcUpstream up) { - return new EthereumMultistream(Chain.ETHEREUM, [up], Caches.default()).tap { + static Multistream multistream(EthereumPosRpcUpstreamMock up) { + return new EthereumPosMultiStream(Chain.ETHEREUM, [up], Caches.default()).tap { start() } } diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/CurrentMultistreamHolderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/CurrentMultistreamHolderSpec.groovy index a3b3952b..2f38eecd 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/CurrentMultistreamHolderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/CurrentMultistreamHolderSpec.groovy @@ -16,6 +16,7 @@ package io.emeraldpay.dshackle.upstream import io.emeraldpay.dshackle.startup.UpstreamChange +import io.emeraldpay.dshackle.test.EthereumPosRpcUpstreamMock import io.emeraldpay.dshackle.test.EthereumRpcUpstreamMock import io.emeraldpay.dshackle.test.TestingCommons import io.emeraldpay.grpc.Chain @@ -26,7 +27,7 @@ class CurrentMultistreamHolderSpec extends Specification { def "add upstream"() { setup: def current = new CurrentMultistreamHolder(TestingCommons.emptyCaches()) - def up = new EthereumRpcUpstreamMock("test", Chain.ETHEREUM, TestingCommons.api()) + def up = new EthereumPosRpcUpstreamMock("test", Chain.ETHEREUM, TestingCommons.api()) when: current.update(new UpstreamChange(Chain.ETHEREUM, up, UpstreamChange.ChangeType.ADDED)) then: @@ -37,9 +38,9 @@ class CurrentMultistreamHolderSpec extends Specification { def "add multiple upstreams"() { setup: def current = new CurrentMultistreamHolder(TestingCommons.emptyCaches()) - def up1 = new EthereumRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) + def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC, TestingCommons.api()) - def up3 = new EthereumRpcUpstreamMock("test3", Chain.ETHEREUM, TestingCommons.api()) + def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM, TestingCommons.api()) when: current.update(new UpstreamChange(Chain.ETHEREUM, up1, UpstreamChange.ChangeType.ADDED)) current.update(new UpstreamChange(Chain.ETHEREUM_CLASSIC, up2, UpstreamChange.ChangeType.ADDED)) @@ -53,10 +54,10 @@ class CurrentMultistreamHolderSpec extends Specification { def "remove upstream"() { setup: def current = new CurrentMultistreamHolder(TestingCommons.emptyCaches()) - def up1 = new EthereumRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) + def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC, TestingCommons.api()) - def up3 = new EthereumRpcUpstreamMock("test3", Chain.ETHEREUM, TestingCommons.api()) - def up1_del = new EthereumRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) + def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM, TestingCommons.api()) + def up1_del = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) when: current.update(new UpstreamChange(Chain.ETHEREUM, up1, UpstreamChange.ChangeType.ADDED)) current.update(new UpstreamChange(Chain.ETHEREUM_CLASSIC, up2, UpstreamChange.ChangeType.ADDED)) @@ -71,7 +72,7 @@ class CurrentMultistreamHolderSpec extends Specification { def "available after adding"() { setup: def current = new CurrentMultistreamHolder(TestingCommons.emptyCaches()) - def up1 = new EthereumRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) + def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) when: def act = current.isAvailable(Chain.ETHEREUM) diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy index 5a97148f..42fa96c8 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy @@ -20,10 +20,12 @@ import io.emeraldpay.dshackle.cache.Caches import io.emeraldpay.dshackle.config.UpstreamsConfig import io.emeraldpay.dshackle.quorum.AlwaysQuorum import io.emeraldpay.dshackle.reader.Reader +import io.emeraldpay.dshackle.test.EthereumPosRpcUpstreamMock import io.emeraldpay.dshackle.test.EthereumRpcUpstreamMock import io.emeraldpay.dshackle.test.TestingCommons import io.emeraldpay.dshackle.upstream.calls.DirectCallMethods import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse import io.emeraldpay.grpc.Chain @@ -38,9 +40,9 @@ class MultistreamSpec extends Specification { def "Aggregates methods"() { setup: - def up1 = new EthereumRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2"])) - def up2 = new EthereumRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api(), new DirectCallMethods(["eth_test2", "eth_test3"])) - def aggr = new EthereumMultistream(Chain.ETHEREUM, [up1, up2], Caches.default()) + 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()) when: aggr.onUpstreamsUpdated() def act = aggr.getMethods() diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/ERC20BalanceSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/ERC20BalanceSpec.groovy index 11235509..8de66c50 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/ERC20BalanceSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/ERC20BalanceSpec.groovy @@ -15,6 +15,7 @@ */ package io.emeraldpay.dshackle.upstream.ethereum +import io.emeraldpay.dshackle.test.EthereumPosRpcUpstreamMock import io.emeraldpay.dshackle.test.EthereumRpcUpstreamMock import io.emeraldpay.dshackle.test.ReaderMock import io.emeraldpay.dshackle.upstream.ApiSource @@ -47,7 +48,7 @@ class ERC20BalanceSpec extends Specification { JsonRpcResponse.ok('"0x0000000000000000000000000000000000000000000000000000001f28d72868"') ) - EthereumRpcUpstream upstream = new EthereumRpcUpstreamMock(Chain.ETHEREUM, api) + EthereumPosRpcUpstream upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api) ERC20Token token = new ERC20Token(Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9")) ERC20Balance query = new ERC20Balance() @@ -73,7 +74,7 @@ class ERC20BalanceSpec extends Specification { JsonRpcResponse.ok('"0x0000000000000000000000000000000000000000000000000000001f28d72868"') ) - EthereumRpcUpstream upstream = new EthereumRpcUpstreamMock(Chain.ETHEREUM, api) + EthereumPosRpcUpstream upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api) ERC20Token token = new ERC20Token(Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9")) ERC20Balance query = new ERC20Balance() diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumReaderSpec.groovy index 84c29069..30a273d1 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumReaderSpec.groovy @@ -23,6 +23,7 @@ import io.emeraldpay.dshackle.data.BlockContainer import io.emeraldpay.dshackle.data.BlockId import io.emeraldpay.dshackle.data.TxContainer import io.emeraldpay.dshackle.data.TxId +import io.emeraldpay.dshackle.test.EthereumPosRpcUpstreamMock import io.emeraldpay.dshackle.test.EthereumRpcUpstreamMock import io.emeraldpay.dshackle.test.TestingCommons import io.emeraldpay.dshackle.upstream.Multistream @@ -203,7 +204,7 @@ class EthereumReaderSpec extends Specification { api.answerOnce("eth_getBalance", ["0x70b91ff87a902b53dc6e2f6bda8bb9b330ccd30c", "latest"], "0x10") // height 101 + 1 => 102 => 0x66 api.answerOnce("eth_getBalance", ["0x70b91ff87a902b53dc6e2f6bda8bb9b330ccd30c", "0x66"], "0xff") - EthereumRpcUpstreamMock upstream = new EthereumRpcUpstreamMock(Chain.ETHEREUM, api) + EthereumPosRpcUpstreamMock upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api) def upstreams = TestingCommons.multistream(upstream) def reader = new EthereumReader(upstreams, Caches.default(), calls) reader.start() @@ -241,7 +242,7 @@ class EthereumReaderSpec extends Specification { api.answerOnce("eth_getTransactionReceipt", ["0xf85b826fdf98ee0f48f7db001be00472e63ceb056846f4ecac5f0c32878b8ab2"], [ transactionHash: "0xf85b826fdf98ee0f48f7db001be00472e63ceb056846f4ecac5f0c32878b8ab2" ]) - EthereumRpcUpstreamMock upstream = new EthereumRpcUpstreamMock(Chain.ETHEREUM, api) + EthereumPosRpcUpstreamMock upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api) def upstreams = TestingCommons.multistream(upstream) def reader = new EthereumReader(upstreams, Caches.default(), calls) reader.start() @@ -257,7 +258,7 @@ class EthereumReaderSpec extends Specification { def "Read receipt from cache if available"() { setup: def api = TestingCommons.api() - EthereumRpcUpstreamMock upstream = new EthereumRpcUpstreamMock(Chain.ETHEREUM, api) + EthereumPosRpcUpstreamMock upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api) def upstreams = TestingCommons.multistream(upstream) def receiptCache = Mock(ReceiptRedisCache) { 1 * it.read(TxId.from("0xf85b826fdf98ee0f48f7db001be00472e63ceb056846f4ecac5f0c32878b8ab2")) >> diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumSubscribeSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumSubscribeSpec.groovy index 3a2e116c..fbe98f6a 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumSubscribeSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumSubscribeSpec.groovy @@ -24,7 +24,7 @@ class EthereumSubscribeSpec extends Specification { def "read empty logs request"() { setup: - def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumMultistream) + def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def act = ethereumSubscribe.readLogsRequest([:]) @@ -35,7 +35,7 @@ class EthereumSubscribeSpec extends Specification { def "read single address logs request"() { setup: - def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumMultistream) + def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def act = ethereumSubscribe.readLogsRequest([ address: "0x829bd824b016326a401d083b33d092293333a830" @@ -60,7 +60,7 @@ class EthereumSubscribeSpec extends Specification { def "ignores invalid address for logs request"() { setup: - def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumMultistream) + def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def act = ethereumSubscribe.readLogsRequest([ address: "829bd824b016326a401d083b33d092293333a830" @@ -73,7 +73,7 @@ class EthereumSubscribeSpec extends Specification { def "read multi address logs request"() { setup: - def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumMultistream) + def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def act = ethereumSubscribe.readLogsRequest([ address: ["0x829bd824b016326a401d083b33d092293333a830", "0x401d083b33d092293333a83829bd824b016326a0"] @@ -89,7 +89,7 @@ class EthereumSubscribeSpec extends Specification { def "read single topic logs request"() { setup: - def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumMultistream) + def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def act = ethereumSubscribe.readLogsRequest([ topics: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" @@ -114,7 +114,7 @@ class EthereumSubscribeSpec extends Specification { def "read invalid topic for request"() { setup: - def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumMultistream) + def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def act = ethereumSubscribe.readLogsRequest([ topics: [ @@ -132,7 +132,7 @@ class EthereumSubscribeSpec extends Specification { def "read multi topic logs request"() { setup: - def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumMultistream) + def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def act = ethereumSubscribe.readLogsRequest([ topics: [ @@ -151,7 +151,7 @@ class EthereumSubscribeSpec extends Specification { def "read full logs request"() { setup: - def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumMultistream) + def ethereumSubscribe = new EthereumSubscribe(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def act = ethereumSubscribe.readLogsRequest([ address: "0x298d492e8c1d909d3f63bc4a36c66c64acb3d695", diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ConnectLogsSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ConnectLogsSpec.groovy index 8d823f81..e7186c2a 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ConnectLogsSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ConnectLogsSpec.groovy @@ -17,6 +17,7 @@ package io.emeraldpay.dshackle.upstream.ethereum.subscribe import io.emeraldpay.dshackle.test.TestingCommons import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream +import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.LogMessage import io.emeraldpay.etherjar.domain.Address import io.emeraldpay.etherjar.domain.BlockHash @@ -86,7 +87,7 @@ class ConnectLogsSpec extends Specification { def "Filter is empty"() { setup: - def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream() as EthereumMultistream) + def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def input = Flux.fromIterable([ log1, log2, log3, log4 @@ -104,7 +105,7 @@ class ConnectLogsSpec extends Specification { def "Filter by address"() { setup: - def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream() as EthereumMultistream) + def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def input = Flux.fromIterable([ log1, log2 @@ -119,7 +120,7 @@ class ConnectLogsSpec extends Specification { def "Filter by topic"() { setup: - def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream() as EthereumMultistream) + def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def input = Flux.fromIterable([ log1, log2, log3, log4 @@ -136,7 +137,7 @@ class ConnectLogsSpec extends Specification { def "Filter by address and topic"() { setup: - def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream() as EthereumMultistream) + def connectLogs = new ConnectLogs(TestingCommons.emptyMultistream() as EthereumPosMultiStream) when: def input = Flux.fromIterable([ log1, log2, log3, log4