Search in sources :

Example 1 with UTXOProvider

use of co.rsk.bitcoinj.core.UTXOProvider in project rskj by rsksmart.

the class BridgeUtilsTest method test_getSpendWallet.

private void test_getSpendWallet(boolean isFastBridgeCompatible) throws UTXOProviderException {
    Federation federation = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList(BtcECKey.fromPublicOnly(Hex.decode("036bb9eab797eadc8b697f0e82a01d01cabbfaaca37e5bafc06fdc6fdd38af894a")), BtcECKey.fromPublicOnly(Hex.decode("031da807c71c2f303b7f409dd2605b297ac494a563be3b9ca5f52d95a43d183cc5")))), Instant.ofEpochMilli(5005L), 0L, networkParameters);
    Context mockedBtcContext = mock(Context.class);
    when(mockedBtcContext.getParams()).thenReturn(networkParameters);
    List<UTXO> mockedUtxos = new ArrayList<>();
    mockedUtxos.add(mock(UTXO.class));
    mockedUtxos.add(mock(UTXO.class));
    mockedUtxos.add(mock(UTXO.class));
    Wallet wallet = BridgeUtils.getFederationSpendWallet(mockedBtcContext, federation, mockedUtxos, isFastBridgeCompatible, null);
    if (isFastBridgeCompatible) {
        Assert.assertEquals(FastBridgeCompatibleBtcWalletWithStorage.class, wallet.getClass());
    } else {
        Assert.assertEquals(BridgeBtcWallet.class, wallet.getClass());
    }
    assertIsWatching(federation.getAddress(), wallet, networkParameters);
    CoinSelector selector = wallet.getCoinSelector();
    Assert.assertEquals(RskAllowUnconfirmedCoinSelector.class, selector.getClass());
    UTXOProvider utxoProvider = wallet.getUTXOProvider();
    Assert.assertEquals(RskUTXOProvider.class, utxoProvider.getClass());
    Assert.assertEquals(mockedUtxos, utxoProvider.getOpenTransactionOutputs(Collections.emptyList()));
}
Also used : Context(co.rsk.bitcoinj.core.Context) UTXO(co.rsk.bitcoinj.core.UTXO) UTXOProvider(co.rsk.bitcoinj.core.UTXOProvider) Wallet(co.rsk.bitcoinj.wallet.Wallet) ArrayList(java.util.ArrayList) CoinSelector(co.rsk.bitcoinj.wallet.CoinSelector) RskAllowUnconfirmedCoinSelector(co.rsk.peg.bitcoin.RskAllowUnconfirmedCoinSelector)

Aggregations

Context (co.rsk.bitcoinj.core.Context)1 UTXO (co.rsk.bitcoinj.core.UTXO)1 UTXOProvider (co.rsk.bitcoinj.core.UTXOProvider)1 CoinSelector (co.rsk.bitcoinj.wallet.CoinSelector)1 Wallet (co.rsk.bitcoinj.wallet.Wallet)1 RskAllowUnconfirmedCoinSelector (co.rsk.peg.bitcoin.RskAllowUnconfirmedCoinSelector)1 ArrayList (java.util.ArrayList)1