mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-26 00:15:18 -04:00
add system try support, add address to create offer screen
This commit is contained in:
parent
01ca7d3e17
commit
65d97819ac
60 changed files with 1278 additions and 1040 deletions
|
@ -1,18 +0,0 @@
|
|||
package io.bitsquare;
|
||||
|
||||
import io.bitsquare.btc.BtcValidatorTest;
|
||||
import io.bitsquare.gui.util.BitSquareConverterTest;
|
||||
import io.bitsquare.gui.util.BitSquareValidatorTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
BtcValidatorTest.class,
|
||||
BitSquareConverterTest.class,
|
||||
BitSquareValidatorTest.class,
|
||||
})
|
||||
|
||||
public class BitSquareTestSuite
|
||||
{
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package io.bitsquare.btc;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import java.math.BigInteger;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BtcValidatorTest
|
||||
{
|
||||
@Test
|
||||
public void testIsMinSpendableAmount()
|
||||
{
|
||||
BigInteger amount = null;
|
||||
//noinspection ConstantConditions
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = BigInteger.ZERO;
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = FeePolicy.TX_FEE;
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = Transaction.MIN_NONDUST_OUTPUT;
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = FeePolicy.TX_FEE.add(Transaction.MIN_NONDUST_OUTPUT);
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = FeePolicy.TX_FEE.add(Transaction.MIN_NONDUST_OUTPUT).add(BigInteger.ONE);
|
||||
assertTrue("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package io.bitsquare.gui.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class BitSquareConverterTest
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testStringToDouble()
|
||||
{
|
||||
|
||||
assertEquals(1, BitSquareConverter.stringToDouble("1"), 0);
|
||||
assertEquals(0.1, BitSquareConverter.stringToDouble("0.1"), 0);
|
||||
assertEquals(0.1, BitSquareConverter.stringToDouble("0,1"), 0);
|
||||
assertEquals(1, BitSquareConverter.stringToDouble("1.0"), 0);
|
||||
assertEquals(1, BitSquareConverter.stringToDouble("1,0"), 0);
|
||||
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble("1,000.2"), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble("1,000.2"), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble(null), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble(""), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble(""), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble("."), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble(","), 0);
|
||||
assertEquals(Double.NEGATIVE_INFINITY, BitSquareConverter.stringToDouble("a"), 0);
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package io.bitsquare.gui.util;
|
||||
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Currency;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BitSquareValidatorTest
|
||||
{
|
||||
@Test
|
||||
public void testValidateStringAsDouble()
|
||||
{
|
||||
assertTrue(BitSquareValidator.validateStringAsDouble("0"));
|
||||
assertTrue(BitSquareValidator.validateStringAsDouble("1"));
|
||||
assertTrue(BitSquareValidator.validateStringAsDouble("0,1"));
|
||||
assertTrue(BitSquareValidator.validateStringAsDouble("0.01"));
|
||||
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble(""));
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble("a"));
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble("0.0.1"));
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble("1,000.1"));
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble("1.000,1"));
|
||||
assertFalse(BitSquareValidator.validateStringAsDouble(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateStringNotEmpty()
|
||||
{
|
||||
assertTrue(BitSquareValidator.validateStringNotEmpty("a"));
|
||||
assertTrue(BitSquareValidator.validateStringNotEmpty("123"));
|
||||
|
||||
assertFalse(BitSquareValidator.validateStringNotEmpty(""));
|
||||
assertFalse(BitSquareValidator.validateStringNotEmpty(" "));
|
||||
assertFalse(BitSquareValidator.validateStringNotEmpty(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTradeAmountOutOfRange()
|
||||
{
|
||||
|
||||
assertFalse(BitSquareValidator.tradeAmountOutOfRange(BigInteger.ZERO, new MockOffer(BigInteger.TEN, BigInteger.valueOf(0))));
|
||||
assertTrue(BitSquareValidator.tradeAmountOutOfRange(BigInteger.ZERO, new MockOffer(BigInteger.TEN, BigInteger.valueOf(1))));
|
||||
assertFalse(BitSquareValidator.tradeAmountOutOfRange(BigInteger.TEN, new MockOffer(BigInteger.TEN, BigInteger.valueOf(0))));
|
||||
assertFalse(BitSquareValidator.tradeAmountOutOfRange(BigInteger.TEN, new MockOffer(BigInteger.TEN, BigInteger.valueOf(2))));
|
||||
assertTrue(BitSquareValidator.tradeAmountOutOfRange(BigInteger.TEN, new MockOffer(BigInteger.ONE, BigInteger.valueOf(0))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGreaterThanZero()
|
||||
{
|
||||
assertFalse(BitSquareValidator.greaterThanZero(BigInteger.ZERO));
|
||||
assertFalse(BitSquareValidator.greaterThanZero(BigInteger.valueOf(-1)));
|
||||
assertTrue(BitSquareValidator.greaterThanZero(BigInteger.ONE));
|
||||
}
|
||||
|
||||
public static class MockOffer extends Offer
|
||||
{
|
||||
|
||||
public MockOffer(BigInteger amount, BigInteger minAmount)
|
||||
{
|
||||
super(null, null, 0, amount, minAmount, null, null, null, null, null, 0, null, null);
|
||||
}
|
||||
|
||||
public MockOffer(String messagePubKeyAsHex, Direction direction, double price, BigInteger amount, BigInteger minAmount, BankAccountType bankAccountType, Currency currency, Country bankAccountCountry, String bankAccountUID, Arbitrator arbitrator, int collateral, List<Country> acceptedCountries, List<Locale> acceptedLanguageLocales)
|
||||
{
|
||||
super(messagePubKeyAsHex, direction, price, amount, minAmount, bankAccountType, currency, bankAccountCountry, bankAccountUID, arbitrator, collateral, acceptedCountries, acceptedLanguageLocales);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue