From aff954b53325b0a521a66140099942f613544e91 Mon Sep 17 00:00:00 2001 From: a10zn8 Date: Thu, 29 Jun 2023 00:01:53 +0400 Subject: [PATCH] refactor chain names --- .../io/emeraldpay/dshackle/BlockchainType.kt | 48 +++++------ .../kotlin/io/emeraldpay/dshackle/Chain.kt | 48 +++++------ .../kotlin/io/emeraldpay/dshackle/Global.kt | 66 +++++++------- .../dshackle/rpc/TrackBitcoinAddress.kt | 2 +- .../upstream/calls/DefaultEthereumMethods.kt | 86 +++++++++---------- .../upstream/ethereum/EthereumMultistream.kt | 26 +++--- .../cache/BlocksRedisCacheSpec.groovy | 2 +- .../cache/HeightByHashRedisCacheSpec.groovy | 2 +- .../cache/ReceiptRedisCacheSpec.groovy | 2 +- .../dshackle/cache/TxRedisCacheSpec.groovy | 2 +- .../config/ChainsConfigReaderSpec.groovy | 8 +- .../config/HealthConfigReaderSpec.groovy | 6 +- .../config/MainConfigReaderSpec.groovy | 12 +-- .../config/ProxyConfigReaderSpec.groovy | 10 +-- .../config/TokensConfigReaderSpec.groovy | 4 +- .../monitoring/HealthCheckSetupSpec.groovy | 33 ++++--- .../accesslog/AccessLogWriterSpec.groovy | 4 +- .../EventsBuilderSubscribeBalanceSpec.groovy | 4 +- .../dshackle/proxy/BaseHandlerSpec.groovy | 14 +-- .../dshackle/proxy/HttpHandlerSpec.groovy | 10 +-- .../dshackle/proxy/ProxyServerSpec.groovy | 4 +- .../proxy/WebsocketHandlerSpec.groovy | 18 ++-- .../quorum/QuorumRpcReaderSpec.groovy | 18 ++-- .../dshackle/rpc/NativeCallSpec.groovy | 44 +++++----- .../dshackle/rpc/NativeSubscribeSpec.groovy | 12 +-- .../dshackle/rpc/StreamHeadSpec.groovy | 12 +-- .../dshackle/rpc/SubscribeStatusSpec.groovy | 8 +- .../rpc/TrackBitcoinAddressSpec.groovy | 28 +++--- .../dshackle/rpc/TrackBitcoinTxSpec.groovy | 4 +- .../dshackle/rpc/TrackERC20AddressSpec.groovy | 42 ++++----- .../rpc/TrackEthereumAddressSpec.groovy | 6 +- .../dshackle/rpc/TrackEthereumTxSpec.groovy | 24 +++--- .../startup/ConfiguredUpstreamsSpec.groovy | 6 +- .../test/EthereumPosRpcUpstreamMock.groovy | 2 +- .../test/EthereumRpcUpstreamMock.groovy | 2 +- .../dshackle/test/TestingCommons.groovy | 20 ++--- .../CurrentMultistreamHolderSpec.groovy | 58 ++++++------- .../dshackle/upstream/FilteredApisSpec.groovy | 36 ++++---- .../dshackle/upstream/MultistreamSpec.groovy | 26 +++--- .../calls/DefaultEthereumMethodsSpec.groovy | 38 ++++---- .../calls/ManagedCallMethodsSpec.groovy | 10 +-- .../upstream/ethereum/ERC20BalanceSpec.groovy | 6 +- .../ethereum/EthereumCachingReaderSpec.groovy | 24 +++--- .../ethereum/EthereumLocalReaderSpec.groovy | 16 ++-- .../ethereum/WsConnectionImplRealSpec.groovy | 4 +- .../ethereum/WsConnectionImplSpec.groovy | 6 +- .../DshacklePendingTxesSourceSpec.groovy | 8 +- .../grpc/EthereumGrpcUpstreamSpec.groovy | 10 +-- .../upstream/grpc/GrpcHeadSpec.groovy | 8 +- .../rpcclient/JsonRpcGrpcClientSpec.groovy | 6 +- .../io/emeraldpay/dshackle/IntegrationTest.kt | 2 +- .../dshackle/config/ChainsConfigTest.kt | 20 ++--- 52 files changed, 458 insertions(+), 459 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/BlockchainType.kt b/src/main/kotlin/io/emeraldpay/dshackle/BlockchainType.kt index 450c8ba9..fe02425b 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/BlockchainType.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/BlockchainType.kt @@ -6,36 +6,36 @@ enum class BlockchainType { companion object { @JvmStatic fun from(chain: Chain): BlockchainType { - if (chain == Chain.TESTNET_ROPSTEN || - chain == Chain.POLYGON || - chain == Chain.OPTIMISM || - chain == Chain.ARBITRUM || - chain == Chain.BSC || - chain == Chain.TESTNET_GOERLI || - chain == Chain.ETHEREUM || - chain == Chain.TESTNET_SEPOLIA || - chain == Chain.TESTNET_ARBITRUM || - chain == Chain.TESTNET_OPTIMISM || - chain == Chain.ARBITRUM_NOVA || - chain == Chain.POLYGON_ZKEVM || - chain == Chain.TESTNET_POLYGON_ZKEVM || - chain == Chain.ZKSYNC || - chain == Chain.TESTNET_ZKSYNC || - chain == Chain.TESTNET_POYGON_POS_MUMBAI + if (chain == Chain.ETHEREUM__ROPSTEN || + chain == Chain.POLYGON_POS__MAINNET || + chain == Chain.OPTIMISM__MAINNET || + chain == Chain.ARBITRUM__MAINNET || + chain == Chain.BSC__MAINNET || + chain == Chain.ETHEREUM__GOERLI || + chain == Chain.ETHEREUM__MAINNET || + chain == Chain.ETHEREUM__SEPOLIA || + chain == Chain.ARBITRUM__GOERLI || + chain == Chain.OPTIMISM__GOERLI || + chain == Chain.ARBITRUM_NOVA__MAINNET || + chain == Chain.POLYGON_ZKEVM__MAINNET || + chain == Chain.POLYGON_ZKEVM__TESTNET || + chain == Chain.ZKSYNC__MAINNET || + chain == Chain.ZKSYNC__TESTNET || + chain == Chain.POYGON_POS__MUMBAI ) { return EVM_POS } - if (chain == Chain.ETHEREUM_CLASSIC || - chain == Chain.FANTOM || - chain == Chain.RSK || - chain == Chain.TESTNET_KOVAN || - chain == Chain.TESTNET_MORDEN || - chain == Chain.TESTNET_RINKEBY + if (chain == Chain.ETHEREUM_CLASSIC__MAINNET || + chain == Chain.FANTOM__MAINNET || + chain == Chain.RSK__MAINNET || + chain == Chain.ETHEREUM__KOVAN || + chain == Chain.ETHEREUM__MORDEN || + chain == Chain.ETHEREUM__RINKEBY ) { return EVM_POW } - if (chain == Chain.BITCOIN || - chain == Chain.TESTNET_BITCOIN + if (chain == Chain.BITCOIN__MAINNET || + chain == Chain.BITCOIN__TESTNET ) { return BITCOIN } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/Chain.kt b/src/main/kotlin/io/emeraldpay/dshackle/Chain.kt index b918fc3a..1511ca3f 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/Chain.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/Chain.kt @@ -17,70 +17,70 @@ package io.emeraldpay.dshackle enum class Chain(val id: Int, val chainCode: String, val chainName: String) { UNSPECIFIED(0, "UNSPECIFIED", "Unknown"), - BITCOIN(1, "BTC", "Bitcoin"), // GRIN(2, "GRIN", "Grin"), + BITCOIN__MAINNET(1, "BTC", "Bitcoin"), // GRIN(2, "GRIN", "Grin"), // Networks with tokens - ETHEREUM(100, "ETH", "Ethereum"), - ETHEREUM_CLASSIC(101, "ETC", "Ethereum Classic"), - FANTOM( + ETHEREUM__MAINNET(100, "ETH", "Ethereum"), + ETHEREUM_CLASSIC__MAINNET(101, "ETC", "Ethereum Classic"), + FANTOM__MAINNET( 102, "FTM", "Fantom" ), // LIGHTNING(1001, "BTC_LN", "Bitcoin Lightning"), - POLYGON(1002, "POLYGON", "Polygon Matic"), - RSK(1003, "RSK", "Bitcoin RSK"), - ARBITRUM( + POLYGON_POS__MAINNET(1002, "POLYGON", "Polygon Matic"), + RSK__MAINNET(1003, "RSK", "Bitcoin RSK"), + ARBITRUM__MAINNET( 1004, "ARBITRUM", "Arbitrum" ), - OPTIMISM(1005, "OPTIMISM", "Optimism"), - BSC(1006, "BSC", "Binance Smart Chain"), - POLYGON_ZKEVM( + OPTIMISM__MAINNET(1005, "OPTIMISM", "Optimism"), + BSC__MAINNET(1006, "BSC", "Binance Smart Chain"), + POLYGON_ZKEVM__MAINNET( 1007, "POLYGON_ZKEVM", "Polygon ZK-EVM" ), - ARBITRUM_NOVA( + ARBITRUM_NOVA__MAINNET( 1008, "ARBITRUM_NOVA", "Arbitrum Nova" ), - ZKSYNC(1009, "ZKSYNC", "ZkSync Era"), + ZKSYNC__MAINNET(1009, "ZKSYNC", "ZkSync Era"), // Testnets - TESTNET_MORDEN(10001, "MORDEN", "Morden Testnet"), - TESTNET_KOVAN(10002, "KOVAN", "Kovan Testnet"), - TESTNET_BITCOIN( + ETHEREUM__MORDEN(10001, "MORDEN", "Morden Testnet"), + ETHEREUM__KOVAN(10002, "KOVAN", "Kovan Testnet"), + BITCOIN__TESTNET( 10003, "TESTNET_BITCOIN", "Bitcoin Testnet" ), // TESTNET_FLOONET(10004, "FLOONET", "Floonet Testnet"), - TESTNET_GOERLI(10005, "GOERLI", "Goerli Testnet"), - TESTNET_ROPSTEN( + ETHEREUM__GOERLI(10005, "GOERLI", "Goerli Testnet"), + ETHEREUM__ROPSTEN( 10006, "ROPSTEN", "Ropsten Testnet" ), - TESTNET_RINKEBY(10007, "RINKEBY", "Rinkeby Testnet"), - TESTNET_SEPOLIA(10008, "SEPOLIA", "Sepolia Testnet"), - TESTNET_ARBITRUM( + ETHEREUM__RINKEBY(10007, "RINKEBY", "Rinkeby Testnet"), + ETHEREUM__SEPOLIA(10008, "SEPOLIA", "Sepolia Testnet"), + ARBITRUM__GOERLI( 10009, "ARBITRUM_TESTNET", "Arbitrum Testnet" ), - TESTNET_OPTIMISM(10010, "OPTIMISM_TESTNET", "Optimism Testnet"), - TESTNET_POLYGON_ZKEVM( + OPTIMISM__GOERLI(10010, "OPTIMISM_TESTNET", "Optimism Testnet"), + POLYGON_ZKEVM__TESTNET( 10011, "POLYGON_ZKEVM_TESTNET", "Polygon ZK-EVM Testnet" ), - TESTNET_ZKSYNC( + ZKSYNC__TESTNET( 10012, "ZKS_TESTNET", "ZkSync Testnet" ), - TESTNET_POYGON_POS_MUMBAI( + POYGON_POS__MUMBAI( 10013, "POLYGON_POS_MUMBAI", "Polygon POS Mumbai Testnet" diff --git a/src/main/kotlin/io/emeraldpay/dshackle/Global.kt b/src/main/kotlin/io/emeraldpay/dshackle/Global.kt index 7ee41e9c..39eb25d6 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/Global.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/Global.kt @@ -44,39 +44,39 @@ class Global { var metricsExtended = false val chainNames = mapOf( - "ethereum" to Chain.ETHEREUM, - "ethereum-classic" to Chain.ETHEREUM_CLASSIC, - "eth" to Chain.ETHEREUM, - "polygon" to Chain.POLYGON, - "matic" to Chain.POLYGON, - "arbitrum" to Chain.ARBITRUM, - "arb" to Chain.ARBITRUM, - "optimism" to Chain.OPTIMISM, - "binance" to Chain.BSC, - "bsc" to Chain.BSC, - "bnb-smart-chain" to Chain.BSC, - "etc" to Chain.ETHEREUM_CLASSIC, - "morden" to Chain.TESTNET_MORDEN, - "kovan" to Chain.TESTNET_KOVAN, - "kovan-testnet" to Chain.TESTNET_KOVAN, - "goerli" to Chain.TESTNET_GOERLI, - "goerli-testnet" to Chain.TESTNET_GOERLI, - "rinkeby" to Chain.TESTNET_RINKEBY, - "rinkeby-testnet" to Chain.TESTNET_RINKEBY, - "ropsten" to Chain.TESTNET_ROPSTEN, - "ropsten-testnet" to Chain.TESTNET_ROPSTEN, - "bitcoin" to Chain.BITCOIN, - "bitcoin-testnet" to Chain.TESTNET_BITCOIN, - "sepolia" to Chain.TESTNET_SEPOLIA, - "sepolia-testnet" to Chain.TESTNET_SEPOLIA, - "optimism-testnet" to Chain.TESTNET_OPTIMISM, - "arbitrum-testnet" to Chain.TESTNET_ARBITRUM, - "arbitrum-nova" to Chain.ARBITRUM_NOVA, - "polygon-zkevm" to Chain.POLYGON_ZKEVM, - "polygon-zkevm-testnet" to Chain.TESTNET_POLYGON_ZKEVM, - "zksync" to Chain.ZKSYNC, - "zksync-testnet" to Chain.TESTNET_ZKSYNC, - "polygon-mumbai" to Chain.TESTNET_POYGON_POS_MUMBAI, + "ethereum" to Chain.ETHEREUM__MAINNET, + "ethereum-classic" to Chain.ETHEREUM_CLASSIC__MAINNET, + "eth" to Chain.ETHEREUM__MAINNET, + "polygon" to Chain.POLYGON_POS__MAINNET, + "matic" to Chain.POLYGON_POS__MAINNET, + "arbitrum" to Chain.ARBITRUM__MAINNET, + "arb" to Chain.ARBITRUM__MAINNET, + "optimism" to Chain.OPTIMISM__MAINNET, + "binance" to Chain.BSC__MAINNET, + "bsc" to Chain.BSC__MAINNET, + "bnb-smart-chain" to Chain.BSC__MAINNET, + "etc" to Chain.ETHEREUM_CLASSIC__MAINNET, + "morden" to Chain.ETHEREUM__MORDEN, + "kovan" to Chain.ETHEREUM__KOVAN, + "kovan-testnet" to Chain.ETHEREUM__KOVAN, + "goerli" to Chain.ETHEREUM__GOERLI, + "goerli-testnet" to Chain.ETHEREUM__GOERLI, + "rinkeby" to Chain.ETHEREUM__RINKEBY, + "rinkeby-testnet" to Chain.ETHEREUM__RINKEBY, + "ropsten" to Chain.ETHEREUM__ROPSTEN, + "ropsten-testnet" to Chain.ETHEREUM__ROPSTEN, + "bitcoin" to Chain.BITCOIN__MAINNET, + "bitcoin-testnet" to Chain.BITCOIN__TESTNET, + "sepolia" to Chain.ETHEREUM__SEPOLIA, + "sepolia-testnet" to Chain.ETHEREUM__SEPOLIA, + "optimism-testnet" to Chain.OPTIMISM__GOERLI, + "arbitrum-testnet" to Chain.ARBITRUM__GOERLI, + "arbitrum-nova" to Chain.ARBITRUM_NOVA__MAINNET, + "polygon-zkevm" to Chain.POLYGON_ZKEVM__MAINNET, + "polygon-zkevm-testnet" to Chain.POLYGON_ZKEVM__TESTNET, + "zksync" to Chain.ZKSYNC__MAINNET, + "zksync-testnet" to Chain.ZKSYNC__TESTNET, + "polygon-mumbai" to Chain.POYGON_POS__MUMBAI, ) fun chainById(id: String?): Chain { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackBitcoinAddress.kt b/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackBitcoinAddress.kt index afea9881..fcdccd3b 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackBitcoinAddress.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/rpc/TrackBitcoinAddress.kt @@ -287,7 +287,7 @@ class TrackBitcoinAddress( // TODO use bitcoin class for address class Address(val chain: Chain, val address: String) { - val network = if (chain == Chain.BITCOIN) { + val network = if (chain == Chain.BITCOIN__MAINNET) { MainNetParams() } else { TestNet3Params() diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethods.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethods.kt index a3c7e38e..e370986b 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethods.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethods.kt @@ -172,10 +172,10 @@ class DefaultEthereumMethods( private fun getChainSpecificMethods(chain: Chain): List { return when (chain) { - Chain.OPTIMISM, Chain.TESTNET_OPTIMISM -> listOf( + Chain.OPTIMISM__MAINNET, Chain.OPTIMISM__GOERLI -> listOf( "rollup_gasPrices" ) - Chain.POLYGON, Chain.TESTNET_POYGON_POS_MUMBAI -> listOf( + Chain.POLYGON_POS__MAINNET, Chain.POYGON_POS__MUMBAI -> listOf( "bor_getAuthor", "bor_getCurrentValidators", "bor_getCurrentProposer", @@ -183,7 +183,7 @@ class DefaultEthereumMethods( "bor_getSignersAtHash", "eth_getRootHash" ) - Chain.POLYGON_ZKEVM, Chain.TESTNET_POLYGON_ZKEVM -> listOf( + Chain.POLYGON_ZKEVM__MAINNET, Chain.POLYGON_ZKEVM__TESTNET -> listOf( "zkevm_consolidatedBlockNumber", "zkevm_isBlockConsolidated", "zkevm_isBlockVirtualized", @@ -194,7 +194,7 @@ class DefaultEthereumMethods( "zkevm_getBatchByNumber", "zkevm_getBroadcastURI" ) - Chain.ZKSYNC, Chain.TESTNET_ZKSYNC -> listOf( + Chain.ZKSYNC__MAINNET, Chain.ZKSYNC__TESTNET -> listOf( "zks_estimateFee", "zks_estimateGasL1ToL2", "zks_getAllAccountBalances", @@ -219,7 +219,7 @@ class DefaultEthereumMethods( } private fun chainUnsupportedMethods(chain: Chain): Set { - if (chain == Chain.OPTIMISM) { + if (chain == Chain.OPTIMISM__MAINNET) { return setOf("eth_getAccounts") } return emptySet() @@ -239,79 +239,79 @@ class DefaultEthereumMethods( val json = when (method) { "net_version" -> { when { - Chain.ETHEREUM == chain -> { + Chain.ETHEREUM__MAINNET == chain -> { "\"1\"" } - Chain.ETHEREUM_CLASSIC == chain -> { + Chain.ETHEREUM_CLASSIC__MAINNET == chain -> { "\"1\"" } - Chain.POLYGON == chain -> { + Chain.POLYGON_POS__MAINNET == chain -> { "\"137\"" } - Chain.TESTNET_MORDEN == chain -> { + Chain.ETHEREUM__MORDEN == chain -> { "\"2\"" } - Chain.TESTNET_ROPSTEN == chain -> { + Chain.ETHEREUM__ROPSTEN == chain -> { "\"3\"" } - Chain.TESTNET_RINKEBY == chain -> { + Chain.ETHEREUM__RINKEBY == chain -> { "\"4\"" } - Chain.TESTNET_KOVAN == chain -> { + Chain.ETHEREUM__KOVAN == chain -> { "\"42\"" } - Chain.TESTNET_GOERLI == chain -> { + Chain.ETHEREUM__GOERLI == chain -> { "\"5\"" } - Chain.TESTNET_SEPOLIA == chain -> { + Chain.ETHEREUM__SEPOLIA == chain -> { "\"11155111\"" } - Chain.ARBITRUM == chain -> { + Chain.ARBITRUM__MAINNET == chain -> { "\"42161\"" } - Chain.OPTIMISM == chain -> { + Chain.OPTIMISM__MAINNET == chain -> { "\"10\"" } - Chain.TESTNET_ARBITRUM == chain -> { + Chain.ARBITRUM__GOERLI == chain -> { "\"421613\"" } - Chain.TESTNET_OPTIMISM == chain -> { + Chain.OPTIMISM__GOERLI == chain -> { "\"420\"" } - Chain.ARBITRUM_NOVA == chain -> { + Chain.ARBITRUM_NOVA__MAINNET == chain -> { "\"42170\"" } - Chain.POLYGON_ZKEVM == chain -> { + Chain.POLYGON_ZKEVM__MAINNET == chain -> { "\"1101\"" } - Chain.TESTNET_POLYGON_ZKEVM == chain -> { + Chain.POLYGON_ZKEVM__TESTNET == chain -> { "\"1442\"" } - Chain.ZKSYNC == chain -> { + Chain.ZKSYNC__MAINNET == chain -> { "\"324\"" } - Chain.TESTNET_ZKSYNC == chain -> { + Chain.ZKSYNC__TESTNET == chain -> { "\"280\"" } - Chain.TESTNET_POYGON_POS_MUMBAI == chain -> { + Chain.POYGON_POS__MUMBAI == chain -> { "\"80001\"" } @@ -321,79 +321,79 @@ class DefaultEthereumMethods( "eth_chainId" -> { when { - Chain.ETHEREUM == chain -> { + Chain.ETHEREUM__MAINNET == chain -> { "\"0x1\"" } - Chain.POLYGON == chain -> { + Chain.POLYGON_POS__MAINNET == chain -> { "\"0x89\"" } - Chain.TESTNET_ROPSTEN == chain -> { + Chain.ETHEREUM__ROPSTEN == chain -> { "\"0x3\"" } - Chain.TESTNET_RINKEBY == chain -> { + Chain.ETHEREUM__RINKEBY == chain -> { "\"0x4\"" } - Chain.ETHEREUM_CLASSIC == chain -> { + Chain.ETHEREUM_CLASSIC__MAINNET == chain -> { "\"0x3d\"" } - Chain.TESTNET_MORDEN == chain -> { + Chain.ETHEREUM__MORDEN == chain -> { "\"0x3c\"" } - Chain.TESTNET_KOVAN == chain -> { + Chain.ETHEREUM__KOVAN == chain -> { "\"0x2a\"" } - Chain.TESTNET_GOERLI == chain -> { + Chain.ETHEREUM__GOERLI == chain -> { "\"0x5\"" } - Chain.TESTNET_SEPOLIA == chain -> { + Chain.ETHEREUM__SEPOLIA == chain -> { "\"0xaa36a7\"" } - Chain.ARBITRUM == chain -> { + Chain.ARBITRUM__MAINNET == chain -> { "\"0xa4b1\"" } - Chain.OPTIMISM == chain -> { + Chain.OPTIMISM__MAINNET == chain -> { "\"0xa\"" } - Chain.TESTNET_ARBITRUM == chain -> { + Chain.ARBITRUM__GOERLI == chain -> { "\"0x66eed\"" } - Chain.TESTNET_OPTIMISM == chain -> { + Chain.OPTIMISM__GOERLI == chain -> { "\"0x1A4\"" } - Chain.ARBITRUM_NOVA == chain -> { + Chain.ARBITRUM_NOVA__MAINNET == chain -> { "\"0xa4ba\"" } - Chain.POLYGON_ZKEVM == chain -> { + Chain.POLYGON_ZKEVM__MAINNET == chain -> { "\"0x44d\"" } - Chain.TESTNET_POLYGON_ZKEVM == chain -> { + Chain.POLYGON_ZKEVM__TESTNET == chain -> { "\"0x5a2\"" } - Chain.ZKSYNC == chain -> { + Chain.ZKSYNC__MAINNET == chain -> { "\"0x144\"" } - Chain.TESTNET_ZKSYNC == chain -> { + Chain.ZKSYNC__TESTNET == chain -> { "\"0x118\"" } - Chain.TESTNET_POYGON_POS_MUMBAI == chain -> { + Chain.POYGON_POS__MUMBAI == chain -> { "\"0x13881\"" } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumMultistream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumMultistream.kt index 7e9ac2ef..e53c3c66 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumMultistream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumMultistream.kt @@ -66,19 +66,19 @@ open class EthereumMultistream( private var subscribe = EthereumEgressSubscription(this, headScheduler, NoPendingTxes()) private val supportsEIP1559set = setOf( - Chain.ETHEREUM, Chain.TESTNET_ROPSTEN, - Chain.TESTNET_GOERLI, - Chain.TESTNET_RINKEBY, - Chain.TESTNET_SEPOLIA, - Chain.ARBITRUM, - Chain.OPTIMISM, - Chain.TESTNET_ARBITRUM, - Chain.TESTNET_OPTIMISM, - Chain.POLYGON_ZKEVM, - Chain.TESTNET_POLYGON_ZKEVM, - Chain.ZKSYNC, - Chain.TESTNET_ZKSYNC, - Chain.ARBITRUM_NOVA + Chain.ETHEREUM__MAINNET, Chain.ETHEREUM__ROPSTEN, + Chain.ETHEREUM__GOERLI, + Chain.ETHEREUM__RINKEBY, + Chain.ETHEREUM__SEPOLIA, + Chain.ARBITRUM__MAINNET, + Chain.OPTIMISM__MAINNET, + Chain.ARBITRUM__GOERLI, + Chain.OPTIMISM__GOERLI, + Chain.POLYGON_ZKEVM__MAINNET, + Chain.POLYGON_ZKEVM__TESTNET, + Chain.ZKSYNC__MAINNET, + Chain.ZKSYNC__TESTNET, + Chain.ARBITRUM_NOVA__MAINNET ) private val supportsEIP1559 = supportsEIP1559set.contains(chain) diff --git a/src/test/groovy/io/emeraldpay/dshackle/cache/BlocksRedisCacheSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/cache/BlocksRedisCacheSpec.groovy index 37572c75..931e1ece 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/cache/BlocksRedisCacheSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/cache/BlocksRedisCacheSpec.groovy @@ -48,7 +48,7 @@ class BlocksRedisCacheSpec extends Specification { redis = IntegrationTestingCommons.redisConnection() redis.sync().flushdb() cache = new BlocksRedisCache( - redis.reactive(), Chain.ETHEREUM + redis.reactive(), Chain.ETHEREUM__MAINNET ) } diff --git a/src/test/groovy/io/emeraldpay/dshackle/cache/HeightByHashRedisCacheSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/cache/HeightByHashRedisCacheSpec.groovy index 4f78e999..1fccba0e 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/cache/HeightByHashRedisCacheSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/cache/HeightByHashRedisCacheSpec.groovy @@ -44,7 +44,7 @@ class HeightByHashRedisCacheSpec extends Specification { redis = IntegrationTestingCommons.redisConnection() redis.sync().flushdb() cache = new HeightByHashRedisCache( - redis.reactive(), Chain.ETHEREUM + redis.reactive(), Chain.ETHEREUM__MAINNET ) } diff --git a/src/test/groovy/io/emeraldpay/dshackle/cache/ReceiptRedisCacheSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/cache/ReceiptRedisCacheSpec.groovy index 5ae4ca2c..07757f5d 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/cache/ReceiptRedisCacheSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/cache/ReceiptRedisCacheSpec.groovy @@ -47,7 +47,7 @@ class ReceiptRedisCacheSpec extends Specification { redis = IntegrationTestingCommons.redisConnection() redis.sync().flushdb() cache = new ReceiptRedisCache( - redis.reactive(), Chain.ETHEREUM + redis.reactive(), Chain.ETHEREUM__MAINNET ) } diff --git a/src/test/groovy/io/emeraldpay/dshackle/cache/TxRedisCacheSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/cache/TxRedisCacheSpec.groovy index bf64a2bb..aa636c36 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/cache/TxRedisCacheSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/cache/TxRedisCacheSpec.groovy @@ -50,7 +50,7 @@ class TxRedisCacheSpec extends Specification { def setup() { StatefulRedisConnection redis = IntegrationTestingCommons.redisConnection() redis.sync().flushdb() - cache = new TxRedisCache(redis.reactive(), Chain.ETHEREUM) + cache = new TxRedisCache(redis.reactive(), Chain.ETHEREUM__MAINNET) } def "Decode encoded"() { diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/ChainsConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/ChainsConfigReaderSpec.groovy index b05c329d..16fbe4ff 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/ChainsConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/ChainsConfigReaderSpec.groovy @@ -31,10 +31,10 @@ class ChainsConfigReaderSpec extends Specification { def stream = this.class.getClassLoader().getResourceAsStream("configs/chains-basic.yaml") when: def config = reader.read(stream) - def eth = config.resolve(Chain.ETHEREUM) - def pol = config.resolve(Chain.POLYGON) - def opt = config.resolve(Chain.OPTIMISM) - def sep = config.resolve(Chain.TESTNET_SEPOLIA) + def eth = config.resolve(Chain.ETHEREUM__MAINNET) + def pol = config.resolve(Chain.POLYGON_POS__MAINNET) + def opt = config.resolve(Chain.OPTIMISM__MAINNET) + def sep = config.resolve(Chain.ETHEREUM__SEPOLIA) then: eth.laggingLagSize == 1 eth.syncingLagSize == 6 diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/HealthConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/HealthConfigReaderSpec.groovy index 9006581b..2492dac3 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/HealthConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/HealthConfigReaderSpec.groovy @@ -50,7 +50,7 @@ class HealthConfigReaderSpec extends Specification { with(act.configs()) { size() == 1 with(it[0]) { - it.blockchain == Chain.ETHEREUM + it.blockchain == Chain.ETHEREUM__MAINNET it.minAvailable == 2 } } @@ -70,11 +70,11 @@ class HealthConfigReaderSpec extends Specification { with(act.configs().toSorted { it.blockchain.id }) { size() == 2 with(it[0]) { - it.blockchain == Chain.BITCOIN + it.blockchain == Chain.BITCOIN__MAINNET it.minAvailable == 1 } with(it[1]) { - it.blockchain == Chain.ETHEREUM + it.blockchain == Chain.ETHEREUM__MAINNET it.minAvailable == 2 } } diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/MainConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/MainConfigReaderSpec.groovy index 810cce66..6dc071fd 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/MainConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/MainConfigReaderSpec.groovy @@ -54,23 +54,23 @@ class MainConfigReaderSpec extends Specification { routes.size() == 5 with(routes[0]) { id == "eth" - blockchain == Chain.ETHEREUM + blockchain == Chain.ETHEREUM__MAINNET } with(routes[1]) { id == "etc" - blockchain == Chain.ETHEREUM_CLASSIC + blockchain == Chain.ETHEREUM_CLASSIC__MAINNET } with(routes[2]) { id == "kovan" - blockchain == Chain.TESTNET_KOVAN + blockchain == Chain.ETHEREUM__KOVAN } with(routes[3]) { id == "goerli" - blockchain == Chain.TESTNET_GOERLI + blockchain == Chain.ETHEREUM__GOERLI } with(routes[4]) { id == "rinkeby" - blockchain == Chain.TESTNET_RINKEBY + blockchain == Chain.ETHEREUM__RINKEBY } } with(act.health) { @@ -78,7 +78,7 @@ class MainConfigReaderSpec extends Specification { with(it.configs()) { it.size() == 1 with(it[0]) { - it.blockchain == Chain.ETHEREUM + it.blockchain == Chain.ETHEREUM__MAINNET it.minAvailable == 1 } } diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy index 473247df..5aa1e52e 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy @@ -36,7 +36,7 @@ class ProxyConfigReaderSpec extends Specification { act.routes.size() == 1 with(act.routes[0]) { id == "ethereum" - blockchain == Chain.ETHEREUM + blockchain == Chain.ETHEREUM__MAINNET } } @@ -63,11 +63,11 @@ class ProxyConfigReaderSpec extends Specification { act.routes.size() == 2 with(act.routes[0]) { id == "ethereum" - blockchain == Chain.ETHEREUM + blockchain == Chain.ETHEREUM__MAINNET } with(act.routes[1]) { id == "classic" - blockchain == Chain.ETHEREUM_CLASSIC + blockchain == Chain.ETHEREUM_CLASSIC__MAINNET } } @@ -87,11 +87,11 @@ class ProxyConfigReaderSpec extends Specification { act.corsAllowedHeaders == "Content-Type" with(act.routes[0]) { id == "ethereum" - blockchain == Chain.ETHEREUM + blockchain == Chain.ETHEREUM__MAINNET } with(act.routes[1]) { id == "classic" - blockchain == Chain.ETHEREUM_CLASSIC + blockchain == Chain.ETHEREUM_CLASSIC__MAINNET } } } diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/TokensConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/TokensConfigReaderSpec.groovy index 2d67314e..9d05af26 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/TokensConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/TokensConfigReaderSpec.groovy @@ -33,14 +33,14 @@ class TokensConfigReaderSpec extends Specification { act.tokens.size() == 2 with(act.tokens[0]) { id == "dai" - blockchain == Chain.ETHEREUM + blockchain == Chain.ETHEREUM__MAINNET name == "DAI" type == TokensConfig.Type.ERC20 address == "0x6B175474E89094C44Da98b954EedeAC495271d0F" } with(act.tokens[1]) { id == "tether" - blockchain == Chain.ETHEREUM + blockchain == Chain.ETHEREUM__MAINNET name == "Tether" type == TokensConfig.Type.ERC20 address == "0xdac17f958d2ee523a2206206994597c13d831ec7" diff --git a/src/test/groovy/io/emeraldpay/dshackle/monitoring/HealthCheckSetupSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/monitoring/HealthCheckSetupSpec.groovy index fee2c39c..ac5a5f92 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/monitoring/HealthCheckSetupSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/monitoring/HealthCheckSetupSpec.groovy @@ -20,7 +20,6 @@ import io.emeraldpay.dshackle.config.HealthConfig import io.emeraldpay.dshackle.upstream.Multistream import io.emeraldpay.dshackle.upstream.MultistreamHolder import io.emeraldpay.dshackle.upstream.Upstream -import io.emeraldpay.dshackle.upstream.UpstreamAvailability import spock.lang.Specification class HealthCheckSetupSpec extends Specification { @@ -28,8 +27,8 @@ class HealthCheckSetupSpec extends Specification { def "OK when meets availability - 1"() { setup: def config = new HealthConfig().tap { - it.chains[Chain.ETHEREUM] = new HealthConfig.ChainConfig( - Chain.ETHEREUM, 1 + it.chains[Chain.ETHEREUM__MAINNET] = new HealthConfig.ChainConfig( + Chain.ETHEREUM__MAINNET, 1 ) } def up1 = Mock(Upstream) @@ -43,7 +42,7 @@ class HealthCheckSetupSpec extends Specification { then: act.ok act.details == ["OK"] - 1 * multistream.getUpstream(Chain.ETHEREUM) >> ethereumUpstreams + 1 * multistream.getUpstream(Chain.ETHEREUM__MAINNET) >> ethereumUpstreams 1 * ethereumUpstreams.available >> true 1 * ethereumUpstreams.getAll() >> [up1] 1 * up1.isAvailable() >> true @@ -52,8 +51,8 @@ class HealthCheckSetupSpec extends Specification { def "OK when meets availability - 1 - bitcoin"() { setup: def config = new HealthConfig().tap { - it.chains[Chain.BITCOIN] = new HealthConfig.ChainConfig( - Chain.BITCOIN, 1 + it.chains[Chain.BITCOIN__MAINNET] = new HealthConfig.ChainConfig( + Chain.BITCOIN__MAINNET, 1 ) } def up1 = Mock(Upstream) @@ -67,7 +66,7 @@ class HealthCheckSetupSpec extends Specification { then: act.ok act.details == ["OK"] - 1 * multistream.getUpstream(Chain.BITCOIN) >> bitcoinUpstreams + 1 * multistream.getUpstream(Chain.BITCOIN__MAINNET) >> bitcoinUpstreams 1 * bitcoinUpstreams.available >> true 1 * bitcoinUpstreams.getAll() >> [up1] 1 * up1.isAvailable() >> true @@ -76,8 +75,8 @@ class HealthCheckSetupSpec extends Specification { def "OK when meets availability - 2/3"() { setup: def config = new HealthConfig().tap { - it.chains[Chain.ETHEREUM] = new HealthConfig.ChainConfig( - Chain.ETHEREUM, 2 + it.chains[Chain.ETHEREUM__MAINNET] = new HealthConfig.ChainConfig( + Chain.ETHEREUM__MAINNET, 2 ) } def up1 = Mock(Upstream) @@ -93,7 +92,7 @@ class HealthCheckSetupSpec extends Specification { then: act.ok act.details == ["OK"] - 1 * multistream.getUpstream(Chain.ETHEREUM) >> ethereumUpstreams + 1 * multistream.getUpstream(Chain.ETHEREUM__MAINNET) >> ethereumUpstreams 1 * ethereumUpstreams.available >> true 1 * ethereumUpstreams.getAll() >> [up1, up2, up3] 1 * up1.isAvailable() >> true @@ -104,8 +103,8 @@ class HealthCheckSetupSpec extends Specification { def "OK when doesn't meet availability - 2/3"() { setup: def config = new HealthConfig().tap { - it.chains[Chain.ETHEREUM] = new HealthConfig.ChainConfig( - Chain.ETHEREUM, 2 + it.chains[Chain.ETHEREUM__MAINNET] = new HealthConfig.ChainConfig( + Chain.ETHEREUM__MAINNET, 2 ) } def up1 = Mock(Upstream) @@ -121,7 +120,7 @@ class HealthCheckSetupSpec extends Specification { then: !act.ok act.details != ["OK"] - 1 * multistream.getUpstream(Chain.ETHEREUM) >> ethereumUpstreams + 1 * multistream.getUpstream(Chain.ETHEREUM__MAINNET) >> ethereumUpstreams 1 * ethereumUpstreams.available >> true 1 * ethereumUpstreams.getAll() >> [up1, up2, up3] 1 * up1.isAvailable() >> true @@ -132,8 +131,8 @@ class HealthCheckSetupSpec extends Specification { def "OK when meets availability - 2/3 - detailed"() { setup: def config = new HealthConfig().tap { - it.chains[Chain.ETHEREUM] = new HealthConfig.ChainConfig( - Chain.ETHEREUM, 2 + it.chains[Chain.ETHEREUM__MAINNET] = new HealthConfig.ChainConfig( + Chain.ETHEREUM__MAINNET, 2 ) } def up1 = Mock(Upstream) @@ -149,8 +148,8 @@ class HealthCheckSetupSpec extends Specification { then: act.ok act.details.size() > 1 - 1 * multistream.getAvailable() >> [Chain.ETHEREUM] - 1 * multistream.getUpstream(Chain.ETHEREUM) >> ethereumUpstreams + 1 * multistream.getAvailable() >> [Chain.ETHEREUM__MAINNET] + 1 * multistream.getUpstream(Chain.ETHEREUM__MAINNET) >> ethereumUpstreams 1 * ethereumUpstreams.available >> true 1 * ethereumUpstreams.getAll() >> [up1, up2, up3] _ * up1.isAvailable() >> true diff --git a/src/test/groovy/io/emeraldpay/dshackle/monitoring/accesslog/AccessLogWriterSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/monitoring/accesslog/AccessLogWriterSpec.groovy index 93d88cc3..14fc2f01 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/monitoring/accesslog/AccessLogWriterSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/monitoring/accesslog/AccessLogWriterSpec.groovy @@ -24,7 +24,7 @@ class AccessLogWriterSpec extends Specification { when: def event = new Events.Status( - Chain.ETHEREUM, UUID.fromString("9d8ecbf3-12fb-49cf-af9d-949a1050a000"), + Chain.ETHEREUM__MAINNET, UUID.fromString("9d8ecbf3-12fb-49cf-af9d-949a1050a000"), new Events.StreamRequestDetails( UUID.fromString("9d8ecbf3-12fb-49cf-af9d-949a1050a000"), Instant.ofEpochMilli(1626746880123), @@ -43,7 +43,7 @@ class AccessLogWriterSpec extends Specification { json["version"] == "accesslog/v1beta" json["id"] == "9d8ecbf3-12fb-49cf-af9d-949a1050a000" json["method"] == "Status" - json["blockchain"] == "ETHEREUM" + json["blockchain"] == "ETHEREUM__MAINNET" json["request"]["start"] == "2021-07-20T02:08:00.123Z" json["request"]["id"] == "9d8ecbf3-12fb-49cf-af9d-949a1050a000" json["request"]["remote"]["ip"] == "172.217.8.78" diff --git a/src/test/groovy/io/emeraldpay/dshackle/monitoring/accesslog/EventsBuilderSubscribeBalanceSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/monitoring/accesslog/EventsBuilderSubscribeBalanceSpec.groovy index aca4439e..79fbf85b 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/monitoring/accesslog/EventsBuilderSubscribeBalanceSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/monitoring/accesslog/EventsBuilderSubscribeBalanceSpec.groovy @@ -37,7 +37,7 @@ class EventsBuilderSubscribeBalanceSpec extends Specification { }.onReply(resp) then: act.index == 0 - act.blockchain == Chain.ETHEREUM + act.blockchain == Chain.ETHEREUM__MAINNET act.balanceRequest.asset == "ETHER" act.balanceRequest.addressType == "ADDRESS_SINGLE" act.addressBalance.asset == "ETHER" @@ -74,7 +74,7 @@ class EventsBuilderSubscribeBalanceSpec extends Specification { }.onReply(resp) then: act.index == 0 - act.blockchain == Chain.BITCOIN + act.blockchain == Chain.BITCOIN__MAINNET act.balanceRequest.asset == "BTC" act.balanceRequest.addressType == "ADDRESS_SINGLE" act.addressBalance.asset == "BTC" diff --git a/src/test/groovy/io/emeraldpay/dshackle/proxy/BaseHandlerSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/proxy/BaseHandlerSpec.groovy index 2ca802f7..7e7bc6f5 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/proxy/BaseHandlerSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/proxy/BaseHandlerSpec.groovy @@ -34,7 +34,7 @@ class BaseHandlerSpec extends Specification { setup: def handler = new BaseHandlerImpl(new WriteRpcJson(), Stub(NativeCall), Stub(ProxyServer.RequestMetricsFactory)) when: - def act = Mono.from(handler.execute(Chain.ETHEREUM, new ProxyCall(ProxyCall.RpcType.SINGLE), requestHandler, false)) + def act = Mono.from(handler.execute(Chain.ETHEREUM__MAINNET, new ProxyCall(ProxyCall.RpcType.SINGLE), requestHandler, false)) .block(Duration.ofSeconds(1)) then: act == "" @@ -44,7 +44,7 @@ class BaseHandlerSpec extends Specification { setup: def handler = new BaseHandlerImpl(new WriteRpcJson(), Stub(NativeCall), Stub(ProxyServer.RequestMetricsFactory)) when: - def act = Mono.from(handler.execute(Chain.ETHEREUM, new ProxyCall(ProxyCall.RpcType.BATCH), requestHandler, false)) + def act = Mono.from(handler.execute(Chain.ETHEREUM__MAINNET, new ProxyCall(ProxyCall.RpcType.BATCH), requestHandler, false)) .block(Duration.ofSeconds(1)) then: act == "[]" @@ -64,7 +64,7 @@ class BaseHandlerSpec extends Specification { call.ids[0] = 5 def response = new NativeCall.CallResult(0, null, '{"foo": 1}'.bytes, null, null, null, null) when: - def act = Flux.from(handler.execute(Chain.ETHEREUM, call, requestHandler, false)) + def act = Flux.from(handler.execute(Chain.ETHEREUM__MAINNET, call, requestHandler, false)) .collectList() .block(Duration.ofSeconds(1)) .join("") @@ -87,7 +87,7 @@ class BaseHandlerSpec extends Specification { call.ids[0] = 5 def response = new NativeCall.CallResult(0, null, '{"foo": 1}'.bytes, null, null, null, null) when: - def act = Flux.from(handler.execute(Chain.ETHEREUM, call, requestHandler, false)) + def act = Flux.from(handler.execute(Chain.ETHEREUM__MAINNET, call, requestHandler, false)) .collectList() .block(Duration.ofSeconds(1)) .join("") @@ -120,7 +120,7 @@ class BaseHandlerSpec extends Specification { new NativeCall.CallResult(0, null, '{"foo": 1}'.bytes, null, null, null, null) ] when: - def act = Flux.from(handler.execute(Chain.ETHEREUM, call, requestHandler, true)) + def act = Flux.from(handler.execute(Chain.ETHEREUM__MAINNET, call, requestHandler, true)) .collectList() .block(Duration.ofSeconds(1)) .join("") @@ -153,7 +153,7 @@ class BaseHandlerSpec extends Specification { new NativeCall.CallResult(0, null, '{"foo": 1}'.bytes, null, null, null, null) ] when: - def act = Flux.from(handler.execute(Chain.ETHEREUM, call, requestHandler, true)) + def act = Flux.from(handler.execute(Chain.ETHEREUM__MAINNET, call, requestHandler, true)) .collectList() .block(Duration.ofSeconds(1)) .join("") @@ -193,7 +193,7 @@ class BaseHandlerSpec extends Specification { new NativeCall.CallResult(2, null, '{"foo": 3}'.bytes, null, null, null, null) ] when: - def act = Flux.from(handler.execute(Chain.ETHEREUM, call, requestHandler, true)) + def act = Flux.from(handler.execute(Chain.ETHEREUM__MAINNET, call, requestHandler, true)) .collectList() .block(Duration.ofSeconds(1)) .join("") diff --git a/src/test/groovy/io/emeraldpay/dshackle/proxy/HttpHandlerSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/proxy/HttpHandlerSpec.groovy index 4a67c54a..cad323af 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/proxy/HttpHandlerSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/proxy/HttpHandlerSpec.groovy @@ -44,7 +44,7 @@ class HttpHandlerSpec extends Specification { .build() def respItem = new NativeCall.CallResult(1, null, "100".bytes, null, null, null, null) def req = BlockchainOuterClass.NativeCallRequest.newBuilder() - .setChain(Common.ChainRef.CHAIN_ETHEREUM) + .setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .addItems(reqItem) .build() @@ -62,7 +62,7 @@ class HttpHandlerSpec extends Specification { ) when: - handler.execute(Chain.ETHEREUM, [reqItem], accessHandler) + handler.execute(Chain.ETHEREUM__MAINNET, [reqItem], accessHandler) .blockLast() then: @@ -79,7 +79,7 @@ class HttpHandlerSpec extends Specification { 1 * increment() } ProxyServer.RequestMetricsFactory metrics = Mock(ProxyServer.RequestMetricsFactory) { - 1 * get(Chain.ETHEREUM, "invalid_method") >> Mock(ProxyServer.RequestMetrics) { + 1 * get(Chain.ETHEREUM__MAINNET, "invalid_method") >> Mock(ProxyServer.RequestMetrics) { 1 * it.errorMetric >> errorMetric } } @@ -92,7 +92,7 @@ class HttpHandlerSpec extends Specification { ) when: - def act = handler.processRequest(Chain.ETHEREUM, Mono.just("".bytes), new AccessHandlerHttp.NoOpHandler()) + def act = handler.processRequest(Chain.ETHEREUM__MAINNET, Mono.just("".bytes), new AccessHandlerHttp.NoOpHandler()) .map { new String(it.array()) } then: StepVerifier.create(act) @@ -125,7 +125,7 @@ class HttpHandlerSpec extends Specification { .build() ) when: - def act = handler.execute(Chain.ETHEREUM, call, new AccessHandlerHttp.NoOpHandler(), false) + def act = handler.execute(Chain.ETHEREUM__MAINNET, call, new AccessHandlerHttp.NoOpHandler(), false) then: 1 * nativeCall.nativeCallResult(_) >> Flux.just(new NativeCall.CallResult(1, null, "".bytes, null, null, null, null)) diff --git a/src/test/groovy/io/emeraldpay/dshackle/proxy/ProxyServerSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/proxy/ProxyServerSpec.groovy index 4f03ea34..3a4a2533 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/proxy/ProxyServerSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/proxy/ProxyServerSpec.groovy @@ -16,7 +16,7 @@ class ProxyServerSpec extends Specification { setup: def config1 = new ProxyConfig() config1.routes = [ - new ProxyConfig.Route("test", Chain.ETHEREUM) + new ProxyConfig.Route("test", Chain.ETHEREUM__MAINNET) ] def proxyServer = new ProxyServer( config1, @@ -40,7 +40,7 @@ class ProxyServerSpec extends Specification { def config1 = new ProxyConfig() config1.websocketEnabled = false config1.routes = [ - new ProxyConfig.Route("test", Chain.ETHEREUM) + new ProxyConfig.Route("test", Chain.ETHEREUM__MAINNET) ] def proxyServer = new ProxyServer( config1, diff --git a/src/test/groovy/io/emeraldpay/dshackle/proxy/WebsocketHandlerSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/proxy/WebsocketHandlerSpec.groovy index 0cb6bca6..33cfc457 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/proxy/WebsocketHandlerSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/proxy/WebsocketHandlerSpec.groovy @@ -39,7 +39,7 @@ class WebsocketHandlerSpec extends Specification { new ReadRpcJson(), Stub(WriteRpcJson), Stub(NativeCall), Stub(NativeSubscribe), requestHandlerFactory, Stub(ProxyServer.RequestMetricsFactory) ) when: - def act = handler.parseRequest('{"id": 5, "jsonrpc": "2.0", "method": "eth_getBlockByNumber", "params": ["0x100001", false]}'.bytes, Chain.ETHEREUM) + def act = handler.parseRequest('{"id": 5, "jsonrpc": "2.0", "method": "eth_getBlockByNumber", "params": ["0x100001", false]}'.bytes, Chain.ETHEREUM__MAINNET) .block(Duration.ofSeconds(1)) then: @@ -54,7 +54,7 @@ class WebsocketHandlerSpec extends Specification { 1 * increment() } ProxyServer.RequestMetricsFactory metrics = Mock(ProxyServer.RequestMetricsFactory) { - 1 * get(Chain.ETHEREUM, "invalid_method") >> Mock(ProxyServer.RequestMetrics) { + 1 * get(Chain.ETHEREUM__MAINNET, "invalid_method") >> Mock(ProxyServer.RequestMetrics) { 1 * it.errorMetric >> errorMetric } } @@ -62,7 +62,7 @@ class WebsocketHandlerSpec extends Specification { new ReadRpcJson(), Stub(WriteRpcJson), Stub(NativeCall), Stub(NativeSubscribe), requestHandlerFactory, metrics ) when: - def act = handler.parseRequest('hello world'.bytes, Chain.ETHEREUM) + def act = handler.parseRequest('hello world'.bytes, Chain.ETHEREUM__MAINNET) .block(Duration.ofSeconds(1)) then: @@ -76,7 +76,7 @@ class WebsocketHandlerSpec extends Specification { new ReadRpcJson(), Stub(WriteRpcJson), Stub(NativeCall), Stub(NativeSubscribe), requestHandlerFactory, Stub(ProxyServer.RequestMetricsFactory) ) when: - def act = handler.parseRequest("[$req1]".bytes, Chain.ETHEREUM) + def act = handler.parseRequest("[$req1]".bytes, Chain.ETHEREUM__MAINNET) .block(Duration.ofSeconds(1)) then: @@ -96,7 +96,7 @@ class WebsocketHandlerSpec extends Specification { def request = new RequestJson("foo_test", [], 2) when: - def act = handler.respond(Chain.ETHEREUM, new HashMap>(), Flux.just(request), requestHandler) + def act = handler.respond(Chain.ETHEREUM__MAINNET, new HashMap>(), Flux.just(request), requestHandler) .single() .block(Duration.ofSeconds(1)) then: @@ -109,7 +109,7 @@ class WebsocketHandlerSpec extends Specification { def response2 = [foo: 2] def nativeSubscribe = Mock(NativeSubscribe) { - 1 * it.subscribe(Chain.ETHEREUM, "foo_test", null, Selector.empty) >> Flux.fromIterable([response1, response2]) + 1 * it.subscribe(Chain.ETHEREUM__MAINNET, "foo_test", null, Selector.empty) >> Flux.fromIterable([response1, response2]) } def handler = new WebsocketHandler( new ReadRpcJson(), new WriteRpcJson(), Stub(NativeCall), nativeSubscribe, requestHandlerFactory, Stub(ProxyServer.RequestMetricsFactory) @@ -117,7 +117,7 @@ class WebsocketHandlerSpec extends Specification { def request = new RequestJson("eth_subscribe", ["foo_test"], 2) when: - def act = handler.respond(Chain.ETHEREUM, new HashMap>(), Flux.just(request), requestHandler) + def act = handler.respond(Chain.ETHEREUM__MAINNET, new HashMap>(), Flux.just(request), requestHandler) .collectList() .block(Duration.ofSeconds(1)) then: @@ -139,7 +139,7 @@ class WebsocketHandlerSpec extends Specification { control["5"] = sink def request = new RequestJson("eth_unsubscribe", ["5"], 0) when: - def act = handler.respond(Chain.ETHEREUM, control, Flux.just(request), requestHandler) + def act = handler.respond(Chain.ETHEREUM__MAINNET, control, Flux.just(request), requestHandler) .single() .block(Duration.ofSeconds(1)) def sinkResponse = sink.asMono().block() @@ -158,7 +158,7 @@ class WebsocketHandlerSpec extends Specification { def control = new HashMap>() def request = new RequestJson("eth_unsubscribe", ["5"], 0) when: - def act = handler.respond(Chain.ETHEREUM, control, Flux.just(request), requestHandler) + def act = handler.respond(Chain.ETHEREUM__MAINNET, control, Flux.just(request), requestHandler) .single() .block(Duration.ofSeconds(1)) then: diff --git a/src/test/groovy/io/emeraldpay/dshackle/quorum/QuorumRpcReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/quorum/QuorumRpcReaderSpec.groovy index b75a57dd..fd292513 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/quorum/QuorumRpcReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/quorum/QuorumRpcReaderSpec.groovy @@ -45,7 +45,7 @@ class QuorumRpcReaderSpec extends Specification { } } def apis = new FilteredApis( - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, [up], Selector.empty ) def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer)) @@ -76,7 +76,7 @@ class QuorumRpcReaderSpec extends Specification { _ * getIngressReader() >> api } def apis = new FilteredApis( - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, [up], Selector.empty ) def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer)) @@ -113,7 +113,7 @@ class QuorumRpcReaderSpec extends Specification { _ * getIngressReader() >> api } def apis = new FilteredApis( - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, [up], Selector.empty ) def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer)) @@ -145,7 +145,7 @@ class QuorumRpcReaderSpec extends Specification { } } def apis = new FilteredApis( - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, [up], Selector.empty ) def reader = new QuorumRpcReader(apis, new NotNullQuorum(), Stub(Tracer)) @@ -177,7 +177,7 @@ class QuorumRpcReaderSpec extends Specification { } } def apis = new FilteredApis( - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, [up], Selector.empty ) def reader = new QuorumRpcReader(apis, new NotNullQuorum(), Stub(Tracer)) @@ -210,7 +210,7 @@ class QuorumRpcReaderSpec extends Specification { _ * getIngressReader() >> api } def apis = new FilteredApis( - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, [up], Selector.empty ) def reader = new QuorumRpcReader(apis, new NotNullQuorum(), Stub(Tracer)) @@ -240,7 +240,7 @@ class QuorumRpcReaderSpec extends Specification { _ * getIngressReader() >> api } def apis = new FilteredApis( - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, [up], Selector.empty ) def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer)) @@ -273,7 +273,7 @@ class QuorumRpcReaderSpec extends Specification { } } def apis = new FilteredApis( - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, [up], Selector.empty ) def reader = new QuorumRpcReader(apis, new NotLaggingQuorum(1), Stub(Tracer)) @@ -299,7 +299,7 @@ class QuorumRpcReaderSpec extends Specification { _ * getIngressReader() >> api } def apis = new FilteredApis( - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, [up], Selector.empty ) def reader = new QuorumRpcReader(apis, new AlwaysQuorum(), Stub(Tracer)) diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy index 82508463..5f184403 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy @@ -297,7 +297,7 @@ class NativeCallSpec extends Specification { def nativeCall = nativeCall(upstreams) def req = BlockchainOuterClass.NativeCallRequest.newBuilder() - .setChainValue(Chain.TESTNET_MORDEN.id) + .setChainValue(Chain.ETHEREUM__MORDEN.id) .addAllItems([1, 2].collect { id -> return BlockchainOuterClass.NativeCallItem.newBuilder() .setId(id) @@ -305,7 +305,7 @@ class NativeCallSpec extends Specification { .build() }) .build() - 1 * upstreams.isAvailable(Chain.TESTNET_MORDEN) >> false + 1 * upstreams.isAvailable(Chain.ETHEREUM__MORDEN) >> false when: def resp = nativeCall.prepareCall(req) then: @@ -323,7 +323,7 @@ class NativeCallSpec extends Specification { def nativeCall = nativeCall(upstreams) def req = BlockchainOuterClass.NativeCallRequest.newBuilder() - .setChain(Common.ChainRef.CHAIN_ETHEREUM) + .setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .addItems( BlockchainOuterClass.NativeCallItem.newBuilder() .setId(1) @@ -353,7 +353,7 @@ class NativeCallSpec extends Specification { def nativeCall = nativeCall(upstreams) def req = BlockchainOuterClass.NativeCallRequest.newBuilder() - .setChain(Common.ChainRef.CHAIN_ETHEREUM) + .setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .addItems( BlockchainOuterClass.NativeCallItem.newBuilder() .setId(1) @@ -384,11 +384,11 @@ class NativeCallSpec extends Specification { .setMethod("eth_testInvalid") .build() def req = BlockchainOuterClass.NativeCallRequest.newBuilder() - .setChain(Common.ChainRef.CHAIN_ETHEREUM) + .setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .addItems(item) .build() when: - def act = nativeCall.prepareIndividualCall(Chain.ETHEREUM, req, item, TestingCommons.emptyMultistream()) + def act = nativeCall.prepareIndividualCall(Chain.ETHEREUM__MAINNET, req, item, TestingCommons.emptyMultistream()) .block(Duration.ofSeconds(1)) then: act instanceof NativeCall.InvalidCallContext @@ -402,14 +402,14 @@ class NativeCallSpec extends Specification { def "Prepare call adds height selector for not-lagging quorum"() { setup: def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["foo_bar"] as Set, [] as Set, [] as Set, [] as Set ) methods.setQuorum("foo_bar", "not_lagging") def head = Mock(Head) { 1 * it.getCurrentHeight() >> 101 } - def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream()) + def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream()) multistream.customMethods = methods multistream.customHead = head def multistreamHolder = Mock(MultistreamHolder) { @@ -418,7 +418,7 @@ class NativeCallSpec extends Specification { def nativeCall = nativeCall(multistreamHolder) def req = BlockchainOuterClass.NativeCallRequest.newBuilder() - .setChain(Common.ChainRef.CHAIN_ETHEREUM) + .setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .addItems( BlockchainOuterClass.NativeCallItem.newBuilder() .setId(1) @@ -443,11 +443,11 @@ class NativeCallSpec extends Specification { def "Prepare call adds decorator for eth_newFilter"() { setup: def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_newFilter"] as Set, [] as Set, [] as Set, [] as Set ) methods.setQuorum("eth_newFilter", "always") - def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream()) + def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream()) multistream.customMethods = methods multistream.customHead = Mock(Head) def multistreamHolder = Mock(MultistreamHolder) { @@ -456,7 +456,7 @@ class NativeCallSpec extends Specification { def nativeCall = nativeCall(multistreamHolder) def req = BlockchainOuterClass.NativeCallRequest.newBuilder() - .setChain(Common.ChainRef.CHAIN_ETHEREUM) + .setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .addItems( BlockchainOuterClass.NativeCallItem.newBuilder() .setId(1) @@ -474,10 +474,10 @@ class NativeCallSpec extends Specification { def "Prepare call adds decorator for eth_getFilterChanges"() { setup: def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_getFilterChanges"] as Set, [] as Set, [] as Set, [] as Set ) - def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream()) + def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream()) multistream.customMethods = methods multistream.customHead = Mock(Head) def multistreamHolder = Mock(MultistreamHolder) { @@ -486,7 +486,7 @@ class NativeCallSpec extends Specification { def nativeCall = nativeCall(multistreamHolder) def req = BlockchainOuterClass.NativeCallRequest.newBuilder() - .setChain(Common.ChainRef.CHAIN_ETHEREUM) + .setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .addItems( BlockchainOuterClass.NativeCallItem.newBuilder() .setId(1) @@ -504,10 +504,10 @@ class NativeCallSpec extends Specification { def "Prepare call adds decorator for eth_uninstallFilter"() { setup: def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_uninstallFilter"] as Set, [] as Set, [] as Set, [] as Set ) - def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream()) + def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream()) multistream.customMethods = methods multistream.customHead = Mock(Head) def multistreamHolder = Mock(MultistreamHolder) { @@ -516,7 +516,7 @@ class NativeCallSpec extends Specification { def nativeCall = nativeCall(multistreamHolder) def req = BlockchainOuterClass.NativeCallRequest.newBuilder() - .setChain(Common.ChainRef.CHAIN_ETHEREUM) + .setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .addItems( BlockchainOuterClass.NativeCallItem.newBuilder() .setId(1) @@ -604,10 +604,10 @@ class NativeCallSpec extends Specification { } def quorum = new AlwaysQuorum() def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), [] as Set, [] as Set, ["filter"] as Set, [] as Set ) - def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream( + def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream( TestingCommons.api(), methods )) multistream.customHead = Mock(Head) @@ -639,10 +639,10 @@ class NativeCallSpec extends Specification { } def quorum = new AlwaysQuorum() def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), [] as Set, [] as Set, ["filter"] as Set, [] as Set ) - def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM, TestingCommons.upstream( + def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream( TestingCommons.api(), methods )) multistream.customHead = Mock(Head) diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy index 76ea65d7..6f3861d5 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeSubscribeSpec.groovy @@ -35,7 +35,7 @@ class NativeSubscribeSpec extends Specification { def "Call with empty params when not provided"() { setup: def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder() - .setChainValue(Chain.ETHEREUM.id) + .setChainValue(Chain.ETHEREUM__MAINNET.id) .setMethod("newHeads") .build() @@ -47,7 +47,7 @@ class NativeSubscribeSpec extends Specification { 1 * it.getEgressSubscription() >> subscribe } - def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up), signer) + def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, up), signer) when: def act = nativeSubscribe.start(call) @@ -62,7 +62,7 @@ class NativeSubscribeSpec extends Specification { def "Call with params when provided"() { setup: def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder() - .setChainValue(Chain.ETHEREUM.id) + .setChainValue(Chain.ETHEREUM__MAINNET.id) .setMethod("logs") .setPayload(ByteString.copyFromUtf8( '{"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", ' + @@ -86,7 +86,7 @@ class NativeSubscribeSpec extends Specification { 1 * it.getEgressSubscription() >> subscribe } - def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up), signer) + def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, up), signer) when: def act = nativeSubscribe.start(call) @@ -101,7 +101,7 @@ class NativeSubscribeSpec extends Specification { def "Proxy call"() { setup: def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder() - .setChainValue(Chain.ETHEREUM.id) + .setChainValue(Chain.ETHEREUM__MAINNET.id) .setMethod("newHeads") .build() def up = Mock(EthereumPosMultiStream) { @@ -109,7 +109,7 @@ class NativeSubscribeSpec extends Specification { 0 * it.getEgressSubscription() } - def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up), signer) + def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, up), signer) when: def act = nativeSubscribe.start(call) diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/StreamHeadSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/StreamHeadSpec.groovy index e1b24299..0b53f84c 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/StreamHeadSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/StreamHeadSpec.groovy @@ -43,11 +43,11 @@ class StreamHeadSpec extends Specification { def "Errors on unavailable chain"() { setup: - def upstreams = new MultistreamHolderMock(Chain.ETHEREUM, Stub(EthereumPosRpcUpstream)) + def upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, Stub(EthereumPosRpcUpstream)) def streamHead = new StreamHead(upstreams) when: def flux = streamHead.add( - Mono.just(Common.Chain.newBuilder().setType(Common.ChainRef.CHAIN_ETHEREUM_CLASSIC).build()) + Mono.just(Common.Chain.newBuilder().setType(Common.ChainRef.CHAIN_ETHEREUM_CLASSIC__MAINNET).build()) ) then: StepVerifier.create(flux) @@ -71,7 +71,7 @@ class StreamHeadSpec extends Specification { def heads = blocks.collect { return BlockchainOuterClass.ChainHead.newBuilder() - .setChain(Common.ChainRef.CHAIN_ETHEREUM) + .setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .setTimestamp(it.timestamp.toEpochMilli()) .setBlockId(it.hash.toHex().substring(2)) .setWeight(ByteString.copyFrom(it.totalDifficulty.toByteArray())) @@ -80,12 +80,12 @@ class StreamHeadSpec extends Specification { .build() } - def upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, TestingCommons.api()) - def upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstream) + def upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.api()) + def upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstream) def streamHead = new StreamHead(upstreams) when: def flux = streamHead.add( - Mono.just(Common.Chain.newBuilder().setType(Common.ChainRef.CHAIN_ETHEREUM).build()) + Mono.just(Common.Chain.newBuilder().setType(Common.ChainRef.CHAIN_ETHEREUM__MAINNET).build()) ) then: StepVerifier.create(flux.take(2)) diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/SubscribeStatusSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/SubscribeStatusSpec.groovy index 6e65c324..24112957 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/SubscribeStatusSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/SubscribeStatusSpec.groovy @@ -26,14 +26,14 @@ class SubscribeStatusSpec extends Specification { _ * it.getAll() >> [ethereumUp] } def ups = Mock(MultistreamHolder) { - _ * it.getAvailable() >> [Chain.ETHEREUM] - 1 * it.getUpstream(Chain.ETHEREUM) >> ethereumUpAll + _ * it.getAvailable() >> [Chain.ETHEREUM__MAINNET] + 1 * it.getUpstream(Chain.ETHEREUM__MAINNET) >> ethereumUpAll } def ctrl = new SubscribeStatus(ups) when: def req = BlockchainOuterClass.StatusRequest.newBuilder() - .addChains(Common.ChainRef.CHAIN_ETHEREUM) + .addChains(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .build() def act = ctrl.subscribeStatus(Mono.just(req)) .take(1) @@ -47,7 +47,7 @@ class SubscribeStatusSpec extends Specification { then: StepVerifier.create(act) .expectNextMatches { - it.chainValue == Chain.ETHEREUM.id && it.availability == BlockchainOuterClass.AvailabilityEnum.AVAIL_OK + it.chainValue == Chain.ETHEREUM__MAINNET.id && it.availability == BlockchainOuterClass.AvailabilityEnum.AVAIL_OK } .expectComplete() .verify(Duration.ofSeconds(3)) diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinAddressSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinAddressSpec.groovy index 2f93b0a6..2ffa0007 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinAddressSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinAddressSpec.groovy @@ -52,7 +52,7 @@ class TrackBitcoinAddressSpec extends Specification { ] TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder)) def address = new TrackBitcoinAddress.Address( - Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" + Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" ) when: def total = track.totalUnspent(address, false, unspents) @@ -70,7 +70,7 @@ class TrackBitcoinAddressSpec extends Specification { ] TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder)) def address = new TrackBitcoinAddress.Address( - Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" + Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" ) when: def total = track.totalUnspent(address, false, unspents) @@ -85,7 +85,7 @@ class TrackBitcoinAddressSpec extends Specification { def unspents = [] TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder)) def address = new TrackBitcoinAddress.Address( - Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" + Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" ) when: def total = track.totalUnspent(address, false, unspents) @@ -99,7 +99,7 @@ class TrackBitcoinAddressSpec extends Specification { setup: TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder)) def address = new TrackBitcoinAddress.Address( - Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" + Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" ) def api = Mock(BitcoinMultistream) { 1 * getReader() >> Mock(BitcoinReader) { @@ -122,7 +122,7 @@ class TrackBitcoinAddressSpec extends Specification { ] TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder)) def address = new TrackBitcoinAddress.Address( - Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" + Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" ) when: def total = track.totalUnspent(address, true, unspents) @@ -225,39 +225,39 @@ class TrackBitcoinAddressSpec extends Specification { def "Build proto for common balance"() { setup: TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder)) - def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.valueOf(123456)) + def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.valueOf(123456)) when: def act = track.buildResponse(balance) then: act.address.address == "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" act.balance == "123456" - act.asset.chain.number == Chain.BITCOIN.id + act.asset.chain.number == Chain.BITCOIN__MAINNET.id act.asset.code == "BTC" } def "Build proto for zero balance"() { setup: TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder)) - def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.ZERO) + def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.ZERO) when: def act = track.buildResponse(balance) then: act.address.address == "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" act.balance == "0" - act.asset.chain.number == Chain.BITCOIN.id + act.asset.chain.number == Chain.BITCOIN__MAINNET.id act.asset.code == "BTC" } def "Build proto for all bitcoins"() { setup: TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder)) - def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.valueOf(21_000_000).multiply(BigInteger.TEN.pow(8))) + def balance = new TrackBitcoinAddress.AddressBalance(Chain.BITCOIN__MAINNET, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK", BigInteger.valueOf(21_000_000).multiply(BigInteger.TEN.pow(8))) when: def act = track.buildResponse(balance) then: act.address.address == "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK" act.balance == "2100000000000000" - act.asset.chain.number == Chain.BITCOIN.id + act.asset.chain.number == Chain.BITCOIN__MAINNET.id act.asset.code == "BTC" } @@ -288,13 +288,13 @@ class TrackBitcoinAddressSpec extends Specification { upstream } } - MultistreamHolder upstreams = new MultistreamHolderMock(Chain.BITCOIN, upstream) + MultistreamHolder upstreams = new MultistreamHolderMock(Chain.BITCOIN__MAINNET, upstream) TrackBitcoinAddress track = new TrackBitcoinAddress(upstreams) - track.setBalanceAvailability(Chain.BITCOIN, true) + track.setBalanceAvailability(Chain.BITCOIN__MAINNET, true) when: def resp = track.subscribe(BlockchainOuterClass.BalanceRequest.newBuilder() - .setAsset(Common.Asset.newBuilder().setChain(Common.ChainRef.CHAIN_BITCOIN)) + .setAsset(Common.Asset.newBuilder().setChain(Common.ChainRef.CHAIN_BITCOIN__MAINNET)) .setAddress( Common.AnyAddress.newBuilder().setAddressSingle( Common.SingleAddress.newBuilder().setAddress("1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK") diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinTxSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinTxSpec.groovy index faf6c48f..1c1e9baf 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinTxSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackBitcoinTxSpec.groovy @@ -241,7 +241,7 @@ class TrackBitcoinTxSpec extends Specification { when: def steps = StepVerifier.withVirtualTime { - track.untilFound(Chain.BITCOIN, upstream, txid).take(1) + track.untilFound(Chain.BITCOIN__MAINNET, upstream, txid).take(1) } then: @@ -282,7 +282,7 @@ class TrackBitcoinTxSpec extends Specification { } when: - def act = track.subscribe(Chain.BITCOIN, upstream, txid) + def act = track.subscribe(Chain.BITCOIN__MAINNET, upstream, txid) then: StepVerifier.create(act) diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy index e7cf9fb2..162fd20f 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackERC20AddressSpec.groovy @@ -30,12 +30,12 @@ class TrackERC20AddressSpec extends Specification { def "Init with single token"() { setup: MultistreamHolder ups = Mock(MultistreamHolder) { - _ * isAvailable(Chain.ETHEREUM) >> true + _ * isAvailable(Chain.ETHEREUM__MAINNET) >> true } TokensConfig tokens = new TokensConfig([ new TokensConfig.Token().tap { id = "dai" - blockchain = Chain.ETHEREUM + blockchain = Chain.ETHEREUM__MAINNET name = "DAI" type = TokensConfig.Type.ERC20 address = Address.from("0x6B175474E89094C44Da98b954EedeAC495271d0F") @@ -45,17 +45,17 @@ class TrackERC20AddressSpec extends Specification { when: track.init() def act = track.tokens - def supportDai = track.isSupported(Chain.ETHEREUM, "DAI") - def supportSai = track.isSupported(Chain.ETHEREUM, "SAI") + def supportDai = track.isSupported(Chain.ETHEREUM__MAINNET, "DAI") + def supportSai = track.isSupported(Chain.ETHEREUM__MAINNET, "SAI") then: act.size() == 1 with(act.keySet().first()) { - chain == Chain.ETHEREUM + chain == Chain.ETHEREUM__MAINNET name == "dai" } with(act.values().first()) { - chain == Chain.ETHEREUM + chain == Chain.ETHEREUM__MAINNET name == "dai" token != null } @@ -66,7 +66,7 @@ class TrackERC20AddressSpec extends Specification { def "Init without tokens"() { setup: MultistreamHolder ups = Mock(MultistreamHolder) { - _ * isAvailable(Chain.ETHEREUM) >> true + _ * isAvailable(Chain.ETHEREUM__MAINNET) >> true } TokensConfig tokens = new TokensConfig([]) @@ -74,8 +74,8 @@ class TrackERC20AddressSpec extends Specification { when: track.init() def act = track.tokens - def supportDai = track.isSupported(Chain.ETHEREUM, "dai") - def supportSai = track.isSupported(Chain.ETHEREUM, "sai") + def supportDai = track.isSupported(Chain.ETHEREUM__MAINNET, "dai") + def supportSai = track.isSupported(Chain.ETHEREUM__MAINNET, "sai") then: act.size() == 0 @@ -86,20 +86,20 @@ class TrackERC20AddressSpec extends Specification { def "Init with two tokens"() { setup: MultistreamHolder ups = Mock(MultistreamHolder) { - _ * isAvailable(Chain.ETHEREUM) >> true + _ * isAvailable(Chain.ETHEREUM__MAINNET) >> true } TokensConfig tokens = new TokensConfig([ new TokensConfig.Token().tap { id = "dai" - blockchain = Chain.ETHEREUM + blockchain = Chain.ETHEREUM__MAINNET name = "DAI" type = TokensConfig.Type.ERC20 address = Address.from("0x6B175474E89094C44Da98b954EedeAC495271d0F") }, new TokensConfig.Token().tap { id = "sai" - blockchain = Chain.ETHEREUM + blockchain = Chain.ETHEREUM__MAINNET name = "SAI" type = TokensConfig.Type.ERC20 address = Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9") @@ -109,17 +109,17 @@ class TrackERC20AddressSpec extends Specification { when: track.init() def act = track.tokens - def supportDai = track.isSupported(Chain.ETHEREUM, "dai") - def supportSai = track.isSupported(Chain.ETHEREUM, "sai") + def supportDai = track.isSupported(Chain.ETHEREUM__MAINNET, "dai") + def supportSai = track.isSupported(Chain.ETHEREUM__MAINNET, "sai") then: act.size() == 2 with(act[act.keySet().find { it.name == "dai" }]) { - chain == Chain.ETHEREUM + chain == Chain.ETHEREUM__MAINNET name == "dai" } with(act[act.keySet().find { it.name == "sai" }]) { - chain == Chain.ETHEREUM + chain == Chain.ETHEREUM__MAINNET name == "sai" } supportDai @@ -130,7 +130,7 @@ class TrackERC20AddressSpec extends Specification { setup: TrackERC20Address track = new TrackERC20Address(Stub(MultistreamHolder), new TokensConfig([])) TrackERC20Address.TrackedAddress address = new TrackERC20Address.TrackedAddress( - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, Address.from("0x16c15c65ad00b6dfbcc2cb8a7b6c2d0103a3883b"), new ERC20Token(Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9")), "test", @@ -142,7 +142,7 @@ class TrackERC20AddressSpec extends Specification { act == BlockchainOuterClass.AddressBalance.newBuilder() .setAddress(Common.SingleAddress.newBuilder().setAddress("0x16c15c65ad00b6dfbcc2cb8a7b6c2d0103a3883b")) .setAsset(Common.Asset.newBuilder() - .setChain(Common.ChainRef.CHAIN_ETHEREUM) + .setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .setCode("TEST") ) .setBalance("1234") @@ -194,12 +194,12 @@ class TrackERC20AddressSpec extends Specification { } } def mup = Mock(MultistreamHolder) { - _ * getUpstream(Chain.ETHEREUM) >> up + _ * getUpstream(Chain.ETHEREUM__MAINNET) >> up } TokensConfig tokens = new TokensConfig([ new TokensConfig.Token().tap { id = "test" - blockchain = Chain.ETHEREUM + blockchain = Chain.ETHEREUM__MAINNET name = "TEST" type = TokensConfig.Type.ERC20 address = Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9") @@ -220,7 +220,7 @@ class TrackERC20AddressSpec extends Specification { ) .setAsset( Common.Asset.newBuilder() - .setChain(Common.ChainRef.CHAIN_ETHEREUM) + .setChain(Common.ChainRef.CHAIN_ETHEREUM__MAINNET) .setCode("TEST") ) .build() diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumAddressSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumAddressSpec.groovy index 4ea6d290..91910e7f 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumAddressSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumAddressSpec.groovy @@ -34,7 +34,7 @@ import java.time.temporal.ChronoUnit class TrackEthereumAddressSpec extends Specification { - def chain = Common.ChainRef.CHAIN_ETHEREUM + def chain = Common.ChainRef.CHAIN_ETHEREUM__MAINNET def address1 = "0xe2c8fa8120d813cd0b5e6add120295bf20cfa09f" def address1Proto = Common.SingleAddress.newBuilder() .setAddress(address1) @@ -57,7 +57,7 @@ class TrackEthereumAddressSpec extends Specification { def apiMock = TestingCommons.api() def upstreamMock = TestingCommons.upstream(apiMock) - MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock) + MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock) TrackEthereumAddress trackAddress = new TrackEthereumAddress(upstreams) apiMock.answer("eth_getBalance", ["0xe2c8fa8120d813cd0b5e6add120295bf20cfa09f", "latest"], "0x499602D2") @@ -99,7 +99,7 @@ class TrackEthereumAddressSpec extends Specification { def apiMock = TestingCommons.api() def upstreamMock = TestingCommons.upstream(apiMock) - MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock) + MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock) TrackEthereumAddress trackAddress = new TrackEthereumAddress(upstreams) apiMock.answerOnce("eth_getBalance", ["0xe2c8fa8120d813cd0b5e6add120295bf20cfa09f", "latest"], "0x499602D2") diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy index 7265110f..35d5e09d 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/TrackEthereumTxSpec.groovy @@ -44,7 +44,7 @@ import java.time.Instant class TrackEthereumTxSpec extends Specification { - def chain = Common.ChainRef.CHAIN_ETHEREUM + def chain = Common.ChainRef.CHAIN_ETHEREUM__MAINNET def txId = "0xba61ce4672751fd6086a9ac2b55547a5555af17535b6c0334ede2ecb6d64070a" def parent = BlockHash.from("0xa0e65cbc1b52a8ca60562112c6060552d882f16f34a9dba2ccdc05c0a6a27c22") @@ -100,7 +100,7 @@ class TrackEthereumTxSpec extends Specification { def apiMock = TestingCommons.api() def upstreamMock = TestingCommons.upstream(apiMock) - MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock) + MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock) TrackEthereumTx trackTx = new TrackEthereumTx(upstreams, Schedulers.parallel()) apiMock.answer("eth_getTransactionByHash", [txId], txJson) @@ -120,8 +120,8 @@ class TrackEthereumTxSpec extends Specification { setup: def apiMock = TestingCommons.api() def upstreamMock = TestingCommons.upstream(apiMock) - MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock) - ((EthereumPosMultiStream) upstreams.getUpstream(Chain.ETHEREUM)).head = Mock(DynamicMergedHead) { + MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock) + ((EthereumPosMultiStream) upstreams.getUpstream(Chain.ETHEREUM__MAINNET)).head = Mock(DynamicMergedHead) { _ * getFlux() >> Flux.empty() } def scheduler = VirtualTimeScheduler.create(true) @@ -130,9 +130,9 @@ class TrackEthereumTxSpec extends Specification { apiMock.answer("eth_getTransactionByHash", [txId], null) when: - def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM, Instant.now(), TransactionId.from(txId), 6) + def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM__MAINNET, Instant.now(), TransactionId.from(txId), 6) def act = StepVerifier.withVirtualTime( - { trackTx.subscribe(tx, upstreams.getUpstream(Chain.ETHEREUM).cast(EthereumPosMultiStream)) }, + { trackTx.subscribe(tx, upstreams.getUpstream(Chain.ETHEREUM__MAINNET).cast(EthereumPosMultiStream)) }, { scheduler }, 5) @@ -170,7 +170,7 @@ class TrackEthereumTxSpec extends Specification { def apiMock = TestingCommons.api() def upstreamMock = TestingCommons.upstream(apiMock) - MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock) + MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock) TrackEthereumTx trackTx = new TrackEthereumTx(upstreams, Schedulers.boundedElastic()) apiMock.answer("eth_getTransactionByHash", [txId], null, 2) @@ -191,10 +191,10 @@ class TrackEthereumTxSpec extends Specification { setup: def apiMock = TestingCommons.api() def upstreamMock = TestingCommons.upstream(apiMock) - MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock) + MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock) TrackEthereumTx trackTx = new TrackEthereumTx(upstreams, Schedulers.parallel()) - def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM, Instant.now(), TransactionId.from(txId), 6) + def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM__MAINNET, Instant.now(), TransactionId.from(txId), 6) def block = new BlockContainer( 100, BlockId.from(txId), BigInteger.ONE, Instant.now(), false, "".bytes, null, BlockId.from(txId), [TxId.from(txId)], 0, "unknown" @@ -213,10 +213,10 @@ class TrackEthereumTxSpec extends Specification { setup: def apiMock = TestingCommons.api() def upstreamMock = TestingCommons.upstream(apiMock) - MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, upstreamMock) + MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, upstreamMock) TrackEthereumTx trackTx = new TrackEthereumTx(upstreams, Schedulers.parallel()) - def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM, Instant.now(), TransactionId.from(txId), 6) + def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM__MAINNET, Instant.now(), TransactionId.from(txId), 6) def block = new BlockContainer( 100, BlockId.from(txId), BigInteger.ONE, Instant.now(), false, "".bytes, null, BlockId.from(txId), [TxId.from("0xa0e65cbc1b52a8ca60562112c6060552d882f16f34a9dba2ccdc05c0a6a27c22")], @@ -291,7 +291,7 @@ class TrackEthereumTxSpec extends Specification { def multi = Mock(EthereumPosMultiStream) { _ * getHead() >> upstreamMock.getHead() } - MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM, multi) + MultistreamHolder upstreams = new MultistreamHolderMock(Chain.ETHEREUM__MAINNET, multi) TrackEthereumTx trackTx = new TrackEthereumTx(upstreams, Schedulers.parallel()) diff --git a/src/test/groovy/io/emeraldpay/dshackle/startup/ConfiguredUpstreamsSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/startup/ConfiguredUpstreamsSpec.groovy index db80f9fa..99cb4750 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/startup/ConfiguredUpstreamsSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/startup/ConfiguredUpstreamsSpec.groovy @@ -44,7 +44,7 @@ class ConfiguredUpstreamsSpec extends Specification { def upstream = new UpstreamsConfig.Upstream() upstream.methods = methods when: - def act = configurer.buildMethods(upstream, Chain.ETHEREUM) + def act = configurer.buildMethods(upstream, Chain.ETHEREUM__MAINNET) then: act instanceof ManagedCallMethods act.createQuorumFor("foo_bar") instanceof NotNullQuorum @@ -75,7 +75,7 @@ class ConfiguredUpstreamsSpec extends Specification { def upstream = new UpstreamsConfig.Upstream() upstream.methods = methods when: - def act = configurer.buildMethods(upstream, Chain.ETHEREUM) + def act = configurer.buildMethods(upstream, Chain.ETHEREUM__MAINNET) then: act instanceof ManagedCallMethods new String(act.executeHardcoded("foo_bar")) == "\"static_response\"" @@ -161,7 +161,7 @@ class ConfiguredUpstreamsSpec extends Specification { def upstream = new UpstreamsConfig.Upstream() upstream.methodGroups = methodsGroup when: - def act = configurer.buildMethods(upstream, Chain.ETHEREUM) + def act = configurer.buildMethods(upstream, Chain.ETHEREUM__MAINNET) then: act instanceof ManagedCallMethods act.supportedMethods.findAll {it.containsIgnoreCase("filter")}.size() == 6 diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/EthereumPosRpcUpstreamMock.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/EthereumPosRpcUpstreamMock.groovy index 72258b5f..6dd3e71a 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/test/EthereumPosRpcUpstreamMock.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/test/EthereumPosRpcUpstreamMock.groovy @@ -42,7 +42,7 @@ class EthereumPosRpcUpstreamMock extends EthereumPosRpcUpstream { static CallMethods allMethods() { new AggregatedCallMethods([ - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), new DefaultBitcoinMethods(), new DirectCallMethods(["eth_test"]) ]) diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/EthereumRpcUpstreamMock.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/EthereumRpcUpstreamMock.groovy index fe1865ec..f1d7e0d8 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/test/EthereumRpcUpstreamMock.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/test/EthereumRpcUpstreamMock.groovy @@ -40,7 +40,7 @@ class EthereumRpcUpstreamMock extends EthereumRpcUpstream { static CallMethods allMethods() { new AggregatedCallMethods([ - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), new DefaultBitcoinMethods(), new DirectCallMethods(["eth_test"]) ]) diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy index e670774e..96f12b4a 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy @@ -52,23 +52,23 @@ class TestingCommons { } static EthereumPosRpcUpstreamMock upstream() { - return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api()) + return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api()) } static EthereumPosRpcUpstreamMock upstream(String id) { - return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM, api()) + return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM__MAINNET, api()) } static EthereumPosRpcUpstreamMock upstream(String id, String provider) { - return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM, api(), Collections.singletonMap("provider", provider)) + return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM__MAINNET, api(), Collections.singletonMap("provider", provider)) } static EthereumPosRpcUpstreamMock upstream(String id, Reader api) { - return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM, api) + return new EthereumPosRpcUpstreamMock(id, Chain.ETHEREUM__MAINNET, api) } static EthereumPosRpcUpstreamMock upstream(Reader api) { - return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api) + return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api) } static EthereumPosRpcUpstreamMock upstream(Reader api, String method) { @@ -76,11 +76,11 @@ class TestingCommons { } static EthereumPosRpcUpstreamMock upstream(Reader api, List methods) { - return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api, new DirectCallMethods(methods)) + return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api, new DirectCallMethods(methods)) } static EthereumPosRpcUpstreamMock upstream(Reader api, CallMethods callMethods) { - return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api, callMethods) + return new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api, callMethods) } static Multistream multistream(Reader api) { @@ -88,7 +88,7 @@ class TestingCommons { } static Multistream multistream(EthereumPosRpcUpstreamMock up) { - return new EthereumPosMultiStream(Chain.ETHEREUM, [up], Caches.default(), Schedulers.parallel(), tracerMock()).tap { + return new EthereumPosMultiStream(Chain.ETHEREUM__MAINNET, [up], Caches.default(), Schedulers.parallel(), tracerMock()).tap { start() } } @@ -103,8 +103,8 @@ class TestingCommons { static List defaultMultistreams() { return [ - multistreamWithoutUpstreams(Chain.ETHEREUM), - multistreamClassicWithoutUpstreams(Chain.ETHEREUM_CLASSIC) + multistreamWithoutUpstreams(Chain.ETHEREUM__MAINNET), + multistreamClassicWithoutUpstreams(Chain.ETHEREUM_CLASSIC__MAINNET) ] } diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/CurrentMultistreamHolderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/CurrentMultistreamHolderSpec.groovy index 1a8084f2..1ec7f3fe 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/CurrentMultistreamHolderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/CurrentMultistreamHolderSpec.groovy @@ -27,62 +27,62 @@ class CurrentMultistreamHolderSpec extends Specification { def "add upstream"() { setup: def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams()) - def up = new EthereumPosRpcUpstreamMock("test", Chain.ETHEREUM, TestingCommons.api()) + def up = new EthereumPosRpcUpstreamMock("test", Chain.ETHEREUM__MAINNET, TestingCommons.api()) when: - current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up, UpstreamChangeEvent.ChangeType.ADDED)) + current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up, UpstreamChangeEvent.ChangeType.ADDED)) then: - current.getAvailable() == [Chain.ETHEREUM] - current.getUpstream(Chain.ETHEREUM).getAll()[0] == up + current.getAvailable() == [Chain.ETHEREUM__MAINNET] + current.getUpstream(Chain.ETHEREUM__MAINNET).getAll()[0] == up } def "add multiple upstreams"() { setup: def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams()) - def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) - def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC, TestingCommons.api()) - def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM, TestingCommons.api()) + def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api()) + def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC__MAINNET, TestingCommons.api()) + def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM__MAINNET, TestingCommons.api()) when: - current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up1, UpstreamChangeEvent.ChangeType.ADDED)) - current.getUpstream(Chain.ETHEREUM_CLASSIC).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM_CLASSIC, up2, UpstreamChangeEvent.ChangeType.ADDED)) - current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up3, UpstreamChangeEvent.ChangeType.ADDED)) - current.getUpstream(Chain.ETHEREUM_CLASSIC).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up3, UpstreamChangeEvent.ChangeType.ADDED)) + current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED)) + current.getUpstream(Chain.ETHEREUM_CLASSIC__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM_CLASSIC__MAINNET, up2, UpstreamChangeEvent.ChangeType.ADDED)) + current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up3, UpstreamChangeEvent.ChangeType.ADDED)) + current.getUpstream(Chain.ETHEREUM_CLASSIC__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up3, UpstreamChangeEvent.ChangeType.ADDED)) then: - current.getAvailable().toSet() == [Chain.ETHEREUM, Chain.ETHEREUM_CLASSIC].toSet() - current.getUpstream(Chain.ETHEREUM).getAll().toSet() == [up1, up3].toSet() - current.getUpstream(Chain.ETHEREUM_CLASSIC).getAll().toSet() == [up2].toSet() + current.getAvailable().toSet() == [Chain.ETHEREUM__MAINNET, Chain.ETHEREUM_CLASSIC__MAINNET].toSet() + current.getUpstream(Chain.ETHEREUM__MAINNET).getAll().toSet() == [up1, up3].toSet() + current.getUpstream(Chain.ETHEREUM_CLASSIC__MAINNET).getAll().toSet() == [up2].toSet() } def "remove upstream"() { setup: def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams()) - def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) - def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC, TestingCommons.api()) - def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM, TestingCommons.api()) - def up1_del = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) + def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api()) + def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC__MAINNET, TestingCommons.api()) + def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM__MAINNET, TestingCommons.api()) + def up1_del = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api()) when: - current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up1, UpstreamChangeEvent.ChangeType.ADDED)) - current.getUpstream(Chain.ETHEREUM_CLASSIC).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM_CLASSIC, up2, UpstreamChangeEvent.ChangeType.ADDED)) - current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up3, UpstreamChangeEvent.ChangeType.ADDED)) - current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up1_del, UpstreamChangeEvent.ChangeType.REMOVED)) + current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED)) + current.getUpstream(Chain.ETHEREUM_CLASSIC__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM_CLASSIC__MAINNET, up2, UpstreamChangeEvent.ChangeType.ADDED)) + current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up3, UpstreamChangeEvent.ChangeType.ADDED)) + current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1_del, UpstreamChangeEvent.ChangeType.REMOVED)) then: - current.getAvailable().toSet() == [Chain.ETHEREUM, Chain.ETHEREUM_CLASSIC].toSet() - current.getUpstream(Chain.ETHEREUM).getAll().toSet() == [up3].toSet() - current.getUpstream(Chain.ETHEREUM_CLASSIC).getAll().toSet() == [up2].toSet() + current.getAvailable().toSet() == [Chain.ETHEREUM__MAINNET, Chain.ETHEREUM_CLASSIC__MAINNET].toSet() + current.getUpstream(Chain.ETHEREUM__MAINNET).getAll().toSet() == [up3].toSet() + current.getUpstream(Chain.ETHEREUM_CLASSIC__MAINNET).getAll().toSet() == [up2].toSet() } def "available after adding"() { setup: def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams()) - def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api()) + def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api()) when: - def act = current.isAvailable(Chain.ETHEREUM) + def act = current.isAvailable(Chain.ETHEREUM__MAINNET) then: !act when: - current.getUpstream(Chain.ETHEREUM).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM, up1, UpstreamChangeEvent.ChangeType.ADDED)) - act = current.isAvailable(Chain.ETHEREUM) + current.getUpstream(Chain.ETHEREUM__MAINNET).onUpstreamChange(new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED)) + act = current.isAvailable(Chain.ETHEREUM__MAINNET) then: act diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/FilteredApisSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/FilteredApisSpec.groovy index b38a4795..7fd36894 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/FilteredApisSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/FilteredApisSpec.groovy @@ -37,7 +37,7 @@ import static java.util.List.of class FilteredApisSpec extends Specification { - def ethereumTargets = new DefaultEthereumMethods(Chain.ETHEREUM) + def ethereumTargets = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) def "Verifies labels"() { setup: @@ -64,7 +64,7 @@ class FilteredApisSpec extends Specification { new EthereumRpcUpstream( "test", (byte) 123, - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, new UpstreamsConfig.PartialOptions().buildOptions(), UpstreamsConfig.UpstreamRole.PRIMARY, ethereumTargets, @@ -79,7 +79,7 @@ class FilteredApisSpec extends Specification { it.setStatus(UpstreamAvailability.OK) } when: - def iter = new FilteredApis(Chain.ETHEREUM, upstreams, matcher, 0, 1, 0) + def iter = new FilteredApis(Chain.ETHEREUM__MAINNET, upstreams, matcher, 0, 1, 0) iter.request(10) then: StepVerifier.create(iter) @@ -90,7 +90,7 @@ class FilteredApisSpec extends Specification { .verify(Duration.ofSeconds(1)) when: - iter = new FilteredApis(Chain.ETHEREUM, upstreams, matcher, 1, 1, 0) + iter = new FilteredApis(Chain.ETHEREUM__MAINNET, upstreams, matcher, 1, 1, 0) iter.request(10) then: StepVerifier.create(iter) @@ -101,7 +101,7 @@ class FilteredApisSpec extends Specification { .verify(Duration.ofSeconds(1)) when: - iter = new FilteredApis(Chain.ETHEREUM, upstreams, matcher, 1, 2, 0) + iter = new FilteredApis(Chain.ETHEREUM__MAINNET, upstreams, matcher, 1, 2, 0) iter.request(10) then: StepVerifier.create(iter) @@ -117,7 +117,7 @@ class FilteredApisSpec extends Specification { def "Exponential backoff"() { setup: - def apis = new FilteredApis(Chain.ETHEREUM, [], Selector.empty, 0, 1, 0) + def apis = new FilteredApis(Chain.ETHEREUM__MAINNET, [], Selector.empty, 0, 1, 0) expect: wait == apis.waitDuration(n).toMillis() as Integer where: @@ -139,7 +139,7 @@ class FilteredApisSpec extends Specification { @Retry def "Backoff uses jitter"() { setup: - def apis = new FilteredApis(Chain.ETHEREUM, [], Selector.empty, 0, 1, 20) + def apis = new FilteredApis(Chain.ETHEREUM__MAINNET, [], Selector.empty, 0, 1, 20) when: def act = apis.waitDuration(1).toMillis() println act @@ -165,7 +165,7 @@ class FilteredApisSpec extends Specification { def up2 = TestingCommons.upstream(api2) then: StepVerifier.withVirtualTime({ - def apis = new FilteredApis(Chain.ETHEREUM, [up1, up2], Selector.empty, 0, 4, 0) + def apis = new FilteredApis(Chain.ETHEREUM__MAINNET, [up1, up2], Selector.empty, 0, 4, 0) apis.request(10) return apis }) @@ -189,7 +189,7 @@ class FilteredApisSpec extends Specification { TestingCommons.upstream(it) } when: - def act = new FilteredApis(Chain.ETHEREUM, ups, Selector.empty, 2, 1, 0) + def act = new FilteredApis(Chain.ETHEREUM__MAINNET, ups, Selector.empty, 2, 1, 0) act.request(10) then: StepVerifier.create(act) @@ -208,7 +208,7 @@ class FilteredApisSpec extends Specification { TestingCommons.upstream(it) } when: - def act = new FilteredApis(Chain.ETHEREUM, ups, Selector.empty, 2, 1, 0) + def act = new FilteredApis(Chain.ETHEREUM__MAINNET, ups, Selector.empty, 2, 1, 0) act.request(3) then: StepVerifier.create(act) @@ -265,7 +265,7 @@ class FilteredApisSpec extends Specification { } ] when: - def act = new FilteredApis(Chain.ETHEREUM, + def act = new FilteredApis(Chain.ETHEREUM__MAINNET, [] + fallback + standard, Selector.empty, 0, 3, 0) act.request(10) @@ -305,7 +305,7 @@ class FilteredApisSpec extends Specification { } ] when: - def act = new FilteredApis(Chain.ETHEREUM, + def act = new FilteredApis(Chain.ETHEREUM__MAINNET, [] + fallback + standard + secondary, Selector.empty, 0, 3, 0) act.request(11) @@ -342,7 +342,7 @@ class FilteredApisSpec extends Specification { } ] when: - def act = new FilteredApis(Chain.ETHEREUM, + def act = new FilteredApis(Chain.ETHEREUM__MAINNET, [] + lagging + ok, Selector.empty, 0, 2, 0) act.request(4) @@ -373,7 +373,7 @@ class FilteredApisSpec extends Specification { } ] when: - def act = new FilteredApis(Chain.ETHEREUM, ups, Selector.empty) + def act = new FilteredApis(Chain.ETHEREUM__MAINNET, ups, Selector.empty) act.request(1) then: StepVerifier.create(act) @@ -404,7 +404,7 @@ class FilteredApisSpec extends Specification { } ] when: - def act = new FilteredApis(Chain.ETHEREUM, ups, new Selector.LabelMatcher("node", of("test"))) + def act = new FilteredApis(Chain.ETHEREUM__MAINNET, ups, new Selector.LabelMatcher("node", of("test"))) act.request(1) then: StepVerifier.create(act) @@ -446,7 +446,7 @@ class FilteredApisSpec extends Specification { ] when: def act = new FilteredApis( - Chain.ETHEREUM, ups, + Chain.ETHEREUM__MAINNET, ups, new Selector.MultiMatcher( of( new Selector.HeightMatcher(100000000), @@ -495,7 +495,7 @@ class FilteredApisSpec extends Specification { ] when: def act = new FilteredApis( - Chain.ETHEREUM, ups, + Chain.ETHEREUM__MAINNET, ups, new Selector.MultiMatcher( of( new Selector.HeightMatcher(100000000), @@ -539,7 +539,7 @@ class FilteredApisSpec extends Specification { ] when: def act = new FilteredApis( - Chain.ETHEREUM, ups, + Chain.ETHEREUM__MAINNET, ups, new Selector.MultiMatcher( of( new Selector.HeightMatcher(100000000), diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy index 5fec4876..a97cf43f 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy @@ -50,9 +50,9 @@ class MultistreamSpec extends Specification { def "Aggregates methods"() { 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.parallel(), TestingCommons.tracerMock()) + def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2"])) + def up2 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api(), new DirectCallMethods(["eth_test2", "eth_test3"])) + def aggr = new EthereumPosMultiStream(Chain.ETHEREUM__MAINNET, [up1, up2], Caches.default(), Schedulers.parallel(), TestingCommons.tracerMock()) when: aggr.onUpstreamsUpdated() def act = aggr.getMethods() @@ -183,7 +183,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.parallel(), TestingCommons.tracerMock()) + def multistream = new EthereumPosMultiStream(Chain.ETHEREUM__MAINNET, [up1, up2, up3], Caches.default(), Schedulers.parallel(), TestingCommons.tracerMock()) expect: multistream.getHead(new Selector.LabelMatcher("provider", ["internal"])).is(up1.ethereumHeadMock) @@ -200,7 +200,7 @@ class MultistreamSpec extends Specification { setup: def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder() - .setChainValue(Chain.ETHEREUM.id) + .setChainValue(Chain.ETHEREUM__MAINNET.id) .setMethod("newHeads") .build() @@ -214,7 +214,7 @@ class MultistreamSpec extends Specification { 1 * getId() >> "external" 1 * getLabels() >> [UpstreamsConfig.Labels.fromMap(Collections.singletonMap("provider", "external"))] } - def multiStream = new TestEthereumPosMultistream(Chain.ETHEREUM, [up1, up2], Caches.default()) + def multiStream = new TestEthereumPosMultistream(Chain.ETHEREUM__MAINNET, [up1, up2], Caches.default()) when: def act = multiStream.tryProxy(new Selector.LabelMatcher("provider", ["internal"]), call) @@ -230,7 +230,7 @@ class MultistreamSpec extends Specification { setup: def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder() - .setChainValue(Chain.ETHEREUM.id) + .setChainValue(Chain.ETHEREUM__MAINNET.id) .setMethod("newHeads") .build() @@ -239,7 +239,7 @@ class MultistreamSpec extends Specification { 1 * getId() >> "2" 1 * getLabels() >> [UpstreamsConfig.Labels.fromMap(Collections.singletonMap("provider", "internal"))] } - def multiStream = new TestEthereumPosMultistream(Chain.ETHEREUM, [up2], Caches.default()) + def multiStream = new TestEthereumPosMultistream(Chain.ETHEREUM__MAINNET, [up2], Caches.default()) when: def act = multiStream.tryProxy(new Selector.LabelMatcher("provider", ["internal"]), call) @@ -250,15 +250,15 @@ class MultistreamSpec extends Specification { def "Change ms methods based on upstream availability"() { setup: - def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2", "eth_test3"])) - def up2 = new EthereumPosRpcUpstreamMock("test2", Chain.ETHEREUM, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2"])) - def ms = new EthereumPosMultiStream(Chain.ETHEREUM, new ArrayList(), Caches.default(), Schedulers.parallel(), TestingCommons.tracerMock()) + def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM__MAINNET, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2", "eth_test3"])) + def up2 = new EthereumPosRpcUpstreamMock("test2", Chain.ETHEREUM__MAINNET, TestingCommons.api(), new DirectCallMethods(["eth_test1", "eth_test2"])) + def ms = new EthereumPosMultiStream(Chain.ETHEREUM__MAINNET, new ArrayList(), Caches.default(), Schedulers.parallel(), TestingCommons.tracerMock()) when: ms.onUpstreamChange( - new UpstreamChangeEvent(Chain.ETHEREUM, up1, UpstreamChangeEvent.ChangeType.ADDED) + new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED) ) ms.onUpstreamChange( - new UpstreamChangeEvent(Chain.ETHEREUM, up2, UpstreamChangeEvent.ChangeType.ADDED) + new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up2, UpstreamChangeEvent.ChangeType.ADDED) ) def states = ms.subscribeStateChanges() then: diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethodsSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethodsSpec.groovy index 992a4be2..1c496740 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethodsSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethodsSpec.groovy @@ -7,7 +7,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "eth_chainId is available"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) when: def act = methods.isAvailable("eth_chainId") then: @@ -16,7 +16,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "eth_chainId is hardcoded"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) when: def act = methods.isHardcoded("eth_chainId") then: @@ -25,7 +25,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "eth_chainId is not callable"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) when: def act = methods.isCallable("eth_chainId") then: @@ -37,17 +37,17 @@ class DefaultEthereumMethodsSpec extends Specification { new String(new DefaultEthereumMethods(chain).executeHardcoded("eth_chainId")) == id where: chain | id - Chain.ETHEREUM | '"0x1"' - Chain.ETHEREUM_CLASSIC | '"0x3d"' - Chain.TESTNET_KOVAN | '"0x2a"' - Chain.TESTNET_GOERLI | '"0x5"' - Chain.TESTNET_RINKEBY | '"0x4"' - Chain.TESTNET_ROPSTEN | '"0x3"' + Chain.ETHEREUM__MAINNET | '"0x1"' + Chain.ETHEREUM_CLASSIC__MAINNET | '"0x3d"' + Chain.ETHEREUM__KOVAN | '"0x2a"' + Chain.ETHEREUM__GOERLI | '"0x5"' + Chain.ETHEREUM__RINKEBY | '"0x4"' + Chain.ETHEREUM__ROPSTEN | '"0x3"' } def "Optimism chain unsupported methods"() { setup: - def methods = new DefaultEthereumMethods(Chain.OPTIMISM) + def methods = new DefaultEthereumMethods(Chain.OPTIMISM__MAINNET) when: def acc = methods.isAvailable("eth_getAccounts") def trans = methods.isAvailable("eth_sendTransaction") @@ -61,18 +61,18 @@ class DefaultEthereumMethodsSpec extends Specification { new DefaultEthereumMethods(chain).getSupportedMethods().containsAll(methods) where: chain | methods - Chain.POLYGON | ["bor_getAuthor", - "bor_getCurrentValidators", - "bor_getCurrentProposer", - "bor_getRootHash", - "bor_getSignersAtHash", - "eth_getRootHash"] - Chain.OPTIMISM | ["rollup_gasPrices"] + Chain.POLYGON_POS__MAINNET | ["bor_getAuthor", + "bor_getCurrentValidators", + "bor_getCurrentProposer", + "bor_getRootHash", + "bor_getSignersAtHash", + "eth_getRootHash"] + Chain.OPTIMISM__MAINNET | ["rollup_gasPrices"] } def "Has no filter methods by default"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) when: def act = methods.getSupportedMethods().findAll { it.containsIgnoreCase("filter") } then: @@ -81,7 +81,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "Has no trace methods by default"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) when: def act = methods.getSupportedMethods().findAll { it.containsIgnoreCase("trace") } then: diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy index d2416776..fa4c1de4 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy @@ -94,7 +94,7 @@ class ManagedCallMethodsSpec extends Specification { def "Use custom quorum if provided"() { setup: def managed = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_test", "eth_foo", "eth_bar"] as Set, [] as Set, [] as Set, @@ -120,7 +120,7 @@ class ManagedCallMethodsSpec extends Specification { def "Doesn't reuse same instance"() { def managed = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_test"] as Set, [] as Set, [] as Set, @@ -145,7 +145,7 @@ class ManagedCallMethodsSpec extends Specification { def "Test enable method group"() { setup: def managed = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), [] as Set, [] as Set, ["filter"] as Set, @@ -169,7 +169,7 @@ class ManagedCallMethodsSpec extends Specification { def "Test enable method group minus one"() { setup: def managed = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), [] as Set, ["eth_newPendingTransactionFilter"] as Set, ["filter"] as Set, @@ -193,7 +193,7 @@ class ManagedCallMethodsSpec extends Specification { def "Test disabled group not disable enabled method"() { setup: def managed = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_newPendingTransactionFilter"] as Set, [] as Set, [] as Set, 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 c60d4047..55a05ccd 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/ERC20BalanceSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/ERC20BalanceSpec.groovy @@ -47,7 +47,7 @@ class ERC20BalanceSpec extends Specification { JsonRpcResponse.ok('"0x0000000000000000000000000000000000000000000000000000001f28d72868"') ) - EthereumPosRpcUpstream upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api) + EthereumPosRpcUpstream upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api) ERC20Token token = new ERC20Token(Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9")) ERC20Balance query = new ERC20Balance() @@ -73,12 +73,12 @@ class ERC20BalanceSpec extends Specification { JsonRpcResponse.ok('"0x0000000000000000000000000000000000000000000000000000001f28d72868"') ) - EthereumPosRpcUpstream upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM, api) + EthereumPosRpcUpstream upstream = new EthereumPosRpcUpstreamMock(Chain.ETHEREUM__MAINNET, api) ERC20Token token = new ERC20Token(Address.from("0x54EedeAC495271d0F6B175474E89094C44Da98b9")) ERC20Balance query = new ERC20Balance() ApiSource apiSource = new FilteredApis( - Chain.ETHEREUM, [upstream], Selector.empty + Chain.ETHEREUM__MAINNET, [upstream], Selector.empty ) when: diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumCachingReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumCachingReaderSpec.groovy index 08b8723c..0e6c1675 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumCachingReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumCachingReaderSpec.groovy @@ -50,7 +50,7 @@ class EthereumDirectReaderSpec extends Specification { 1 * getApiSource(_) >> Stub(ApiSource) } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -80,7 +80,7 @@ class EthereumDirectReaderSpec extends Specification { 1 * getApiSource(_) >> Stub(ApiSource) } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -118,7 +118,7 @@ class EthereumDirectReaderSpec extends Specification { ) >> Stub(ApiSource) } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -154,7 +154,7 @@ class EthereumDirectReaderSpec extends Specification { 1 * getApiSource(_) >> Stub(ApiSource) } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -190,7 +190,7 @@ class EthereumDirectReaderSpec extends Specification { 1 * getApiSource(_) >> Stub(ApiSource) } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -223,7 +223,7 @@ class EthereumDirectReaderSpec extends Specification { 1 * getApiSource(_) >> Stub(ApiSource) } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } def caches = Mock(Caches) { // note that the Caches needs a Height value, otherwise it's not cached @@ -255,7 +255,7 @@ class EthereumDirectReaderSpec extends Specification { 1 * getApiSource(_) >> Stub(ApiSource) } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -286,7 +286,7 @@ class EthereumDirectReaderSpec extends Specification { } } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -318,7 +318,7 @@ class EthereumDirectReaderSpec extends Specification { } } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -355,7 +355,7 @@ class EthereumDirectReaderSpec extends Specification { 3 * getApiSource(_) >> Stub(ApiSource) } def calls = Mock(Factory) { - 3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } def result = Mono.just( new QuorumRpcReader.Result( @@ -398,7 +398,7 @@ class EthereumDirectReaderSpec extends Specification { 3 * getApiSource(_) >> Stub(ApiSource) } def calls = Mock(Factory) { - 3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } def result = Mono.just( new QuorumRpcReader.Result( @@ -436,7 +436,7 @@ class EthereumDirectReaderSpec extends Specification { } } def calls = Mock(Factory) { - 4 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM) + 4 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReaderSpec.groovy index e5639b7d..18e64aef 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReaderSpec.groovy @@ -21,12 +21,12 @@ class EthereumLocalReaderSpec extends Specification { def "Calls hardcoded"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) def router = new EthereumLocalReader( new EthereumCachingReader( TestingCommons.multistream(TestingCommons.api()), Caches.default(), - ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM)), + ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)), TestingCommons.tracerMock() ), methods, @@ -41,12 +41,12 @@ class EthereumLocalReaderSpec extends Specification { def "Returns empty if nonce set"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) def router = new EthereumLocalReader( new EthereumCachingReader( TestingCommons.multistream(TestingCommons.api()), Caches.default(), - ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM)), + ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)), TestingCommons.tracerMock() ), methods, @@ -72,7 +72,7 @@ class EthereumLocalReaderSpec extends Specification { 1 * read(101L) >> Mono.just(TestingCommons.blockForEthereum(101L)) } } - def methods = new DefaultEthereumMethods(Chain.ETHEREUM) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) def router = new EthereumLocalReader(reader, methods, head, true) when: @@ -98,7 +98,7 @@ class EthereumLocalReaderSpec extends Specification { 1 * read(0L) >> Mono.just(TestingCommons.blockForEthereum(0L)) } } - def methods = new DefaultEthereumMethods(Chain.ETHEREUM) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) def router = new EthereumLocalReader(reader, methods, head, true) when: @@ -124,7 +124,7 @@ class EthereumLocalReaderSpec extends Specification { 1 * read(74735L) >> Mono.just(TestingCommons.blockForEthereum(74735L)) } } - def methods = new DefaultEthereumMethods(Chain.ETHEREUM) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) def router = new EthereumLocalReader(reader, methods, head, true) when: @@ -148,7 +148,7 @@ class EthereumLocalReaderSpec extends Specification { _ * txByHashAsCont() >> new EmptyReader<>() _ * blocksByHeightAsCont() >> new EmptyReader<>() } - def methods = new DefaultEthereumMethods(Chain.ETHEREUM) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) def router = new EthereumLocalReader(reader, methods, head, true) when: diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionImplRealSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionImplRealSpec.groovy index c15646ac..daaf4fa1 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionImplRealSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionImplRealSpec.groovy @@ -37,7 +37,7 @@ class WsConnectionImplRealSpec extends Specification { 1, new EthereumWsConnectionFactory( "test", - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, "ws://localhost:${port}".toURI(), "http://localhost:${port}".toURI(), Schedulers.parallel() @@ -117,7 +117,7 @@ class WsConnectionImplRealSpec extends Specification { 1, new EthereumWsConnectionFactory( "test", - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, "ws://localhost:${port}".toURI(), "http://localhost:${port}".toURI(), Schedulers.parallel() diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionImplSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionImplSpec.groovy index ce2eb9c8..180d853c 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionImplSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/WsConnectionImplSpec.groovy @@ -38,7 +38,7 @@ class WsConnectionImplSpec extends Specification { 1, new EthereumWsConnectionFactory( "test", - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, new URI("http://localhost"), new URI("http://localhost"), Schedulers.parallel() @@ -73,7 +73,7 @@ class WsConnectionImplSpec extends Specification { 1, new EthereumWsConnectionFactory( "test", - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, new URI("http://localhost"), new URI("http://localhost"), Schedulers.parallel() @@ -106,7 +106,7 @@ class WsConnectionImplSpec extends Specification { 1, new EthereumWsConnectionFactory( "test", - Chain.ETHEREUM, + Chain.ETHEREUM__MAINNET, new URI("http://localhost"), new URI("http://localhost"), Schedulers.parallel() diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/DshacklePendingTxesSourceSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/DshacklePendingTxesSourceSpec.groovy index c8f5143b..e874e490 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/DshacklePendingTxesSourceSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/subscribe/DshacklePendingTxesSourceSpec.groovy @@ -67,7 +67,7 @@ class DshacklePendingTxesSourceSpec extends Specification { .build() def remote = ReactorBlockchainGrpc.newReactorStub(channel) - def pending = new DshacklePendingTxesSource(Chain.ETHEREUM, remote) + def pending = new DshacklePendingTxesSource(Chain.ETHEREUM__MAINNET, remote) when: pending.available = true @@ -76,7 +76,7 @@ class DshacklePendingTxesSourceSpec extends Specification { then: receivedRequest != null - receivedRequest.chainValue == Chain.ETHEREUM.id + receivedRequest.chainValue == Chain.ETHEREUM__MAINNET.id receivedRequest.method == "newPendingTransactions" txes.collect {it.toHex() } == [ "0xa61bab14fc9720ea8725622688c2f964666d7c2afdae38af7dad53f12f242d5c", @@ -87,7 +87,7 @@ class DshacklePendingTxesSourceSpec extends Specification { def "available when method is enabled on remote"() { setup: - def pending = new DshacklePendingTxesSource(Chain.ETHEREUM, ReactorBlockchainGrpc.newReactorStub(Stub(Channel))) + def pending = new DshacklePendingTxesSource(Chain.ETHEREUM__MAINNET, ReactorBlockchainGrpc.newReactorStub(Stub(Channel))) pending.available = false when: pending.update( @@ -101,7 +101,7 @@ class DshacklePendingTxesSourceSpec extends Specification { def "unavailable when not method is enabled on remote"() { setup: - def pending = new DshacklePendingTxesSource(Chain.ETHEREUM, ReactorBlockchainGrpc.newReactorStub(Stub(Channel))) + def pending = new DshacklePendingTxesSource(Chain.ETHEREUM__MAINNET, ReactorBlockchainGrpc.newReactorStub(Stub(Channel))) pending.available = false when: pending.update( diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/grpc/EthereumGrpcUpstreamSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/grpc/EthereumGrpcUpstreamSpec.groovy index f943bf6c..0b17d0f8 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/grpc/EthereumGrpcUpstreamSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/grpc/EthereumGrpcUpstreamSpec.groovy @@ -61,7 +61,7 @@ class EthereumGrpcUpstreamSpec extends Specification { def "Subscribe to head"() { setup: def callData = [:] - def chain = Chain.ETHEREUM + def chain = Chain.ETHEREUM__MAINNET def api = TestingCommons.api() def block1 = new BlockJson().with { it.number = 650246 @@ -106,7 +106,7 @@ class EthereumGrpcUpstreamSpec extends Specification { new Thread({ Thread.sleep(50); upstream.head.start() }).start() def h = upstream.head.getFlux().next().block(Duration.ofSeconds(1)) then: - callData.chain == Chain.ETHEREUM.id + callData.chain == Chain.ETHEREUM__MAINNET.id upstream.status == UpstreamAvailability.OK upstream.getBuildInfo() == buildInfo h.hash == BlockId.from("0x50d26e119968e791970d84a7bf5d0ec474d3ec2ef85d5ec8915210ac6bc09ad7") @@ -162,7 +162,7 @@ class EthereumGrpcUpstreamSpec extends Specification { }).start() } }) - def upstream = new EthereumGrpcUpstream("test", hash, UpstreamsConfig.UpstreamRole.PRIMARY, Chain.ETHEREUM, client, new JsonRpcGrpcClient(client, Chain.ETHEREUM, metrics), null, ChainsConfig.ChainConfig.default(), Schedulers.parallel()) + def upstream = new EthereumGrpcUpstream("test", hash, UpstreamsConfig.UpstreamRole.PRIMARY, Chain.ETHEREUM__MAINNET, client, new JsonRpcGrpcClient(client, Chain.ETHEREUM__MAINNET, metrics), null, ChainsConfig.ChainConfig.default(), Schedulers.parallel()) upstream.setLag(0) upstream.update( BlockchainOuterClass.DescribeChain.newBuilder() @@ -187,7 +187,7 @@ class EthereumGrpcUpstreamSpec extends Specification { setup: def callData = [:] def finished = new CompletableFuture() - def chain = Chain.ETHEREUM + def chain = Chain.ETHEREUM__MAINNET def api = TestingCommons.api() def block1 = new BlockJson().with { it.number = 650246 @@ -258,7 +258,7 @@ class EthereumGrpcUpstreamSpec extends Specification { def "Send update status if methods were changed"() { setup: - def chain = Chain.ETHEREUM + def chain = Chain.ETHEREUM__MAINNET def client = mockServer.clientForServer(new BlockchainGrpc.BlockchainImplBase() { @Override void nativeCall(BlockchainOuterClass.NativeCallRequest request, StreamObserver responseObserver) { diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/grpc/GrpcHeadSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/grpc/GrpcHeadSpec.groovy index 6e518ac6..8ee22c2d 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/grpc/GrpcHeadSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/grpc/GrpcHeadSpec.groovy @@ -39,7 +39,7 @@ class GrpcHeadSpec extends Specification { def client = mockServer.clientForServer(new BlockchainGrpc.BlockchainImplBase() { @Override void subscribeHead(Common.Chain request, StreamObserver responseObserver) { - if (request.type.number != Chain.BITCOIN.id) { + if (request.type.number != Chain.BITCOIN__MAINNET.id) { responseObserver.onError(new IllegalStateException("Unsupported chain")) return } @@ -64,7 +64,7 @@ class GrpcHeadSpec extends Specification { } def head = new GrpcHead( "test", - Chain.BITCOIN, + Chain.BITCOIN__MAINNET, Stub(DefaultUpstream), client, convert, @@ -92,7 +92,7 @@ class GrpcHeadSpec extends Specification { def client = mockServer.clientForServer(new BlockchainGrpc.BlockchainImplBase() { @Override void subscribeHead(Common.Chain request, StreamObserver responseObserver) { - if (request.type.number != Chain.BITCOIN.id) { + if (request.type.number != Chain.BITCOIN__MAINNET.id) { responseObserver.onError(new IllegalStateException("Unsupported chain")) return } @@ -131,7 +131,7 @@ class GrpcHeadSpec extends Specification { } def head = new GrpcHead( "test", - Chain.BITCOIN, + Chain.BITCOIN__MAINNET, Stub(DefaultUpstream), client, convert, diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcGrpcClientSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcGrpcClientSpec.groovy index 2da81e0f..79d7c99b 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcGrpcClientSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcGrpcClientSpec.groovy @@ -34,7 +34,7 @@ class JsonRpcGrpcClientSpec extends Specification { } }) def client = new JsonRpcGrpcClient( - grpc, Chain.BITCOIN, null + grpc, Chain.BITCOIN__MAINNET, null ).getReader() when: @@ -47,7 +47,7 @@ class JsonRpcGrpcClientSpec extends Specification { act.resultAsProcessedString == "hello world!" requested.get() == BlockchainOuterClass.NativeCallRequest.newBuilder() - .setChain(Common.ChainRef.CHAIN_BITCOIN) + .setChain(Common.ChainRef.CHAIN_BITCOIN__MAINNET) .addAllItems([ BlockchainOuterClass.NativeCallItem.newBuilder() .setId(1) @@ -68,7 +68,7 @@ class JsonRpcGrpcClientSpec extends Specification { } }) def client = new JsonRpcGrpcClient( - grpc, Chain.BITCOIN, null + grpc, Chain.BITCOIN__MAINNET, null ).getReader() when: diff --git a/src/test/kotlin/io/emeraldpay/dshackle/IntegrationTest.kt b/src/test/kotlin/io/emeraldpay/dshackle/IntegrationTest.kt index ea89bbe8..fac73601 100644 --- a/src/test/kotlin/io/emeraldpay/dshackle/IntegrationTest.kt +++ b/src/test/kotlin/io/emeraldpay/dshackle/IntegrationTest.kt @@ -71,7 +71,7 @@ class IntegrationTest { fun test() { val result = stub.describe(BlockchainOuterClass.DescribeRequest.newBuilder().build()) Assertions.assertThat(result.chainsCount).isEqualTo(1) - Assertions.assertThat(result.chainsList[0].chain).isEqualTo(ChainRef.CHAIN_ETHEREUM) + Assertions.assertThat(result.chainsList[0].chain).isEqualTo(ChainRef.CHAIN_ETHEREUM__MAINNET) Assertions.assertThat(result.chainsList[0].nodesCount).isEqualTo(1) } diff --git a/src/test/kotlin/io/emeraldpay/dshackle/config/ChainsConfigTest.kt b/src/test/kotlin/io/emeraldpay/dshackle/config/ChainsConfigTest.kt index a6b25a80..e91cad4b 100644 --- a/src/test/kotlin/io/emeraldpay/dshackle/config/ChainsConfigTest.kt +++ b/src/test/kotlin/io/emeraldpay/dshackle/config/ChainsConfigTest.kt @@ -10,18 +10,18 @@ internal class ChainsConfigTest { fun patch() { val orig = ChainsConfig( mapOf( - Chain.BITCOIN to createRawChainConfig(0, 0), - Chain.ETHEREUM to createRawChainConfig(1, 2), - Chain.POLYGON to createRawChainConfig(3, 4) + Chain.BITCOIN__MAINNET to createRawChainConfig(0, 0), + Chain.ETHEREUM__MAINNET to createRawChainConfig(1, 2), + Chain.POLYGON_POS__MAINNET to createRawChainConfig(3, 4) ), createRawChainConfig(1, 2) ) val patch = ChainsConfig( mapOf( - Chain.BITCOIN to createRawChainConfig(null, 10000), - Chain.POLYGON to createRawChainConfig(10, 11), - Chain.ARBITRUM to createRawChainConfig(999, 999) + Chain.BITCOIN__MAINNET to createRawChainConfig(null, 10000), + Chain.POLYGON_POS__MAINNET to createRawChainConfig(10, 11), + Chain.ARBITRUM__MAINNET to createRawChainConfig(999, 999) ), createRawChainConfig(100, null) ) @@ -31,10 +31,10 @@ internal class ChainsConfigTest { assertEquals( ChainsConfig( mapOf( - Chain.BITCOIN to createRawChainConfig(0, 10000), - Chain.ETHEREUM to createRawChainConfig(1, 2), - Chain.POLYGON to createRawChainConfig(10, 11), - Chain.ARBITRUM to createRawChainConfig(999, 999) + Chain.BITCOIN__MAINNET to createRawChainConfig(0, 10000), + Chain.ETHEREUM__MAINNET to createRawChainConfig(1, 2), + Chain.POLYGON_POS__MAINNET to createRawChainConfig(10, 11), + Chain.ARBITRUM__MAINNET to createRawChainConfig(999, 999) ), createRawChainConfig(100, 2) ),