problem: returns nothing instead of 0 if no unspents

This commit is contained in:
Igor Artamonov
2020-09-26 20:25:50 -04:00
parent d52b8f3381
commit 5dfef09de6
2 changed files with 37 additions and 0 deletions

View File

@@ -83,6 +83,40 @@ class TrackBitcoinAddressSpec extends Specification {
total.utxo.isEmpty()
}
def "Correct sum for none"() {
setup:
def unspents = []
TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder))
def address = new TrackBitcoinAddress.Address(
Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
)
when:
def total = track.totalUnspent(address, false, unspents)
then:
total.balance == 0
total.utxo.isEmpty()
}
def "Correct sum for none read"() {
setup:
TrackBitcoinAddress track = new TrackBitcoinAddress(Stub(MultistreamHolder))
def address = new TrackBitcoinAddress.Address(
Chain.BITCOIN, "1K7xkspJg7DDKNwzXgoRSDCUxiFsRegsSK"
)
def api = Mock(BitcoinMultistream) {
1 * getReader() >> Mock(BitcoinReader) {
1 * listUnspent(_) >> Mono.empty()
}
}
when:
def total = track.balanceForAddress(api, address, false).block()
then:
total.balance == 0
total.utxo.isEmpty()
}
def "Correct sum for few with utxo"() {
setup:
def unspents = [