Java Code Examples for org.bitcoinj.core.Coin#parseCoin()

The following examples show how to use org.bitcoinj.core.Coin#parseCoin() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BtcFormatTest.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void columnAlignmentTest() {
    BtcFormat germany = BtcFormat.getCoinInstance(2, BtcFixedFormat.REPEATING_PLACES);
    char separator = germany.symbols().getDecimalSeparator();
    Coin[] rows = {MAX_MONEY, MAX_MONEY.subtract(SATOSHI), Coin.parseCoin("1234"),
            COIN, COIN.add(SATOSHI), COIN.subtract(SATOSHI),
            COIN.divide(1000).add(SATOSHI), COIN.divide(1000), COIN.divide(1000).subtract(SATOSHI),
            valueOf(100), valueOf(1000), valueOf(10000),
            SATOSHI};
    FieldPosition fp = new FieldPosition(DECIMAL_SEPARATOR);
    String[] output = new String[rows.length];
    int[] indexes = new int[rows.length];
    int maxIndex = 0;
    for (int i = 0; i < rows.length; i++) {
        output[i] = germany.format(rows[i], new StringBuffer(), fp).toString();
        indexes[i] = fp.getBeginIndex();
        if (indexes[i] > maxIndex)
            maxIndex = indexes[i];
    }
    for (int i = 0; i < output.length; i++) {
        // uncomment to watch printout
        // System.out.println(repeat(" ", (maxIndex - indexes[i])) + output[i]);
        assertEquals(output[i].indexOf(separator), indexes[i]);
    }
}
 
Example 2
Source File: BlockrIOProvider.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Coin getFee(String transactionId) throws IOException {
    Log.traceCall("transactionId=" + transactionId);
    try {
        JsonObject data = new JsonParser()
                .parse(httpClient.requestWithGET(transactionId, "User-Agent", ""))
                .getAsJsonObject()
                .get("data")
                .getAsJsonObject();
        return Coin.parseCoin(data
                .get("fee")
                .getAsString());
    } catch (IOException e) {
        log.debug("Error at requesting transaction data from block explorer " + httpClient + "\n" +
                "Error =" + e.getMessage());
        throw e;
    }
}
 
Example 3
Source File: BtcFormatTest.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void columnAlignmentTest() {
    BtcFormat germany = BtcFormat.getCoinInstance(2,BtcFixedFormat.REPEATING_PLACES);
    char separator = germany.symbols().getDecimalSeparator();
    Coin[] rows = {MAX_MONEY, MAX_MONEY.subtract(SATOSHI), Coin.parseCoin("1234"),
                   COIN, COIN.add(SATOSHI), COIN.subtract(SATOSHI),
                    COIN.divide(1000).add(SATOSHI), COIN.divide(1000), COIN.divide(1000).subtract(SATOSHI),
                   valueOf(100), valueOf(1000), valueOf(10000),
                   SATOSHI};
    FieldPosition fp = new FieldPosition(DECIMAL_SEPARATOR);
    String[] output = new String[rows.length];
    int[] indexes = new int[rows.length];
    int maxIndex = 0;
    for (int i = 0; i < rows.length; i++) {
        output[i] = germany.format(rows[i], new StringBuffer(), fp).toString();
        indexes[i] = fp.getBeginIndex();
        if (indexes[i] > maxIndex) maxIndex = indexes[i];
    }
    for (int i = 0; i < output.length; i++) {
        // uncomment to watch printout
        // System.out.println(repeat(" ", (maxIndex - indexes[i])) + output[i]);
        assertEquals(output[i].indexOf(separator), indexes[i]);
    }
}
 
