Bump the gradle-minor-and-patch group across 1 directory with 65 updates (#841)
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.bitcoin
|
||||
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.base.Address
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import io.emeraldpay.dshackle.upstream.Lifecycle
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.data.SimpleUnspent
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.base.Address
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.kotlin.core.publisher.cast
|
||||
|
||||
@@ -22,7 +22,7 @@ import io.netty.handler.codec.http.HttpHeaderNames
|
||||
import io.netty.handler.codec.http.HttpHeaders
|
||||
import io.netty.handler.ssl.SslContextBuilder
|
||||
import io.netty.resolver.DefaultAddressResolverGroup
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.base.Address
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.netty.http.client.HttpClient
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.emeraldpay.dshackle.upstream.bitcoin
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.data.EsploraUnspent
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.data.SimpleUnspent
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.base.Address
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Mono
|
||||
import java.util.function.Function
|
||||
|
||||
@@ -26,7 +26,8 @@ import io.emeraldpay.dshackle.upstream.calls.CallMethods
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.base.Address
|
||||
import org.bitcoinj.base.AddressParser
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -70,7 +71,7 @@ class LocalCallRouter(
|
||||
}
|
||||
val addresses = key.params.list[2]
|
||||
if (addresses is List<*> && addresses.size > 0) {
|
||||
val address = addresses[0].toString().let { Address.fromString(null, it) }
|
||||
val address = addresses[0].toString().let { AddressParser.getDefault().parseAddress(it) }
|
||||
return reader.listUnspent(address).map {
|
||||
val rpc = it.map(convertUnspent(address))
|
||||
val json = Global.objectMapper.writeValueAsBytes(rpc)
|
||||
|
||||
@@ -3,7 +3,7 @@ package io.emeraldpay.dshackle.upstream.bitcoin
|
||||
import io.emeraldpay.dshackle.upstream.Capability
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.data.SimpleUnspent
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.base.Address
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
class RemoteUnspentReader(
|
||||
|
||||
@@ -24,7 +24,7 @@ import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.data.RpcUnspent
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.data.SimpleUnspent
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.base.Address
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
|
||||
@@ -17,6 +17,6 @@ package io.emeraldpay.dshackle.upstream.bitcoin
|
||||
|
||||
import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.data.SimpleUnspent
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.base.Address
|
||||
|
||||
interface UnspentReader : Reader<Address, List<SimpleUnspent>>
|
||||
|
||||
@@ -15,15 +15,16 @@
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.bitcoin
|
||||
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.core.ECKey
|
||||
import org.bitcoinj.base.Address
|
||||
import org.bitcoinj.base.BitcoinNetwork
|
||||
import org.bitcoinj.base.LegacyAddress
|
||||
import org.bitcoinj.base.ScriptType
|
||||
import org.bitcoinj.base.SegwitAddress
|
||||
import org.bitcoinj.core.NetworkParameters
|
||||
import org.bitcoinj.crypto.ChildNumber
|
||||
import org.bitcoinj.crypto.DeterministicKey
|
||||
import org.bitcoinj.crypto.ECKey
|
||||
import org.bitcoinj.crypto.HDKeyDerivation
|
||||
import org.bitcoinj.params.MainNetParams
|
||||
import org.bitcoinj.params.TestNet3Params
|
||||
import org.bitcoinj.script.Script
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.util.function.Tuples
|
||||
@@ -35,8 +36,6 @@ open class XpubAddresses(
|
||||
|
||||
companion object {
|
||||
private val log = LoggerFactory.getLogger(XpubAddresses::class.java)
|
||||
private val MAINNET = MainNetParams()
|
||||
private val TESTNET = TestNet3Params()
|
||||
private val INACTIVE_LIMIT = 20
|
||||
}
|
||||
|
||||
@@ -45,39 +44,45 @@ open class XpubAddresses(
|
||||
// https://electrum.readthedocs.io/en/latest/xpub_version_bytes.html
|
||||
// TODO doesn't support SH keys right now. should?
|
||||
val prefix = xpub.substring(0, 4)
|
||||
val type: Script.ScriptType
|
||||
val network: NetworkParameters
|
||||
val type: ScriptType
|
||||
val params: NetworkParameters
|
||||
|
||||
when (prefix) {
|
||||
"xpub" -> {
|
||||
type = Script.ScriptType.P2PKH
|
||||
network = MAINNET
|
||||
type = ScriptType.P2PKH
|
||||
params = NetworkParameters.of(BitcoinNetwork.MAINNET)
|
||||
}
|
||||
"zpub" -> {
|
||||
type = Script.ScriptType.P2WPKH
|
||||
network = MAINNET
|
||||
type = ScriptType.P2WPKH
|
||||
params = NetworkParameters.of(BitcoinNetwork.MAINNET)
|
||||
}
|
||||
"tpub" -> {
|
||||
type = Script.ScriptType.P2PKH
|
||||
network = TESTNET
|
||||
type = ScriptType.P2PKH
|
||||
params = NetworkParameters.of(BitcoinNetwork.TESTNET)
|
||||
}
|
||||
"vpub" -> {
|
||||
type = Script.ScriptType.P2WPKH
|
||||
network = TESTNET
|
||||
type = ScriptType.P2WPKH
|
||||
params = NetworkParameters.of(BitcoinNetwork.TESTNET)
|
||||
}
|
||||
else -> return Flux.error(IllegalArgumentException("Unsupported type: $prefix"))
|
||||
}
|
||||
|
||||
val key: DeterministicKey
|
||||
try {
|
||||
key = DeterministicKey.deserializeB58(xpub, network)
|
||||
key = DeterministicKey.deserializeB58(xpub, params)
|
||||
} catch (t: Throwable) {
|
||||
return Flux.error(t)
|
||||
}
|
||||
|
||||
return Flux.range(start, limit)
|
||||
.map { HDKeyDerivation.deriveChildKey(key, ChildNumber(it, false)) }
|
||||
.map { Address.fromKey(network, ECKey.fromPublicOnly(it.pubKeyPoint), type) }
|
||||
.map { addressFromKey(params, ECKey.fromPublicOnly(it.pubKey), type) }
|
||||
}
|
||||
|
||||
private fun addressFromKey(params: NetworkParameters, key: ECKey, type: ScriptType): Address = when (type) {
|
||||
ScriptType.P2PKH -> LegacyAddress.fromKey(params, key)
|
||||
ScriptType.P2WPKH -> SegwitAddress.fromKey(params, key)
|
||||
else -> throw IllegalArgumentException("Unsupported script type: $type")
|
||||
}
|
||||
|
||||
open fun activeAddresses(xpub: String, start: Int, limit: Int): Flux<Address> {
|
||||
|
||||
@@ -34,7 +34,7 @@ import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.kotlin.extra.retry.retryRandomBackoff
|
||||
import reactor.util.retry.Retry
|
||||
import java.math.BigInteger
|
||||
import java.time.Duration
|
||||
import java.util.concurrent.TimeoutException
|
||||
@@ -75,12 +75,17 @@ abstract class AbstractCallLimitValidator(
|
||||
Mono.fromCallable { log.error("No response for eth_call limit check from ${upstream.getId()}") }
|
||||
.then(Mono.error(TimeoutException("Validation timeout for call limit"))),
|
||||
)
|
||||
.retryRandomBackoff(3, Duration.ofMillis(100), Duration.ofMillis(500)) { ctx ->
|
||||
log.warn(
|
||||
"error during validateCallLimit for ${upstream.getId()}, iteration ${ctx.iteration()}, " +
|
||||
"message ${ctx.exception().message}",
|
||||
)
|
||||
}
|
||||
.retryWhen(
|
||||
Retry.backoff(3, Duration.ofMillis(100))
|
||||
.maxBackoff(Duration.ofMillis(500))
|
||||
.jitter(1.0)
|
||||
.doBeforeRetry { signal ->
|
||||
log.warn(
|
||||
"error during validateCallLimit for ${upstream.getId()}, iteration ${signal.totalRetries() + 1}, " +
|
||||
"message ${signal.failure().message}",
|
||||
)
|
||||
},
|
||||
)
|
||||
.onErrorReturn(ValidateUpstreamSettingsResult.UPSTREAM_SETTINGS_ERROR)
|
||||
}
|
||||
|
||||
@@ -164,14 +169,19 @@ class ChainIdValidator(
|
||||
private fun chainId(): Mono<String> {
|
||||
return validatorReader.get()
|
||||
.read(ChainRequest("eth_chainId", ListParams()))
|
||||
.retryRandomBackoff(3, Duration.ofMillis(100), Duration.ofMillis(500)) { ctx ->
|
||||
log.warn(
|
||||
"error during chainId retrieving for {}, iteration {}, reason - {}",
|
||||
upstream.getId(),
|
||||
ctx.iteration(),
|
||||
ctx.exception().message,
|
||||
)
|
||||
}
|
||||
.retryWhen(
|
||||
Retry.backoff(3, Duration.ofMillis(100))
|
||||
.maxBackoff(Duration.ofMillis(500))
|
||||
.jitter(1.0)
|
||||
.doBeforeRetry { signal ->
|
||||
log.warn(
|
||||
"error during chainId retrieving for {}, iteration {}, reason - {}",
|
||||
upstream.getId(),
|
||||
signal.totalRetries() + 1,
|
||||
signal.failure().message,
|
||||
)
|
||||
},
|
||||
)
|
||||
.doOnError { log.error("Error during execution 'eth_chainId' - {} for {}", it.message, upstream.getId()) }
|
||||
.flatMap(ChainResponse::requireStringResult)
|
||||
}
|
||||
@@ -179,14 +189,19 @@ class ChainIdValidator(
|
||||
private fun netVersion(): Mono<String> {
|
||||
return validatorReader.get()
|
||||
.read(ChainRequest("net_version", ListParams()))
|
||||
.retryRandomBackoff(3, Duration.ofMillis(100), Duration.ofMillis(500)) { ctx ->
|
||||
log.warn(
|
||||
"error during netVersion retrieving for {}, iteration {}, reason - {}",
|
||||
upstream.getId(),
|
||||
ctx.iteration(),
|
||||
ctx.exception().message,
|
||||
)
|
||||
}
|
||||
.retryWhen(
|
||||
Retry.backoff(3, Duration.ofMillis(100))
|
||||
.maxBackoff(Duration.ofMillis(500))
|
||||
.jitter(1.0)
|
||||
.doBeforeRetry { signal ->
|
||||
log.warn(
|
||||
"error during netVersion retrieving for {}, iteration {}, reason - {}",
|
||||
upstream.getId(),
|
||||
signal.totalRetries() + 1,
|
||||
signal.failure().message,
|
||||
)
|
||||
},
|
||||
)
|
||||
.doOnError { log.error("Error during execution 'net_version' - {} for {}", it.message, upstream.getId()) }
|
||||
.flatMap(ChainResponse::requireStringResult)
|
||||
}
|
||||
@@ -264,14 +279,19 @@ class ErigonBuggedValidator(
|
||||
private fun isErigon(): Mono<Boolean> =
|
||||
upstream.getIngressReader()
|
||||
.read(ChainRequest("web3_clientVersion", ListParams()))
|
||||
.retryRandomBackoff(3, Duration.ofMillis(100), Duration.ofMillis(500)) { ctx ->
|
||||
log.warn(
|
||||
"error during clientVersion retrieving for {}, iteration {}, reason - {}",
|
||||
upstream.getId(),
|
||||
ctx.iteration(),
|
||||
ctx.exception().message,
|
||||
)
|
||||
}
|
||||
.retryWhen(
|
||||
Retry.backoff(3, Duration.ofMillis(100))
|
||||
.maxBackoff(Duration.ofMillis(500))
|
||||
.jitter(1.0)
|
||||
.doBeforeRetry { signal ->
|
||||
log.warn(
|
||||
"error during clientVersion retrieving for {}, iteration {}, reason - {}",
|
||||
upstream.getId(),
|
||||
signal.totalRetries() + 1,
|
||||
signal.failure().message,
|
||||
)
|
||||
},
|
||||
)
|
||||
.flatMap(ChainResponse::requireStringResult)
|
||||
.map { it.lowercase().contains("erigon") }
|
||||
.doOnError { log.error("Error during execution 'web3_clientVersion' - {} for {}", it.message, upstream.getId()) }
|
||||
|
||||
@@ -26,7 +26,7 @@ import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.kotlin.extra.retry.retryRandomBackoff
|
||||
import reactor.util.retry.Retry
|
||||
import java.time.Duration
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
@@ -84,12 +84,17 @@ class LogIndexValidator(
|
||||
}
|
||||
}
|
||||
.timeout(Duration.ofSeconds(15))
|
||||
.retryRandomBackoff(2, Duration.ofMillis(200), Duration.ofMillis(1000)) { ctx ->
|
||||
log.debug(
|
||||
"Retry logIndex validation for ${upstream.getId()}, iteration ${ctx.iteration()}, " +
|
||||
"error: ${ctx.exception().message}",
|
||||
)
|
||||
}
|
||||
.retryWhen(
|
||||
Retry.backoff(2, Duration.ofMillis(200))
|
||||
.maxBackoff(Duration.ofMillis(1000))
|
||||
.jitter(1.0)
|
||||
.doBeforeRetry { signal ->
|
||||
log.debug(
|
||||
"Retry logIndex validation for ${upstream.getId()}, iteration ${signal.totalRetries() + 1}, " +
|
||||
"error: ${signal.failure().message}",
|
||||
)
|
||||
},
|
||||
)
|
||||
.onErrorResume { err ->
|
||||
log.warn("Error during logIndex validation for ${upstream.getId()}: ${err.message}")
|
||||
// In case of error, return last known state to avoid false positives
|
||||
|
||||
@@ -35,7 +35,7 @@ import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.core.publisher.Sinks
|
||||
import reactor.core.scheduler.Scheduler
|
||||
import reactor.kotlin.extra.retry.retryExponentialBackoff
|
||||
import reactor.util.retry.Retry
|
||||
import java.time.Duration
|
||||
import java.util.function.Function
|
||||
|
||||
@@ -108,14 +108,14 @@ class GrpcHead(
|
||||
|
||||
blocks = blocks.doOnNext {
|
||||
log.trace("Received block ${it.height}")
|
||||
}.retryExponentialBackoff(
|
||||
Long.MAX_VALUE,
|
||||
Duration.ofMillis(100),
|
||||
Duration.ofSeconds(60),
|
||||
true,
|
||||
) {
|
||||
log.debug("Retry grpc head connection ${parent.getId()}")
|
||||
}
|
||||
}.retryWhen(
|
||||
Retry.backoff(Long.MAX_VALUE, Duration.ofMillis(100))
|
||||
.maxBackoff(Duration.ofSeconds(60))
|
||||
.jitter(0.5)
|
||||
.doBeforeRetry {
|
||||
log.debug("Retry grpc head connection ${parent.getId()}")
|
||||
},
|
||||
)
|
||||
|
||||
headSubscription = super.follow(blocks)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.emeraldpay.dshackle.upstream.bitcoin
|
||||
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.data.EsploraUnspent
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.base.AddressParser
|
||||
|
||||
/**
|
||||
* Copyright (c) 2020 EmeraldPay, Inc
|
||||
@@ -19,8 +19,6 @@ import org.bitcoinj.core.Address
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.bitcoinj.params.MainNetParams
|
||||
import org.bitcoinj.params.TestNet3Params
|
||||
import org.mockserver.integration.ClientAndServer
|
||||
import org.mockserver.model.HttpRequest
|
||||
import org.mockserver.model.HttpResponse
|
||||
@@ -53,7 +51,7 @@ class EsploraClientSpec extends Specification {
|
||||
)
|
||||
def client = new EsploraClient(new URI("http://localhost:${mockServer.port}"), null, null)
|
||||
when:
|
||||
def act = client.getUtxo(Address.fromString(new MainNetParams(), "35vktkPo4wdK8Twu4VMiuPLdCx23XEykGY"))
|
||||
def act = client.getUtxo(AddressParser.getDefault().parseAddress("35vktkPo4wdK8Twu4VMiuPLdCx23XEykGY"))
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
@@ -74,7 +72,7 @@ class EsploraClientSpec extends Specification {
|
||||
.verify(Duration.ofSeconds(3))
|
||||
|
||||
when:
|
||||
def actTotal = client.getUtxo(Address.fromString(new MainNetParams(), "35vktkPo4wdK8Twu4VMiuPLdCx23XEykGY"))
|
||||
def actTotal = client.getUtxo(AddressParser.getDefault().parseAddress("35vktkPo4wdK8Twu4VMiuPLdCx23XEykGY"))
|
||||
.block()
|
||||
.sum { it.value }
|
||||
|
||||
@@ -94,7 +92,7 @@ class EsploraClientSpec extends Specification {
|
||||
)
|
||||
def client = new EsploraClient(new URI("http://localhost:${mockServer.port}"), null, null)
|
||||
when:
|
||||
def act = client.getTransactions(Address.fromString(TestNet3Params.get(), "tb1qyatuwvkfx8thy2ntmtuea6v42vp3zefqvll8kx"))
|
||||
def act = client.getTransactions(AddressParser.getDefault().parseAddress("tb1qyatuwvkfx8thy2ntmtuea6v42vp3zefqvll8kx"))
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
@@ -124,7 +122,7 @@ class EsploraClientSpec extends Specification {
|
||||
)
|
||||
def client = new EsploraClient(new URI("http://localhost:${mockServer.port}"), null, null)
|
||||
when:
|
||||
def act = client.getTransactions(Address.fromString(TestNet3Params.get(), "tb1qyatuwvkfx8thy2ntmtuea6v42vp3zefqvll8kx"))
|
||||
def act = client.getTransactions(AddressParser.getDefault().parseAddress("tb1qyatuwvkfx8thy2ntmtuea6v42vp3zefqvll8kx"))
|
||||
|
||||
then:
|
||||
StepVerifier.create(act)
|
||||
|
||||
@@ -19,8 +19,7 @@ import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.upstream.ChainRequest
|
||||
import io.emeraldpay.dshackle.upstream.ChainResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.params.MainNetParams
|
||||
import org.bitcoinj.base.AddressParser
|
||||
import reactor.core.publisher.Mono
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -38,7 +37,7 @@ class RpcUnspentReaderSpec extends Specification {
|
||||
def reader = new RpcUnspentReader(upstreams)
|
||||
|
||||
when:
|
||||
def act = reader.read(Address.fromString(new MainNetParams(), "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK")).block()
|
||||
def act = reader.read(AddressParser.getDefault().parseAddress("1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK")).block()
|
||||
|
||||
then:
|
||||
// cat src/test/resources/bitcoin/unspent-one-addr.json | jq '. | length'
|
||||
@@ -72,7 +71,7 @@ class RpcUnspentReaderSpec extends Specification {
|
||||
def reader = new RpcUnspentReader(upstreams)
|
||||
|
||||
when:
|
||||
def act = reader.read(Address.fromString(new MainNetParams(), "35hK24tcLEWcgNA4JxpvbkNkoAcDGqQPsP")).block()
|
||||
def act = reader.read(AddressParser.getDefault().parseAddress("35hK24tcLEWcgNA4JxpvbkNkoAcDGqQPsP")).block()
|
||||
|
||||
then:
|
||||
// cat src/test/resources/bitcoin/unspent-two-addr.json | jq '[.[] | select(.address == "35hK24tcLEWcgNA4JxpvbkNkoAcDGqQPsP")] | length'
|
||||
@@ -107,7 +106,7 @@ class RpcUnspentReaderSpec extends Specification {
|
||||
def reader = new RpcUnspentReader(upstreams)
|
||||
|
||||
when:
|
||||
def act = reader.read(Address.fromString(new MainNetParams(), "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK")).block()
|
||||
def act = reader.read(AddressParser.getDefault().parseAddress("1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK")).block()
|
||||
|
||||
then:
|
||||
// cat src/test/resources/bitcoin/unspent-two-addr.json | jq '[.[] | select(.address == "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK")] | length'
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.bitcoin
|
||||
|
||||
import org.bitcoinj.core.Address
|
||||
import org.bitcoinj.params.MainNetParams
|
||||
import org.bitcoinj.base.AddressParser
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.test.StepVerifier
|
||||
import spock.lang.Specification
|
||||
@@ -119,7 +118,7 @@ class XpubAddressesSpec extends Specification {
|
||||
def "list when only fist is active"() {
|
||||
setup:
|
||||
AddressActiveCheck check = Mock(AddressActiveCheck) {
|
||||
1 * isActive(Address.fromString(MainNetParams.get(), "bc1qaexx257l7sgm62szw2ulj6n2v99t5ph9ekkul3")) >> Mono.just(true)
|
||||
1 * isActive(AddressParser.getDefault().parseAddress("bc1qaexx257l7sgm62szw2ulj6n2v99t5ph9ekkul3")) >> Mono.just(true)
|
||||
20 * isActive(_) >> Mono.just(false)
|
||||
}
|
||||
XpubAddresses addresses = new XpubAddresses(check)
|
||||
@@ -143,7 +142,7 @@ class XpubAddressesSpec extends Specification {
|
||||
def "list when only 3rd is active"() {
|
||||
setup:
|
||||
AddressActiveCheck check = Mock(AddressActiveCheck) {
|
||||
1 * isActive(Address.fromString(MainNetParams.get(), "bc1qah84zz7aavf3f5eyx5f29809y6xugqyphq0wtz")) >> Mono.just(true)
|
||||
1 * isActive(AddressParser.getDefault().parseAddress("bc1qah84zz7aavf3f5eyx5f29809y6xugqyphq0wtz")) >> Mono.just(true)
|
||||
// 2 times before, 20 times after
|
||||
22 * isActive(_) >> Mono.just(false)
|
||||
}
|
||||
@@ -169,11 +168,11 @@ class XpubAddressesSpec extends Specification {
|
||||
setup:
|
||||
AddressActiveCheck check = Mock(AddressActiveCheck) {
|
||||
// 2
|
||||
1 * isActive(Address.fromString(MainNetParams.get(), "bc1qah84zz7aavf3f5eyx5f29809y6xugqyphq0wtz")) >> Mono.just(true)
|
||||
1 * isActive(AddressParser.getDefault().parseAddress("bc1qah84zz7aavf3f5eyx5f29809y6xugqyphq0wtz")) >> Mono.just(true)
|
||||
// 11
|
||||
1 * isActive(Address.fromString(MainNetParams.get(), "bc1q3kqug4cx95a02yhwn6geelftmw3zklrgmhjll8")) >> Mono.just(true)
|
||||
1 * isActive(AddressParser.getDefault().parseAddress("bc1q3kqug4cx95a02yhwn6geelftmw3zklrgmhjll8")) >> Mono.just(true)
|
||||
// 22
|
||||
1 * isActive(Address.fromString(MainNetParams.get(), "bc1qf7m2rrmrksj34vhgxmm04y43dlj7c5f58f8ku6")) >> Mono.just(true)
|
||||
1 * isActive(AddressParser.getDefault().parseAddress("bc1qf7m2rrmrksj34vhgxmm04y43dlj7c5f58f8ku6")) >> Mono.just(true)
|
||||
// 0..1 = 2
|
||||
// + 3..10 = 8
|
||||
// + 12..21 = 10
|
||||
|
||||
Reference in New Issue
Block a user