Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deposit improvements #4347

Merged
merged 11 commits into from Jul 3, 2020
Expand Up @@ -15,11 +15,14 @@
import bisq.core.payment.RevolutAccount;
import bisq.core.provider.fee.FeeService;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.trade.statistics.TradeStatisticsManager;
import bisq.core.user.Preferences;
import bisq.core.user.User;

import org.bitcoinj.core.Coin;

import javafx.collections.FXCollections;

import java.util.HashSet;
import java.util.UUID;

Expand Down Expand Up @@ -52,17 +55,19 @@ public void setUp() {
CreateOfferService createOfferService = mock(CreateOfferService.class);
preferences = mock(Preferences.class);
user = mock(User.class);
var tradeStats = mock(TradeStatisticsManager.class);

when(btcWalletService.getOrCreateAddressEntry(anyString(), any())).thenReturn(addressEntry);
when(preferences.isUsePercentageBasedPrice()).thenReturn(true);
when(preferences.getBuyerSecurityDepositAsPercent(null)).thenReturn(0.01);
when(createOfferService.getRandomOfferId()).thenReturn(UUID.randomUUID().toString());
when(tradeStats.getObservableTradeStatisticsSet()).thenReturn(FXCollections.observableSet());

makerFeeProvider = mock(MakerFeeProvider.class);
model = new CreateOfferDataModel(createOfferService, null, btcWalletService,
null, preferences, user, null,
priceFeedService, null,
feeService, null, makerFeeProvider, null);
feeService, null, makerFeeProvider, tradeStats, null);
}

@Test
Expand Down
Expand Up @@ -34,14 +34,16 @@
import bisq.core.offer.CreateOfferService;
import bisq.core.offer.OfferPayload;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.provider.fee.FeeService;
import bisq.core.provider.price.MarketPrice;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.trade.statistics.TradeStatisticsManager;
import bisq.core.user.Preferences;
import bisq.core.user.User;
import bisq.core.util.coin.ImmutableCoinFormatter;
import bisq.core.util.coin.BsqFormatter;
import bisq.core.util.coin.CoinFormatter;
import bisq.core.util.coin.ImmutableCoinFormatter;
import bisq.core.util.validation.InputValidator;

import bisq.common.config.Config;
Expand Down Expand Up @@ -95,25 +97,28 @@ public void setUp() {
SecurityDepositValidator securityDepositValidator = mock(SecurityDepositValidator.class);
AccountAgeWitnessService accountAgeWitnessService = mock(AccountAgeWitnessService.class);
CreateOfferService createOfferService = mock(CreateOfferService.class);
var tradeStats = mock(TradeStatisticsManager.class);

when(btcWalletService.getOrCreateAddressEntry(anyString(), any())).thenReturn(addressEntry);
when(btcWalletService.getBalanceForAddress(any())).thenReturn(Coin.valueOf(1000L));
when(priceFeedService.updateCounterProperty()).thenReturn(new SimpleIntegerProperty());
when(priceFeedService.getMarketPrice(anyString())).thenReturn(new MarketPrice("USD", 12684.0450, Instant.now().getEpochSecond(), true));
when(feeService.getTxFee(anyInt())).thenReturn(Coin.valueOf(1000L));
when(user.findFirstPaymentAccountWithCurrency(any())).thenReturn(paymentAccount);
when(paymentAccount.getPaymentMethod()).thenReturn(mock(PaymentMethod.class));
when(user.getPaymentAccountsAsObservable()).thenReturn(FXCollections.observableSet());
when(securityDepositValidator.validate(any())).thenReturn(new InputValidator.ValidationResult(false));
when(accountAgeWitnessService.getMyTradeLimit(any(), any(), any())).thenReturn(100000000L);
when(preferences.getUserCountry()).thenReturn(new Country("ES", "Spain", null));
when(bsqFormatter.formatCoin(any())).thenReturn("0");
when(bsqWalletService.getAvailableConfirmedBalance()).thenReturn(Coin.ZERO);
when(createOfferService.getRandomOfferId()).thenReturn(UUID.randomUUID().toString());
when(tradeStats.getObservableTradeStatisticsSet()).thenReturn(FXCollections.observableSet());

CreateOfferDataModel dataModel = new CreateOfferDataModel(createOfferService, null, btcWalletService,
bsqWalletService, empty, user, null, priceFeedService,
accountAgeWitnessService, feeService,
coinFormatter, mock(MakerFeeProvider.class), null);
coinFormatter, mock(MakerFeeProvider.class), tradeStats, null);
dataModel.initWithData(OfferPayload.Direction.BUY, new CryptoCurrency("BTC", "bitcoin"));
dataModel.activate();

Expand Down
Expand Up @@ -19,6 +19,7 @@
import bisq.core.provider.fee.FeeService;
import bisq.core.provider.price.MarketPrice;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.trade.statistics.TradeStatisticsManager;
import bisq.core.user.Preferences;
import bisq.core.user.User;
import bisq.core.util.coin.BsqFormatter;
Expand Down Expand Up @@ -95,7 +96,7 @@ public void setUp() {
btcWalletService, bsqWalletService, empty, user,
null, priceFeedService,
accountAgeWitnessService, feeService, null, null,
mock(MakerFeeProvider.class), null);
mock(MakerFeeProvider.class), mock(TradeStatisticsManager.class), null);
}

@Test
Expand Down