Example 4
Source File: BtcFormatTest.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void columnAlignmentTest() {
    BtcFormat germany = BtcFormat.getCoinInstance(2,BtcFixedFormat.REPEATING_PLACES);
    char separator = germany.symbols().getDecimalSeparator();
    Coin[] rows = {MAX_MONEY, MAX_MONEY.subtract(SATOSHI), Coin.parseCoin("1234"),
                   COIN, COIN.add(SATOSHI), COIN.subtract(SATOSHI),
                    COIN.divide(1000).add(SATOSHI), COIN.divide(1000), COIN.divide(1000).subtract(SATOSHI),
                   valueOf(100), valueOf(1000), valueOf(10000),
                   SATOSHI};
    FieldPosition fp = new FieldPosition(DECIMAL_SEPARATOR);
    String[] output = new String[rows.length];
    int[] indexes = new int[rows.length];
    int maxIndex = 0;
    for (int i = 0; i < rows.length; i++) {
        output[i] = germany.format(rows[i], new StringBuffer(), fp).toString();
        indexes[i] = fp.getBeginIndex();
        if (indexes[i] > maxIndex) maxIndex = indexes[i];
    }
    for (int i = 0; i < output.length; i++) {
        // uncomment to watch printout
        // System.out.println(repeat(" ", (maxIndex - indexes[i])) + output[i]);
        assertEquals(output[i].indexOf(separator), indexes[i]);
    }
}
 
Example 5
Source File: TradesChartsViewModelTest.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@Test
public void testGetCandleData() {
    model.selectedTradeCurrencyProperty.setValue(new FiatCurrency("EUR"));

    long low = Fiat.parseFiat("EUR", "500").value;
    long open = Fiat.parseFiat("EUR", "520").value;
    long close = Fiat.parseFiat("EUR", "580").value;
    long high = Fiat.parseFiat("EUR", "600").value;
    long average = Fiat.parseFiat("EUR", "550").value;
    long median = Fiat.parseFiat("EUR", "550").value;
    long amount = Coin.parseCoin("4").value;
    long volume = Fiat.parseFiat("EUR", "2200").value;
    boolean isBullish = true;

    Set<TradeStatistics2> set = new HashSet<>();
    final Date now = new Date();

    set.add(new TradeStatistics2(offer, Price.parse("EUR", "520"), Coin.parseCoin("1"), new Date(now.getTime()), null, null));
    set.add(new TradeStatistics2(offer, Price.parse("EUR", "500"), Coin.parseCoin("1"), new Date(now.getTime() + 100), null, null));
    set.add(new TradeStatistics2(offer, Price.parse("EUR", "600"), Coin.parseCoin("1"), new Date(now.getTime() + 200), null, null));
    set.add(new TradeStatistics2(offer, Price.parse("EUR", "580"), Coin.parseCoin("1"), new Date(now.getTime() + 300), null, null));

    CandleData candleData = model.getCandleData(model.roundToTick(now, TradesChartsViewModel.TickUnit.DAY).getTime(), set);
    assertEquals(open, candleData.open);
    assertEquals(close, candleData.close);
    assertEquals(high, candleData.high);
    assertEquals(low, candleData.low);
    assertEquals(average, candleData.average);
    assertEquals(median, candleData.median);
    assertEquals(amount, candleData.accumulatedAmount);
    assertEquals(volume, candleData.accumulatedVolume);
    assertEquals(isBullish, candleData.isBullish);
}
 
Example 6
Source File: BtcValidator.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
protected ValidationResult validateIfNotUnderMinValue(String input) {
    try {
        final Coin coin = Coin.parseCoin(input);
        if (minValue != null && coin.compareTo(minValue) < 0)
            return new ValidationResult(false, Res.get("validation.btc.toSmall", formatter.formatCoinWithCode(minValue)));
        else
            return new ValidationResult(true);
    } catch (Throwable t) {
        return new ValidationResult(false, Res.get("validation.invalidInput", t.getMessage()));
    }
}
 
Example 7
Source File: BtcValidator.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
protected ValidationResult validateIfNotExceedsMaxTradeLimit(String input) {
    try {
        final Coin coin = Coin.parseCoin(input);
        if (maxTradeLimit != null && coin.compareTo(maxTradeLimit) > 0)
            return new ValidationResult(false, Res.get("validation.btc.exceedsMaxTradeLimit", formatter.formatCoinWithCode(maxTradeLimit)));
        else
            return new ValidationResult(true);
    } catch (Throwable t) {
        return new ValidationResult(false, Res.get("validation.invalidInput", t.getMessage()));
    }
}
 
