Skip to content

Commit

Permalink
OmniCoreClientRegTestSpec: add (ignored) tests for OmniProxy mode
Browse files Browse the repository at this point in the history
(needs conditional tests, etc.)
  • Loading branch information
msgilligan committed Nov 18, 2021
1 parent 20ff92c commit 3766430
Showing 1 changed file with 41 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import foundation.omni.net.OmniRegTestParams
import foundation.omni.netapi.OmniJBalances
import foundation.omni.netapi.WalletAddressBalance
import org.bitcoinj.core.Address
import org.bitcoinj.core.LegacyAddress
import org.bitcoinj.params.RegTestParams
import org.consensusj.bitcoin.rpc.RpcURI
import spock.lang.Ignore
import spock.lang.Shared
import spock.lang.Specification

import java.util.stream.Collectors

/**
*
*/
Expand All @@ -30,6 +33,7 @@ class OmniCoreClientRegTestSpec extends Specification {
wab != null
}

@Ignore
def "can get mocked up combined btc/omni balances for regTestMiningAddress"() {
given:
Address address = client.getRxOmniClient().getRegTestMiningAddress()
Expand All @@ -41,6 +45,7 @@ class OmniCoreClientRegTestSpec extends Specification {
wab != null
}

@Ignore
def "can get balances for a list of addresses"() {
given:
List<Address> addresses = client.getWalletAddresses()
Expand All @@ -50,22 +55,46 @@ class OmniCoreClientRegTestSpec extends Specification {

then:
balances != null
}

@Ignore
def "can use OmniProxy to get mocked up combined btc/omni balances for regTestMiningAddress"() {
given:
Address address = client.getRxOmniClient().getRegTestMiningAddress()

when:
WalletAddressBalance wab = client.getRxOmniClient().omniProxyGetBalance(address);

then:
wab != null
}

@Ignore
def "can use OmniProxy to get mocked up combined btc/omni balances for multiple addresses"() {
given:
def addresses = ['miwk3gsiqDuGZdCzm6W5mibc3SSkAz6QbB', 'mzG1g5CUCfS6hPoH63Gt7y98RWDnHqTYTe'].stream()
.map(str -> LegacyAddress.fromBase58(null, str))
.collect(Collectors.toList())

when:
OmniJBalances ojb = client.getRxOmniClient().omniProxyGetBalances(addresses);

cleanup:
balances.forEach((address, wab) -> {
def btc = wab.get(CurrencyID.BTC)
if (btc != null && (btc.balance.willetts > 0 || btc.reserved.willetts > 0)) {
wab.forEach((id, entry) -> {
println("$id: $entry")
})
}
})
then:
ojb != null
}

def setup() {
boolean testOmniProxy = false
if (testOmniProxy) {
client = new OmniCoreClient(RegTestParams.get(),
RpcURI.getDefaultRegTestURI(),
"bitcoinrpc",
"pass")
URI.create("http://localhost:8080"),
"",
"")
} else {
client = new OmniCoreClient(RegTestParams.get(),
RpcURI.getDefaultRegTestURI(),
"bitcoinrpc",
"pass")
}
}
}

0 comments on commit 3766430

Please sign in to comment.