solution: delegate bitcoin balance request to another upstream, if data is unavailable locally
This commit is contained in:
@@ -92,6 +92,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
with(act.upstreams.get(0)) {
|
||||
id == "local"
|
||||
chain == "bitcoin"
|
||||
options == null || options.providesBalance == false
|
||||
connection instanceof UpstreamsConfig.BitcoinConnection
|
||||
with((UpstreamsConfig.BitcoinConnection) connection) {
|
||||
rpc != null
|
||||
@@ -119,6 +120,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
with(act.upstreams.get(0)) {
|
||||
id == "local"
|
||||
chain == "bitcoin"
|
||||
options.providesBalance == true
|
||||
connection instanceof UpstreamsConfig.BitcoinConnection
|
||||
with((UpstreamsConfig.BitcoinConnection) connection) {
|
||||
rpc != null
|
||||
|
||||
@@ -259,6 +259,7 @@ class TrackBitcoinAddressSpec extends Specification {
|
||||
}
|
||||
MultistreamHolder upstreams = new MultistreamHolderMock(Chain.BITCOIN, upstream)
|
||||
TrackBitcoinAddress track = new TrackBitcoinAddress(upstreams)
|
||||
track.setBalanceAvailability(Chain.BITCOIN, true)
|
||||
|
||||
when:
|
||||
def resp = track.subscribe(BlockchainOuterClass.BalanceRequest.newBuilder()
|
||||
@@ -285,6 +286,5 @@ class TrackBitcoinAddressSpec extends Specification {
|
||||
}
|
||||
.expectComplete()
|
||||
.verify(Duration.ofSeconds(1))
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package io.emeraldpay.dshackle.upstream.grpc
|
||||
|
||||
import io.emeraldpay.api.proto.BlockchainOuterClass
|
||||
import io.emeraldpay.dshackle.upstream.Capability
|
||||
import spock.lang.Specification
|
||||
|
||||
class RemoteCapabilitiesSpec extends Specification {
|
||||
|
||||
def "parse from remote - all"() {
|
||||
setup:
|
||||
def remote = BlockchainOuterClass.DescribeChain.newBuilder()
|
||||
.addCapabilities(BlockchainOuterClass.Capabilities.CAP_CALLS)
|
||||
.addCapabilities(BlockchainOuterClass.Capabilities.CAP_NONE)
|
||||
.addCapabilities(BlockchainOuterClass.Capabilities.CAP_BALANCE)
|
||||
.build()
|
||||
when:
|
||||
def act = RemoteCapabilities.extract(remote)
|
||||
then:
|
||||
act == [Capability.BALANCE, Capability.RPC].toSet()
|
||||
}
|
||||
|
||||
def "parse from remote - only call"() {
|
||||
setup:
|
||||
def remote = BlockchainOuterClass.DescribeChain.newBuilder()
|
||||
.addCapabilities(BlockchainOuterClass.Capabilities.CAP_CALLS)
|
||||
.build()
|
||||
when:
|
||||
def act = RemoteCapabilities.extract(remote)
|
||||
then:
|
||||
act == [Capability.RPC].toSet()
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ defaults:
|
||||
upstreams:
|
||||
- id: local
|
||||
chain: bitcoin
|
||||
options:
|
||||
balance: true
|
||||
connection:
|
||||
bitcoin:
|
||||
rpc:
|
||||
|
||||
Reference in New Issue
Block a user