From f4f34f071e2baf6dffc3d7a721f0ef84f5366b0c Mon Sep 17 00:00:00 2001 From: Maxksim Fomenkov Date: Wed, 14 Sep 2022 16:00:10 +0300 Subject: [PATCH] fixed tests --- .../dshackle/rpc/NativeSubscribe.kt | 4 +++- .../upstream/ethereum/EthereumWsFactory.kt | 2 +- .../connectors/EthereumRpcConnector.kt | 2 +- .../connectors/EthereumWsConnector.kt | 8 ++++--- .../cache/HeightByHashAddingSpec.groovy | 2 +- .../dshackle/cache/ReceiptMemCacheSpec.groovy | 3 ++- .../dshackle/rpc/NativeSubscribeSpec.groovy | 10 +++++---- .../rpc/TrackBitcoinAddressSpec.groovy | 4 ++-- .../dshackle/rpc/TrackBitcoinTxSpec.groovy | 6 +++--- .../dshackle/rpc/TrackERC20AddressSpec.groovy | 3 ++- .../dshackle/rpc/TrackEthereumTxSpec.groovy | 4 ++-- .../dshackle/test/TestingCommons.groovy | 3 ++- .../dshackle/upstream/AbstractHeadSpec.groovy | 4 ++-- .../ethereum/DefaultEthereumHeadSpec.groovy | 2 +- .../EthereumBlockValidatorSpec.groovy | 4 +++- .../EthereumFullBlocksReaderSpec.groovy | 2 +- .../subscribe/ConnectBlockUpdatesSpec.groovy | 2 +- .../ethereum/subscribe/ConnectLogsSpec.groovy | 12 +++++++---- .../ethereum/subscribe/ProduceLogsSpec.groovy | 21 ++++++++++++------- .../subscribe/json/LogMessageSpec.groovy | 3 ++- .../subscribe/json/NewHeadMessageSpec.groovy | 3 ++- .../forkchoice/MostWorkForkChoiceSpec.groovy | 2 +- .../NoChoiceWithPriorityForkChoiceSpec.groovy | 2 +- .../forkchoice/PriorityForkChoiceSpec.groovy | 2 +- .../upstream/signature/EcdsaSignerSpec.groovy | 2 +- 25 files changed, 68 insertions(+), 44 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeSubscribe.kt b/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeSubscribe.kt index ce253fa7..6e8093df 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeSubscribe.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeSubscribe.kt @@ -73,9 +73,11 @@ open class NativeSubscribe( is SilentException.UnsupportedBlockchain -> StatusException( Status.UNAVAILABLE.withDescription("BLOCKCHAIN UNAVAILABLE: ${t.blockchainId}") ) + is UnsupportedOperationException -> StatusException( Status.UNIMPLEMENTED.withDescription(t.message) ) + else -> { log.warn("Unhandled error", t) StatusException( @@ -98,7 +100,7 @@ open class NativeSubscribe( holder.nonce?.also { nonce -> holder.getSource()?.let { - signer.sign(nonce, result, it) + signer.sign(nonce, result, it) }?.let { buildSignature(nonce, it) }?.also { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsFactory.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsFactory.kt index d81cf822..fee1674d 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsFactory.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsFactory.kt @@ -58,7 +58,7 @@ class EthereumWsFactory( ) } - fun create(id: String, upstream: DefaultUpstream?, validator: EthereumUpstreamValidator?): WsConnection { + fun create(upstream: DefaultUpstream?, validator: EthereumUpstreamValidator?): WsConnection { require(upstream == null || upstream.getId() == id) { "Creating instance for different upstream. ${upstream?.getId()} != id" } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumRpcConnector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumRpcConnector.kt index 61a61704..2b46a499 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumRpcConnector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumRpcConnector.kt @@ -34,7 +34,7 @@ class EthereumRpcConnector( init { if (wsFactory != null) { // do not set upstream to the WS, since it doesn't control the RPC upstream - conn = wsFactory.create(id, null, null) + conn = wsFactory.create(null, null) val wsHead = EthereumWsHead(conn, id, forkChoice, blockValidator) // receive bew blocks through WebSockets, but also periodically verify with RPC in case if WS failed val rpcHead = EthereumRpcHead(directReader, forkChoice, id, blockValidator, Duration.ofSeconds(60)) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumWsConnector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumWsConnector.kt index 83fde6b8..0a248e2c 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumWsConnector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumWsConnector.kt @@ -4,12 +4,14 @@ import io.emeraldpay.dshackle.reader.Reader import io.emeraldpay.dshackle.upstream.BlockValidator import io.emeraldpay.dshackle.upstream.DefaultUpstream import io.emeraldpay.dshackle.upstream.Head -import io.emeraldpay.dshackle.upstream.ethereum.* +import io.emeraldpay.dshackle.upstream.ethereum.EthereumUpstreamValidator +import io.emeraldpay.dshackle.upstream.ethereum.EthereumWsFactory +import io.emeraldpay.dshackle.upstream.ethereum.EthereumWsHead +import io.emeraldpay.dshackle.upstream.ethereum.WsConnection import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcWsClient -import io.emeraldpay.grpc.Chain class EthereumWsConnector( wsFactory: EthereumWsFactory, @@ -23,7 +25,7 @@ class EthereumWsConnector( private val head: EthereumWsHead init { - conn = wsFactory.create(upstream.getId(), upstream, validator) + conn = wsFactory.create(upstream, validator) head = EthereumWsHead(conn, upstream.getId(), forkChoice, blockValidator) api = JsonRpcWsClient(conn) } diff --git a/src/test/groovy/io/emeraldpay/dshackle/cache/HeightByHashAddingSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/cache/HeightByHashAddingSpec.groovy index cdb5c8bd..f570f152 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/cache/HeightByHashAddingSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/cache/HeightByHashAddingSpec.groovy @@ -27,7 +27,7 @@ class HeightByHashAddingSpec extends Specification { def block = new BlockContainer( 12079192L, BlockId.from("0xa6af163aab691919c595e2a466f0a7b01f1dff8cfd9631dee811df57064c2d32"), - BigInteger.ONE, Instant.now(), false, "".bytes, null, [], 0 + BigInteger.ONE, Instant.now(), false, "".bytes, null, [], 0, "upstream" ) def "use memory if available"() { diff --git a/src/test/groovy/io/emeraldpay/dshackle/cache/ReceiptMemCacheSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/cache/ReceiptMemCacheSpec.groovy index d950a765..25b950f4 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/cache/ReceiptMemCacheSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/cache/ReceiptMemCacheSpec.groovy @@ -87,7 +87,8 @@ class ReceiptMemCacheSpec extends Specification { "{}".bytes, null, [TxId.from(receipt.transactionHash)], - 0 + 0, + "unknown" ) when: diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy index b4e94ff9..8b680bd2 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy @@ -22,6 +22,7 @@ import io.emeraldpay.dshackle.upstream.Selector 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.signature.NoSigner import io.emeraldpay.grpc.Chain import reactor.core.publisher.Flux import reactor.test.StepVerifier @@ -30,6 +31,7 @@ import spock.lang.Specification import java.time.Duration class NativeSubscribeSpec extends Specification { + def signer = new NoSigner() def "Call with empty params when not provided"() { setup: @@ -40,7 +42,7 @@ class NativeSubscribeSpec extends Specification { 1 * it.getSubscribe() >> subscribe } - def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up)) + def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up), signer) def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder() .setChainValue(Chain.ETHEREUM.id) .setMethod("newHeads") @@ -50,7 +52,7 @@ class NativeSubscribeSpec extends Specification { then: StepVerifier.create(act) - .expectNext("{}") + .expectNext(new NativeSubscribe.ResponseHolder("{}", null)) .expectComplete() .verify(Duration.ofSeconds(1)) } @@ -72,7 +74,7 @@ class NativeSubscribeSpec extends Specification { 1 * it.getSubscribe() >> subscribe } - def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up)) + def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up), signer) def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder() .setChainValue(Chain.ETHEREUM.id) .setMethod("logs") @@ -86,7 +88,7 @@ class NativeSubscribeSpec extends Specification { then: StepVerifier.create(act) - .expectNext("{}") + .expectNext(new NativeSubscribe.ResponseHolder("{}", null)) .expectComplete() .verify(Duration.ofSeconds(1)) } diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinAddressSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinAddressSpec.groovy index 69601c45..b1d9f7c1 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinAddressSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinAddressSpec.groovy @@ -271,7 +271,7 @@ class TrackBitcoinAddressSpec extends Specification { Head head = Mock(Head) { 1 * getFlux() >> Flux.concat( Flux.just( - new BlockContainer(0L, BlockId.from(hash1), BigInteger.ZERO, Instant.now(), false, null, null, [], 0) + new BlockContainer(0L, BlockId.from(hash1), BigInteger.ZERO, Instant.now(), false, null, null, [], 0, "TrackBitcoinAddressSpec") ), blocks.asFlux() ) @@ -312,7 +312,7 @@ class TrackBitcoinAddressSpec extends Specification { StepVerifier.create(resp) .expectNext("0") .then { - blocks.tryEmitNext(new BlockContainer(1L, BlockId.from(hash1), BigInteger.ONE, Instant.now(), false, null, null, [], 0)) + blocks.tryEmitNext(new BlockContainer(1L, BlockId.from(hash1), BigInteger.ONE, Instant.now(), false, null, null, [], 0, "TrackBitcoinAddressSpec")) } .expectNext("1230000") .then { diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinTxSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinTxSpec.groovy index b1f36eba..a4f6e5df 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinTxSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinTxSpec.groovy @@ -142,7 +142,7 @@ class TrackBitcoinTxSpec extends Specification { def txid = "69cd44d7c641db82e69824523c7ac0c5c1e5628f025474529cf5ffe64527efc9" // start with the current block def next = Flux.fromIterable([10, 12, 13, 14, 15]).map { h -> - new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0) + new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0, "unknown") } Head head = Mock(Head) { 1 * getFlux() >> next @@ -173,7 +173,7 @@ class TrackBitcoinTxSpec extends Specification { def txid = "69cd44d7c641db82e69824523c7ac0c5c1e5628f025474529cf5ffe64527efc9" // start with the current block def next = Flux.fromIterable([10, 12, 13]).map { h -> - new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0) + new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0, "unknown") } Head head = Mock(Head) { 1 * getFlux() >> next @@ -268,7 +268,7 @@ class TrackBitcoinTxSpec extends Specification { ]) } def next = Flux.fromIterable([10, 11, 12]).map { h -> - new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0) + new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0, "unknown") } Head head = Mock(Head) { _ * getFlux() >> next diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy index 2a347a9a..86fc1553 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy @@ -165,7 +165,8 @@ class TrackERC20AddressSpec extends Specification { ], TransactionId.from("0x5a7898e27120575c33d3d0179af3b6353c7268bbad4255df079ed26b743a21a5"), 1, - false + false, + "unknown" ) ] def logs = Mock(ConnectLogs) { diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy index 1289714e..178b794f 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy @@ -199,7 +199,7 @@ class TrackEthereumTxSpec extends Specification { def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM, Instant.now(), TransactionId.from(txId), 6) def block = new BlockContainer( 100, BlockId.from(txId), BigInteger.ONE, Instant.now(), false, "".bytes, null, - [TxId.from(txId)], 0 + [TxId.from(txId)], 0, "unknown" ) when: @@ -222,7 +222,7 @@ class TrackEthereumTxSpec extends Specification { def block = new BlockContainer( 100, BlockId.from(txId), BigInteger.ONE, Instant.now(), false, "".bytes, null, [TxId.from("0xa0e65cbc1b52a8ca60562112c6060552d882f16f34a9dba2ccdc05c0a6a27c22")], - 0 + 0, "unknown" ) apiMock.answer("eth_getTransactionByHash", [txId], null) diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy index f2cac503..3d3ae1fc 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy @@ -114,7 +114,8 @@ class TestingCommons { null, null, [], - 0 + 0, + "upstream" ) } diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/AbstractHeadSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/AbstractHeadSpec.groovy index 028c9150..10253819 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/AbstractHeadSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/AbstractHeadSpec.groovy @@ -34,7 +34,7 @@ class AbstractHeadSpec extends Specification { def blocks = [1L, 2, 3, 4].collect { i -> byte[] hash = new byte[32] hash[0] = i as byte - new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0) + new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0, "AbstractHeadSpec") } def "Calls beforeBlock on each block"() { @@ -96,7 +96,7 @@ class AbstractHeadSpec extends Specification { blocks[1].height, BlockId.from(blocks[1].hash.value.clone().tap { it[1] = 0xff as byte }), blocks[1].difficulty - 1, Instant.now(), - false, null, null, [], 0 + false, null, null, [], 0, "AbstractHeadSpec" ) when: head.follow(source.asFlux()) diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/DefaultEthereumHeadSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/DefaultEthereumHeadSpec.groovy index f0c3fc77..d94914c9 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/DefaultEthereumHeadSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/DefaultEthereumHeadSpec.groovy @@ -32,7 +32,7 @@ import java.time.Instant class DefaultEthereumHeadSpec extends Specification { - DefaultEthereumHead head = new DefaultEthereumHead(new MostWorkForkChoice(), BlockValidator.@Companion.ALWAYS_VALID) + DefaultEthereumHead head = new DefaultEthereumHead("upstream", new MostWorkForkChoice(), BlockValidator.@Companion.ALWAYS_VALID) ObjectMapper objectMapper = Global.objectMapper def blocks = (10L..20L).collect { i -> diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumBlockValidatorSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumBlockValidatorSpec.groovy index d52201f8..571e415c 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumBlockValidatorSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumBlockValidatorSpec.groovy @@ -52,6 +52,8 @@ class EthereumBlockValidatorSpec extends Specification { true, bytes, block, Collections.emptyList(), - 1) + 1, + "upstream" + ) } } diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumFullBlocksReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumFullBlocksReaderSpec.groovy index 0583c05d..0d81a0da 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumFullBlocksReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumFullBlocksReaderSpec.groovy @@ -302,7 +302,7 @@ class EthereumFullBlocksReaderSpec extends Specification { "extraField2": "extraValue2" } ''' - blocks.add(BlockContainer.fromEthereumJson(blockJson.bytes)) + blocks.add(BlockContainer.fromEthereumJson(blockJson.bytes, "EthereumFullBlocksReaderSpec")) def tx1 = ''' { diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ConnectBlockUpdatesSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ConnectBlockUpdatesSpec.groovy index e9557335..f294225e 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ConnectBlockUpdatesSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ConnectBlockUpdatesSpec.groovy @@ -81,7 +81,7 @@ class ConnectBlockUpdatesSpec extends Specification { ] }) when: - def act = connectBlockUpdates.whenReplaced(block) + def act = connectBlockUpdates.whenReplaced(block, "ConnectBlockUpdatesSpec") .collectList().block(Duration.ofSeconds(3)) then: 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 e7186c2a..1c49c95e 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 @@ -40,7 +40,8 @@ class ConnectLogsSpec extends Specification { ], TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"), 1L, - false + false, + "upstream" ) def log2 = new LogMessage( @@ -54,7 +55,8 @@ class ConnectLogsSpec extends Specification { ], TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"), 1L, - false + false, + "upstream" ) def log3 = new LogMessage( @@ -68,7 +70,8 @@ class ConnectLogsSpec extends Specification { ], TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"), 1L, - false + false, + "upstream" ) def log4 = new LogMessage( @@ -82,7 +85,8 @@ class ConnectLogsSpec extends Specification { ], TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"), 1L, - false + false, + "upstream" ) def "Filter is empty"() { diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ProduceLogsSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ProduceLogsSpec.groovy index c0d2ba67..b5165489 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ProduceLogsSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/ProduceLogsSpec.groovy @@ -45,7 +45,8 @@ class ProduceLogsSpec extends Specification { BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), 13412871, ConnectBlockUpdates.UpdateType.NEW, - TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af") + TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af"), + "upstream" ) when: def act = producer.produceAdded(update) @@ -67,7 +68,8 @@ class ProduceLogsSpec extends Specification { BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), 13412871, ConnectBlockUpdates.UpdateType.NEW, - TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af") + TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af"), + "upstream" ) when: def act = producer.produceAdded(update) @@ -112,7 +114,8 @@ class ProduceLogsSpec extends Specification { BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), 13412871, ConnectBlockUpdates.UpdateType.NEW, - TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af") + TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af"), + "upstream" ) when: def act = producer.produceAdded(update) @@ -157,7 +160,8 @@ class ProduceLogsSpec extends Specification { BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), 13412871, ConnectBlockUpdates.UpdateType.NEW, - TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af") + TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af"), + "upstream" ) when: def act = producer.produceAdded(update) @@ -267,7 +271,8 @@ class ProduceLogsSpec extends Specification { BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), 13412871, ConnectBlockUpdates.UpdateType.NEW, - TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec") + TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"), + "upstream" ) when: def act = producer.produceAdded(update) @@ -345,13 +350,15 @@ class ProduceLogsSpec extends Specification { BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), 13412871, ConnectBlockUpdates.UpdateType.NEW, - TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec") + TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"), + "upstream" ) def update2 = new ConnectBlockUpdates.Update( BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), 13412871, ConnectBlockUpdates.UpdateType.DROP, - TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec") + TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"), + "upstream" ) when: // first need to produce them as added, because that's when it remembers logs to "remove" diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/json/LogMessageSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/json/LogMessageSpec.groovy index 826dd710..da1aa41a 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/json/LogMessageSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/json/LogMessageSpec.groovy @@ -41,7 +41,8 @@ class LogMessageSpec extends Specification { ], TransactionId.from("0xc7529e79f78f58125abafeaea01fe3abdc6f45c173d5dfb36716cbc526e5b2d1"), 0xa3, - false) + false, + "LogMessageSpec") ObjectMapper objectMapper = Global.getObjectMapper() def exp = '{' + '"address":"0x011b6e24ffb0b5f5fcc564cf4183c5bbbc96d515",' + diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/json/NewHeadMessageSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/json/NewHeadMessageSpec.groovy index e490083e..f0db8a88 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/json/NewHeadMessageSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/json/NewHeadMessageSpec.groovy @@ -23,7 +23,8 @@ class NewHeadMessageSpec extends Specification { 0x7bb33e, Bloom.from("0x012040020880820356a20b8e980a2004c19f1291800501040001180bb029d0002d8c49440e002048ca00d48581000d900a458100c90139056140880582f22a0a8050224c020c233be8c3080c0a016aa4226a2001446c800822080445a2454118139804001202068401841900840c484222420c4b2022046052c0011e81a9e450085883708545810592e40040010411442300080b0130711f602880600a30c90702cb420a0102a644820650908802840810948142541404884300acc69d000840702020224c000020200880c10858418408098a61445b0ab0480234862655a5000434311b91044849c165040411aa0400b00008222642d24313020d9022219120"), Address.from("0x829bd824b016326a401d083b33d092293333a830"), - null + null, + "NewHeadMessageSpec" ) ObjectMapper objectMapper = Global.getObjectMapper() def exp = '{' + diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/MostWorkForkChoiceSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/MostWorkForkChoiceSpec.groovy index dac1ec85..e4488f23 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/MostWorkForkChoiceSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/MostWorkForkChoiceSpec.groovy @@ -11,7 +11,7 @@ class MostWorkForkChoiceSpec extends Specification { def blocks = [1L, 2, 3, 4].collect { i -> byte[] hash = new byte[32] hash[0] = i as byte - new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0) + new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0, "MostWorkForkChoiceSpec") } def "filters blocks"() { diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/NoChoiceWithPriorityForkChoiceSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/NoChoiceWithPriorityForkChoiceSpec.groovy index 20f90dae..6f862f60 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/NoChoiceWithPriorityForkChoiceSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/NoChoiceWithPriorityForkChoiceSpec.groovy @@ -10,7 +10,7 @@ class NoChoiceWithPriorityForkChoiceSpec extends Specification { def blocks = [1L, 2, 3, 4].collect { i -> byte[] hash = new byte[32] hash[0] = i as byte - new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0) + new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0, "NoChoiceWithPriorityForkChoiceSpec") } def "filters blocks"() { diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/PriorityForkChoiceSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/PriorityForkChoiceSpec.groovy index 25848281..7ef34289 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/PriorityForkChoiceSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/forkchoice/PriorityForkChoiceSpec.groovy @@ -10,7 +10,7 @@ class PriorityForkChoiceSpec extends Specification { def blocks = [1L, 2, 3, 4].collect { i -> byte[] hash = new byte[32] hash[0] = i as byte - new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], i.toInteger()) + new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], i.toInteger(), "PriorityForkChoiceSpec") } def "filters blocks"() { def choice = new PriorityForkChoice() diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/signature/EcdsaSignerSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/signature/EcdsaSignerSpec.groovy index 13a32cfe..408488b7 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/signature/EcdsaSignerSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/signature/EcdsaSignerSpec.groovy @@ -95,7 +95,7 @@ class EcdsaSignerSpec extends Specification { def signer = new EcdsaSigner(Stub(ECPrivateKey), 100L) when: - def act = signer.wrapMessage(10, "test".bytes, up) + def act = signer.wrapMessage(10, "test".bytes, up.id) then: act == "DSHACKLESIG/10/infura/9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"