Example 8
Source File: BtcValidator.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
protected ValidationResult validateIfNotExceedsMaxBtcValue(String input) {
    try {
        final Coin coin = Coin.parseCoin(input);
        if (maxValue != null && coin.compareTo(maxValue) > 0)
            return new ValidationResult(false, Res.get("validation.btc.toLarge", formatter.formatCoinWithCode(maxValue)));
        else
            return new ValidationResult(true);
    } catch (Throwable t) {
        return new ValidationResult(false, Res.get("validation.invalidInput", t.getMessage()));
    }
}
 
Example 9
Source File: BtcValidator.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
protected ValidationResult validateIfAboveDust(String input) {
    try {
        final Coin coin = Coin.parseCoin(input);
        if (Restrictions.isAboveDust(coin))
            return new ValidationResult(true);
        else
            return new ValidationResult(false, Res.get("validation.amountBelowDust",
                    formatter.formatCoinWithCode(Restrictions.getMinNonDustOutput())));
    } catch (Throwable t) {
        return new ValidationResult(false, Res.get("validation.invalidInput", t.getMessage()));
    }
}
 
Example 10
Source File: ExchangeRateTest.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void bigRate() throws Exception {
    ExchangeRate rate = new ExchangeRate(Coin.parseCoin("0.0001"), Fiat.parseFiat("BYR", "5320387.3"));
    assertEquals("53203873000", rate.coinToFiat(Coin.COIN).toPlainString());
    assertEquals("0", rate.fiatToCoin(Fiat.parseFiat("BYR", "1")).toPlainString()); // Tiny value!
}
 
Example 11
Source File: Restrictions.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Coin getMinSellerSecurityDepositAsCoin() {
    if (SELLER_SECURITY_DEPOSIT == null)
        SELLER_SECURITY_DEPOSIT = Coin.parseCoin("0.006"); // 0.006 BTC about 42 USD @ 7000 USD/BTC
    return SELLER_SECURITY_DEPOSIT;
}
 
Example 12
Source File: GenesisTxParserTest.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Test
public void testIsGenesis() {
    // fixme(chirhonul): Assert.assertEquals(2, 3);

    int blockHeight = 200;
    String blockHash = "abc123";
    Coin genesisTotalSupply = Coin.parseCoin("2.5");
    long time = new Date().getTime();
    final List<TxInput> inputs = Arrays.asList(
            new TxInput("tx0", 0, null),
            new TxInput("tx1", 1, null)
    );
    RawTxOutput output = new RawTxOutput(
            0,
            genesisTotalSupply.value,
            null,
            null,
            null,
            null,
            blockHeight
    );
    RawTx rawTx = new RawTx(
            "tx2",
            blockHeight,
            blockHash,
            time,
            ImmutableList.copyOf(inputs),
            ImmutableList.copyOf(Arrays.asList(output))
    );

    String genesisTxId = "genesisTxId";
    int genesisBlockHeight = 150;

    // With mismatch in block height and tx id, we should not get genesis tx back.
    boolean result = GenesisTxParser.isGenesis(rawTx, genesisTxId, genesisBlockHeight);
    boolean want = false;
    Assert.assertEquals(want, result);

    // With correct block height but mismatch in tx id, we should still not get genesis tx back.
    blockHeight = 150;
    rawTx = new RawTx(
            "tx2",
            blockHeight,
            blockHash,
            time,
            ImmutableList.copyOf(inputs),
            ImmutableList.copyOf(Arrays.asList(output))
    );
    result = GenesisTxParser.isGenesis(rawTx, genesisTxId, genesisBlockHeight);
    want = false;
    Assert.assertEquals(want, result);

}
 
Example 13
Source File: ExchangeRateTest.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void smallRate() throws Exception {
    ExchangeRate rate = new ExchangeRate(Coin.parseCoin("1000"), Fiat.parseFiat("XXX", "0.0001"));
    assertEquals("0", rate.coinToFiat(Coin.COIN).toPlainString()); // Tiny value!
    assertEquals("10000000", rate.fiatToCoin(Fiat.parseFiat("XXX", "1")).toPlainString());
}
 
