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