Example 14
Source File: ExchangeRateTest.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void bigRate() throws Exception {
    ExchangeRate rate = new ExchangeRate(Coin.parseCoin("0.0001"), Fiat.parseFiat("BYR", "5320387.3"));
    assertEquals("53203873000", rate.coinToFiat(Coin.COIN).toPlainString());
    assertEquals("0", rate.fiatToCoin(Fiat.parseFiat("BYR", "1")).toPlainString()); // Tiny value!
}
 
Example 15
Source File: DaoStateServiceTest.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Test
public void testIsBlockHashKnown() {
    DaoStateService stateService = new DaoStateService(
            new DaoState(),
            new GenesisTxInfo("fakegenesistxid", 100, Coin.parseCoin("2.5").value),
            new BsqFormatter());
    Assert.assertEquals(
            "Unknown block should not exist.",
            false,
            stateService.isBlockHashKnown("fakeblockhash0")
    );

    Block block = new Block(0, 1534800000, "fakeblockhash0", null);
    stateService.onNewBlockHeight(0);
    stateService.onNewBlockWithEmptyTxs(block);
    Assert.assertEquals(
            "Block has to be genesis block to get added.",
            false,
            stateService.isBlockHashKnown("fakeblockhash0")
    );

    Assert.assertEquals(
            "Block that was never added should still not exist.",
            false,
            stateService.isBlockHashKnown("fakeblockhash1")
    );

    block = new Block(1, 1534800001, "fakeblockhash1", null);
    stateService.onNewBlockHeight(1);
    stateService.onNewBlockWithEmptyTxs(block);
    block = new Block(2, 1534800002, "fakeblockhash2", null);
    stateService.onNewBlockHeight(2);
    stateService.onNewBlockWithEmptyTxs(block);
    block = new Block(3, 1534800003, "fakeblockhash3", null);
    stateService.onNewBlockHeight(3);
    stateService.onNewBlockWithEmptyTxs(block);
    Assert.assertEquals(
            "Block that was never added should still not exist after adding more blocks.",
            false,
            stateService.isBlockHashKnown("fakeblockhash4")
    );
}
 
Example 16
Source File: ExchangeRateTest.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void bigRate() throws Exception {
    ExchangeRate rate = new ExchangeRate(Coin.parseCoin("0.0001"), Fiat.parseFiat("BYR", "5320387.3"));
    assertEquals("53203873000", rate.coinToFiat(Coin.COIN).toPlainString());
    assertEquals("0", rate.fiatToCoin(Fiat.parseFiat("BYR", "1")).toPlainString()); // Tiny value!
}
 
Example 17
Source File: BlockParserTest.java    From bisq-core with GNU Affero General Public License v3.0 4 votes vote down vote up
@Test
public void testIsBsqTx() {
    // Setup a basic transaction with two inputs
    int height = 200;
    String hash = "abc123";
    long time = new Date().getTime();
    final List<TxInput> inputs = asList(new TxInput("tx1", 0, null),
            new TxInput("tx1", 1, null));
    final List<RawTxOutput> outputs = asList(new RawTxOutput(0, 101, "tx1", null, null, null, height));
    RawTx rawTx = new RawTx("vo", height, hash, time,
            ImmutableList.copyOf(inputs),
            ImmutableList.copyOf(outputs));

    // Return one spendable txoutputs with value, for three test cases
    // 1) - null, 0     -> not BSQ transaction
    // 2) - 100, null   -> BSQ transaction
    // 3) - 0, 100      -> BSQ transaction
    new Expectations(bsqStateService) {{
        // Expectations can be recorded on mocked instances, either with specific matching arguments or catch all
        // http://jmockit.github.io/tutorial/Mocking.html#results
        // Results are returned in the order they're recorded, so in this case for the first call to
        // getSpendableTxOutput("tx1", 0) the return value will be Optional.empty()
        // for the second call the return is Optional.of(new TxOutput(0,... and so on
        bsqStateService.getUnspentTxOutput(new TxOutputKey("tx1", 0));
        result = Optional.empty();
        result = Optional.of(new RawTxOutput(0, 100, "txout1", null, null, null, height));
        result = Optional.of(new RawTxOutput(0, 0, "txout1", null, null, null, height));

        bsqStateService.getUnspentTxOutput(new TxOutputKey("tx1", 1));
        result = Optional.of(new RawTxOutput(0, 0, "txout2", null, null, null, height));
        result = Optional.empty();
        result = Optional.of(new RawTxOutput(0, 100, "txout2", null, null, null, height));
    }};
    String genesisTxId = "genesisTxId";
    int blockHeight = 200;
    String blockHash = "abc123";
    Coin genesisTotalSupply = Coin.parseCoin("2.5");

    // First time there is no BSQ value to spend so it's not a bsq transaction
    assertFalse(txParser.findTx(rawTx, genesisTxId, blockHeight, genesisTotalSupply).isPresent());
    // Second time there is BSQ in the first txout
    assertTrue(txParser.findTx(rawTx, genesisTxId, blockHeight, genesisTotalSupply).isPresent());
    // Third time there is BSQ in the second txout
    assertTrue(txParser.findTx(rawTx, genesisTxId, blockHeight, genesisTotalSupply).isPresent());
}
 
Example 18
Source File: PaymentMethod.java    From bisq-core with GNU Affero General Public License v3.0 4 votes vote down vote up
public Coin getMaxTradeLimitAsCoin(String currencyCode) {
    if (currencyCode.equals("SF") || currencyCode.equals("BSQ"))
        return Coin.parseCoin("4");
    else
        return Coin.valueOf(maxTradeLimit);
}
 
Example 19
Source File: PaymentMethod.java    From bisq-core with GNU Affero General Public License v3.0 4 votes vote down vote up
public static List<PaymentMethod> getAllValues() {
    if (ALL_VALUES == null) {
        Coin maxTradeLimitHighRisk;
        Coin maxTradeLimitMidRisk;
        Coin maxTradeLimitLowRisk;
        Coin maxTradeLimitVeryLowRisk;
        switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
            case "BTC":
                // we want to avoid more then 4 decimal places (0.125 / 4 = 0.03125), so we use a bit higher value to get 0.04 for first month
                maxTradeLimitHighRisk = Coin.parseCoin("0.16");

                maxTradeLimitMidRisk = Coin.parseCoin("0.25");
                maxTradeLimitLowRisk = Coin.parseCoin("0.5");
                maxTradeLimitVeryLowRisk = Coin.parseCoin("1");
                break;
            case "LTC":
                maxTradeLimitHighRisk = Coin.parseCoin("12.5");
                maxTradeLimitMidRisk = Coin.parseCoin("25");
                maxTradeLimitLowRisk = Coin.parseCoin("50");
                maxTradeLimitVeryLowRisk = Coin.parseCoin("100");
                break;
            case "DASH":
                maxTradeLimitHighRisk = Coin.parseCoin("5");
                maxTradeLimitMidRisk = Coin.parseCoin("10");
                maxTradeLimitLowRisk = Coin.parseCoin("20");
                maxTradeLimitVeryLowRisk = Coin.parseCoin("40");
                break;

            default:
                log.error("Unsupported BaseCurrency. " + BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode());
                throw new RuntimeException("Unsupported BaseCurrency. " + BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode());
        }

        ALL_VALUES = new ArrayList<>(Arrays.asList(
                // EUR
                SEPA = new PaymentMethod(SEPA_ID, 6 * DAY, maxTradeLimitMidRisk),
                SEPA_INSTANT = new PaymentMethod(SEPA_INSTANT_ID, DAY, maxTradeLimitMidRisk),
                MONEY_BEAM = new PaymentMethod(MONEY_BEAM_ID, DAY, maxTradeLimitHighRisk),

                // UK
                FASTER_PAYMENTS = new PaymentMethod(FASTER_PAYMENTS_ID, DAY, maxTradeLimitMidRisk),

                // Sweden
                SWISH = new PaymentMethod(SWISH_ID, DAY, maxTradeLimitLowRisk),

                // US
                CLEAR_X_CHANGE = new PaymentMethod(CLEAR_X_CHANGE_ID, 4 * DAY, maxTradeLimitMidRisk),
                CASH_APP = new PaymentMethod(CASH_APP_ID, DAY, maxTradeLimitHighRisk),

                VENMO = new PaymentMethod(VENMO_ID, DAY, maxTradeLimitHighRisk),

                POPMONEY = new PaymentMethod(POPMONEY_ID, DAY, maxTradeLimitHighRisk),
                CHASE_QUICK_PAY = new PaymentMethod(CHASE_QUICK_PAY_ID, DAY, maxTradeLimitMidRisk),
                US_POSTAL_MONEY_ORDER = new PaymentMethod(US_POSTAL_MONEY_ORDER_ID, 8 * DAY, maxTradeLimitMidRisk),

                // Canada
                INTERAC_E_TRANSFER = new PaymentMethod(INTERAC_E_TRANSFER_ID, DAY, maxTradeLimitMidRisk),

                // Global
                CASH_DEPOSIT = new PaymentMethod(CASH_DEPOSIT_ID, 4 * DAY, maxTradeLimitMidRisk),
                MONEY_GRAM = new PaymentMethod(MONEY_GRAM_ID, 4 * DAY, maxTradeLimitMidRisk),
                WESTERN_UNION = new PaymentMethod(WESTERN_UNION_ID, 4 * DAY, maxTradeLimitMidRisk),
                NATIONAL_BANK = new PaymentMethod(NATIONAL_BANK_ID, 4 * DAY, maxTradeLimitMidRisk),
                SAME_BANK = new PaymentMethod(SAME_BANK_ID, 2 * DAY, maxTradeLimitMidRisk),
                SPECIFIC_BANKS = new PaymentMethod(SPECIFIC_BANKS_ID, 4 * DAY, maxTradeLimitMidRisk),
                HAL_CASH = new PaymentMethod(HAL_CASH_ID, DAY, maxTradeLimitLowRisk),
                F2F = new PaymentMethod(F2F_ID, 4 * DAY, maxTradeLimitLowRisk),

                // Trans national
                OK_PAY = new PaymentMethod(OK_PAY_ID, DAY, maxTradeLimitVeryLowRisk),
                UPHOLD = new PaymentMethod(UPHOLD_ID, DAY, maxTradeLimitHighRisk),
                REVOLUT = new PaymentMethod(REVOLUT_ID, DAY, maxTradeLimitHighRisk),
                PERFECT_MONEY = new PaymentMethod(PERFECT_MONEY_ID, DAY, maxTradeLimitLowRisk),

                // China
                ALI_PAY = new PaymentMethod(ALI_PAY_ID, DAY, maxTradeLimitLowRisk),
                WECHAT_PAY = new PaymentMethod(WECHAT_PAY_ID, DAY, maxTradeLimitLowRisk),

                // Altcoins
                BLOCK_CHAINS = new PaymentMethod(BLOCK_CHAINS_ID, DAY, maxTradeLimitVeryLowRisk)
        ));
    }
    ALL_VALUES.sort((o1, o2) -> {
        String id1 = o1.getId();
        if (id1.equals(CLEAR_X_CHANGE_ID))
            id1 = "ZELLE";
        String id2 = o2.getId();
        if (id2.equals(CLEAR_X_CHANGE_ID))
            id2 = "ZELLE";
        return id1.compareTo(id2);
    });
    return ALL_VALUES;
}
 
Example 20
Source File: ExchangeRateTest.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void smallRate() throws Exception {
    ExchangeRate rate = new ExchangeRate(Coin.parseCoin("1000"), Fiat.parseFiat("XXX", "0.0001"));
    assertEquals("0", rate.coinToFiat(Coin.COIN).toPlainString()); // Tiny value!
    assertEquals("10000000", rate.fiatToCoin(Fiat.parseFiat("XXX", "1")).toPlainString());
}