mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-05-20 15:30:36 -04:00
moving away from JUnit 4 completely to JUnit 5 Jupiter
This commit is contained in:
parent
a052fd7767
commit
65bc78d3d7
114 changed files with 1352 additions and 1338 deletions
|
@ -30,8 +30,8 @@ import haveno.network.p2p.P2PService;
|
|||
import haveno.network.p2p.storage.payload.PersistableNetworkPayload;
|
||||
import haveno.network.p2p.storage.persistence.AppendOnlyDataStoreService;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.KeyPair;
|
||||
|
@ -41,8 +41,8 @@ import java.util.Date;
|
|||
|
||||
import static haveno.core.account.sign.SignedWitness.VerificationMethod.ARBITRATOR;
|
||||
import static haveno.core.account.sign.SignedWitness.VerificationMethod.TRADE;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyBoolean;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -85,7 +85,7 @@ public class SignedWitnessServiceTest {
|
|||
KeyPair peer2KeyPair;
|
||||
KeyPair peer3KeyPair;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
AppendOnlyDataStoreService appendOnlyDataStoreService = mock(AppendOnlyDataStoreService.class);
|
||||
ArbitratorManager arbitratorManager = mock(ArbitratorManager.class);
|
||||
|
|
|
@ -5,15 +5,15 @@ import haveno.common.crypto.Sig;
|
|||
import haveno.common.util.Utilities;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.bitcoinj.core.Utils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import static haveno.core.account.sign.SignedWitness.VerificationMethod.ARBITRATOR;
|
||||
import static haveno.core.account.sign.SignedWitness.VerificationMethod.TRADE;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class SignedWitnessTest {
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class SignedWitnessTest {
|
|||
private byte[] witnessHash;
|
||||
private byte[] witnessHashSignature;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
arbitrator1Key = new ECKey();
|
||||
witnessOwner1PubKey = Sig.getPublicKeyBytes(Sig.generateKeyPair().getPublic());
|
||||
|
|
|
@ -43,10 +43,9 @@ import haveno.core.trade.HavenoUtils;
|
|||
import haveno.network.p2p.P2PService;
|
||||
import haveno.network.p2p.storage.persistence.AppendOnlyDataStoreService;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -60,9 +59,9 @@ import java.util.List;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static haveno.core.payment.payload.PaymentMethod.getPaymentMethod;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -82,7 +81,7 @@ public class AccountAgeWitnessServiceTest {
|
|||
private File dir2;
|
||||
private File dir3;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
KeyRing keyRing = mock(KeyRing.class);
|
||||
setupService(keyRing);
|
||||
|
@ -113,12 +112,7 @@ public class AccountAgeWitnessServiceTest {
|
|||
return dir;
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
// Do teardown stuff
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Test
|
||||
public void testIsTradeDateAfterReleaseDate() {
|
||||
Date ageWitnessReleaseDate = new GregorianCalendar(2017, Calendar.OCTOBER, 23).getTime();
|
||||
|
@ -139,7 +133,7 @@ public class AccountAgeWitnessServiceTest {
|
|||
}));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Test
|
||||
public void testVerifySignatureOfNonce() throws CryptoException {
|
||||
byte[] nonce = new byte[]{0x01};
|
||||
|
|
|
@ -19,7 +19,7 @@ package haveno.core.app;
|
|||
|
||||
import haveno.common.config.HavenoHelpFormatter;
|
||||
import joptsimple.OptionParser;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -30,7 +30,7 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Paths;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
public class HavenoHelpFormatterTest {
|
||||
|
||||
|
|
|
@ -22,21 +22,19 @@ import haveno.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
|
|||
import haveno.core.support.dispute.arbitration.arbitrator.ArbitratorService;
|
||||
import haveno.core.user.User;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class ArbitratorManagerTest {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testIsArbitratorAvailableForLanguage() {
|
||||
User user = mock(User.class);
|
||||
|
|
|
@ -22,14 +22,14 @@ import haveno.common.crypto.PubKeyRing;
|
|||
import haveno.core.support.dispute.arbitration.arbitrator.Arbitrator;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@SuppressWarnings({"SameParameterValue", "UnusedAssignment"})
|
||||
public class ArbitratorTest {
|
||||
|
||||
@Ignore("TODO InvalidKeySpecException at haveno.common.crypto.Sig.getPublicKeyFromBytes(Sig.java:135)")
|
||||
@Disabled("TODO InvalidKeySpecException at haveno.common.crypto.Sig.getPublicKeyFromBytes(Sig.java:135)")
|
||||
public void testRoundtrip() {
|
||||
Arbitrator arbitrator = getArbitratorMock();
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.google.common.collect.Lists;
|
|||
import haveno.common.crypto.PubKeyRing;
|
||||
import haveno.core.support.dispute.mediation.mediator.Mediator;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
@ -29,7 +29,7 @@ import static haveno.core.arbitration.ArbitratorTest.getBytes;
|
|||
|
||||
public class MediatorTest {
|
||||
|
||||
@Ignore("TODO InvalidKeySpecException at haveno.common.crypto.Sig.getPublicKeyFromBytes(Sig.java:135)")
|
||||
@Disabled("TODO InvalidKeySpecException at haveno.common.crypto.Sig.getPublicKeyFromBytes(Sig.java:135)")
|
||||
public void testRoundtrip() {
|
||||
Mediator Mediator = getMediatorMock();
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@ package haveno.core.arbitration;
|
|||
import haveno.core.account.witness.AccountAgeWitness;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.support.dispute.arbitration.TraderDataItem;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.PublicKey;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/*
|
||||
|
@ -38,7 +38,7 @@ public class TraderDataItemTest {
|
|||
private byte[] hash1 = "1".getBytes();
|
||||
private byte[] hash2 = "2".getBytes();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
accountAgeWitness1 = new AccountAgeWitness(hash1, 123);
|
||||
accountAgeWitness2 = new AccountAgeWitness(hash2, 124);
|
||||
|
|
|
@ -21,10 +21,8 @@ import haveno.common.crypto.CryptoException;
|
|||
import haveno.common.crypto.KeyRing;
|
||||
import haveno.common.crypto.KeyStorage;
|
||||
import haveno.common.file.FileUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -33,11 +31,10 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.security.cert.CertificateException;
|
||||
|
||||
public class EncryptionTest {
|
||||
private static final Logger log = LoggerFactory.getLogger(EncryptionTest.class);
|
||||
private KeyRing keyRing;
|
||||
private File dir;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, CryptoException {
|
||||
|
||||
dir = File.createTempFile("temp_tests", "");
|
||||
|
@ -49,7 +46,7 @@ public class EncryptionTest {
|
|||
keyRing = new KeyRing(keyStorage, null, true);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() throws IOException {
|
||||
FileUtil.deleteDirectory(dir);
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ import haveno.common.crypto.KeyRing;
|
|||
import haveno.common.crypto.KeyStorage;
|
||||
import haveno.common.crypto.Sig;
|
||||
import haveno.common.file.FileUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -32,14 +32,14 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class SigTest {
|
||||
private static final Logger log = LoggerFactory.getLogger(SigTest.class);
|
||||
private KeyRing keyRing;
|
||||
private File dir;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
|
||||
dir = File.createTempFile("temp_tests", "");
|
||||
|
@ -51,7 +51,7 @@ public class SigTest {
|
|||
keyRing = new KeyRing(keyStorage, null, true);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() throws IOException {
|
||||
FileUtil.deleteDirectory(dir);
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package haveno.core.locale;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class BankUtilTest {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
Locale.setDefault(new Locale("en", "US"));
|
||||
GlobalSettings.setLocale(new Locale("en", "US"));
|
||||
|
|
|
@ -22,9 +22,8 @@ import haveno.asset.AssetRegistry;
|
|||
import haveno.asset.Coin;
|
||||
import haveno.asset.coins.Ether;
|
||||
import haveno.common.config.BaseCurrencyNetwork;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -33,13 +32,14 @@ import java.util.Optional;
|
|||
import java.util.ServiceLoader;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class CurrencyUtilTest {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
|
||||
Locale.setDefault(new Locale("en", "US"));
|
||||
|
@ -55,7 +55,7 @@ public class CurrencyUtilTest {
|
|||
|
||||
assertTrue(euro.isPresent());
|
||||
assertTrue(naira.isPresent());
|
||||
assertFalse("Fake currency shouldn't exist", fake.isPresent());
|
||||
assertFalse(fake.isPresent(), "Fake currency shouldn't exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -68,11 +68,11 @@ public class CurrencyUtilTest {
|
|||
assetRegistry.addAsset(mockTestnetCoin);
|
||||
CurrencyUtil.findAsset(assetRegistry, "MOCK_COIN",
|
||||
BaseCurrencyNetwork.XMR_MAINNET);
|
||||
Assert.fail("Expected an IllegalArgumentException");
|
||||
fail("Expected an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
String wantMessage = "We are on mainnet and we could not find an asset with network type mainnet";
|
||||
Assert.assertTrue("Unexpected exception, want message starting with " +
|
||||
"'" + wantMessage + "', got '" + e.getMessage() + "'", e.getMessage().startsWith(wantMessage));
|
||||
assertTrue(e.getMessage().startsWith(wantMessage), "Unexpected exception, want message starting with " +
|
||||
"'" + wantMessage + "', got '" + e.getMessage() + "'");
|
||||
}
|
||||
|
||||
// For testnet its ok
|
||||
|
|
|
@ -17,15 +17,14 @@
|
|||
|
||||
package haveno.core.message;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@Slf4j
|
||||
public class MarshallerTest {
|
||||
|
|
|
@ -17,117 +17,121 @@
|
|||
|
||||
package haveno.core.monetary;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static haveno.core.monetary.Price.parse;
|
||||
import static haveno.core.monetary.Price.valueOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class PriceTest {
|
||||
|
||||
@Test
|
||||
public void testParse() {
|
||||
Price result = Price.parse("USD", "0.1");
|
||||
Assert.assertEquals(
|
||||
"Fiat value should be formatted with two decimals.",
|
||||
Price result = parse("USD", "0.1");
|
||||
assertEquals(
|
||||
"0.10 XMR/USD",
|
||||
result.toFriendlyString()
|
||||
result.toFriendlyString(),
|
||||
"Fiat value should be formatted with two decimals."
|
||||
);
|
||||
|
||||
result = Price.parse("EUR", "0.1234");
|
||||
Assert.assertEquals(
|
||||
"Fiat value should be given two decimals",
|
||||
result = parse("EUR", "0.1234");
|
||||
assertEquals(
|
||||
"0.1234 XMR/EUR",
|
||||
result.toFriendlyString()
|
||||
result.toFriendlyString(),
|
||||
"Fiat value should be given two decimals"
|
||||
);
|
||||
|
||||
try {
|
||||
Price.parse("EUR", "0.12345");
|
||||
Assert.fail("Expected IllegalArgumentException to be thrown when too many decimals are used.");
|
||||
parse("EUR", "0.12345");
|
||||
fail("Expected IllegalArgumentException to be thrown when too many decimals are used.");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
Assert.assertEquals(
|
||||
"Unexpected exception message.",
|
||||
assertEquals(
|
||||
"java.lang.ArithmeticException: Rounding necessary",
|
||||
iae.getMessage()
|
||||
iae.getMessage(),
|
||||
"Unexpected exception message."
|
||||
);
|
||||
}
|
||||
|
||||
Assert.assertEquals(
|
||||
"Negative value should be parsed correctly.",
|
||||
assertEquals(
|
||||
-100000000L,
|
||||
Price.parse("LTC", "-1").getValue()
|
||||
parse("LTC", "-1").getValue(),
|
||||
"Negative value should be parsed correctly."
|
||||
);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Comma (',') as decimal separator should be converted to period ('.')",
|
||||
assertEquals(
|
||||
"0.0001 XMR/USD",
|
||||
Price.parse("USD", "0,0001").toFriendlyString()
|
||||
parse("USD", "0,0001").toFriendlyString(),
|
||||
"Comma (',') as decimal separator should be converted to period ('.')"
|
||||
);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Too many decimals should get rounded up properly.",
|
||||
assertEquals(
|
||||
"10000.2346 LTC/XMR",
|
||||
Price.parse("LTC", "10000,23456789").toFriendlyString()
|
||||
parse("LTC", "10000,23456789").toFriendlyString(),
|
||||
"Too many decimals should get rounded up properly."
|
||||
);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Too many decimals should get rounded down properly.",
|
||||
assertEquals(
|
||||
"10000.2345 LTC/XMR",
|
||||
Price.parse("LTC", "10000,23454999").toFriendlyString()
|
||||
parse("LTC", "10000,23454999").toFriendlyString(),
|
||||
"Too many decimals should get rounded down properly."
|
||||
);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Underlying long value should be correct.",
|
||||
assertEquals(
|
||||
1000023456789L,
|
||||
Price.parse("LTC", "10000,23456789").getValue()
|
||||
parse("LTC", "10000,23456789").getValue(),
|
||||
"Underlying long value should be correct."
|
||||
);
|
||||
|
||||
try {
|
||||
Price.parse("XMR", "56789.123456789");
|
||||
Assert.fail("Expected IllegalArgumentException to be thrown when too many decimals are used.");
|
||||
parse("XMR", "56789.123456789");
|
||||
fail("Expected IllegalArgumentException to be thrown when too many decimals are used.");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
Assert.assertEquals(
|
||||
"Unexpected exception message.",
|
||||
assertEquals(
|
||||
"java.lang.ArithmeticException: Rounding necessary",
|
||||
iae.getMessage()
|
||||
iae.getMessage(),
|
||||
"Unexpected exception message."
|
||||
);
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
Price result = Price.valueOf("USD", 1);
|
||||
Assert.assertEquals(
|
||||
"Fiat value should have four decimals.",
|
||||
Price result = valueOf("USD", 1);
|
||||
assertEquals(
|
||||
"0.0001 XMR/USD",
|
||||
result.toFriendlyString()
|
||||
result.toFriendlyString(),
|
||||
"Fiat value should have four decimals."
|
||||
);
|
||||
|
||||
result = Price.valueOf("EUR", 1234);
|
||||
Assert.assertEquals(
|
||||
"Fiat value should be given two decimals",
|
||||
result = valueOf("EUR", 1234);
|
||||
assertEquals(
|
||||
"0.1234 XMR/EUR",
|
||||
result.toFriendlyString()
|
||||
result.toFriendlyString(),
|
||||
"Fiat value should be given two decimals"
|
||||
);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Negative value should be parsed correctly.",
|
||||
assertEquals(
|
||||
-1L,
|
||||
Price.valueOf("LTC", -1L).getValue()
|
||||
valueOf("LTC", -1L).getValue(),
|
||||
"Negative value should be parsed correctly."
|
||||
);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Too many decimals should get rounded up properly.",
|
||||
assertEquals(
|
||||
"10000.2346 LTC/XMR",
|
||||
Price.valueOf("LTC", 1000023456789L).toFriendlyString()
|
||||
valueOf("LTC", 1000023456789L).toFriendlyString(),
|
||||
"Too many decimals should get rounded up properly."
|
||||
);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Too many decimals should get rounded down properly.",
|
||||
assertEquals(
|
||||
"10000.2345 LTC/XMR",
|
||||
Price.valueOf("LTC", 1000023454999L).toFriendlyString()
|
||||
valueOf("LTC", 1000023454999L).toFriendlyString(),
|
||||
"Too many decimals should get rounded down properly."
|
||||
);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Underlying long value should be correct.",
|
||||
assertEquals(
|
||||
1000023456789L,
|
||||
Price.valueOf("LTC", 1000023456789L).getValue()
|
||||
valueOf("LTC", 1000023456789L).getValue(),
|
||||
"Underlying long value should be correct."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,17 +19,19 @@ package haveno.core.network.p2p.seed;
|
|||
|
||||
import haveno.common.config.Config;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class DefaultSeedNodeRepositoryTest {
|
||||
|
||||
@Test
|
||||
public void getSeedNodes() {
|
||||
DefaultSeedNodeRepository DUT = new DefaultSeedNodeRepository(new Config());
|
||||
Assert.assertFalse(DUT.getSeedNodeAddresses().isEmpty());
|
||||
assertFalse(DUT.getSeedNodeAddresses().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -38,9 +40,9 @@ public class DefaultSeedNodeRepositoryTest {
|
|||
String seed2 = "fdsa:6001";
|
||||
String seedNodesOption = format("--%s=%s,%s", Config.SEED_NODES, seed1, seed2);
|
||||
DefaultSeedNodeRepository DUT = new DefaultSeedNodeRepository(new Config(seedNodesOption));
|
||||
Assert.assertFalse(DUT.getSeedNodeAddresses().isEmpty());
|
||||
Assert.assertEquals(2, DUT.getSeedNodeAddresses().size());
|
||||
Assert.assertTrue(DUT.getSeedNodeAddresses().contains(new NodeAddress(seed1)));
|
||||
Assert.assertTrue(DUT.getSeedNodeAddresses().contains(new NodeAddress(seed2)));
|
||||
assertFalse(DUT.getSeedNodeAddresses().isEmpty());
|
||||
assertEquals(2, DUT.getSeedNodeAddresses().size());
|
||||
assertTrue(DUT.getSeedNodeAddresses().contains(new NodeAddress(seed1)));
|
||||
assertTrue(DUT.getSeedNodeAddresses().contains(new NodeAddress(seed2)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ package haveno.core.notifications;
|
|||
|
||||
import haveno.common.util.Tuple2;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static common.utils.GenUtils.assertEquals;
|
||||
|
||||
@Slf4j
|
||||
public class MobileModelTest {
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
|
||||
package haveno.core.offer;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
|
|
@ -11,16 +11,16 @@ import haveno.core.api.CoreMoneroConnectionsService;
|
|||
import haveno.core.trade.TradableList;
|
||||
import haveno.network.p2p.P2PService;
|
||||
import haveno.network.p2p.peers.PeerManager;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static com.natpryce.makeiteasy.MakeItEasy.make;
|
||||
import static haveno.core.offer.OfferMaker.btcUsdOffer;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -33,7 +33,7 @@ public class OpenOfferManagerTest {
|
|||
private PersistenceManager<SignedOfferList> signedOfferPersistenceManager;
|
||||
private CoreContext coreContext;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
var corruptedStorageFileHandler = mock(CorruptedStorageFileHandler.class);
|
||||
var storageDir = Files.createTempDirectory("storage").toFile();
|
||||
|
@ -43,7 +43,7 @@ public class OpenOfferManagerTest {
|
|||
coreContext = new CoreContext();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
persistenceManager.shutdown();
|
||||
signedOfferPersistenceManager.shutdown();
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
|
||||
package haveno.core.offer.availability;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class ArbitratorSelectionTest {
|
||||
@Test
|
||||
|
|
|
@ -21,11 +21,11 @@ import haveno.core.account.witness.AccountAgeWitness;
|
|||
import haveno.core.account.witness.AccountAgeWitnessService;
|
||||
import haveno.core.offer.Offer;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
|
@ -21,10 +21,10 @@ import com.google.common.collect.Lists;
|
|||
import haveno.core.locale.CryptoCurrency;
|
||||
import haveno.core.offer.Offer;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
|
|
@ -18,28 +18,25 @@
|
|||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.offer.Offer;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.StrictStubs.class)
|
||||
public class ReceiptValidatorTest {
|
||||
private ReceiptValidator validator;
|
||||
private PaymentAccount account;
|
||||
private Offer offer;
|
||||
private ReceiptPredicates predicates;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.predicates = mock(ReceiptPredicates.class);
|
||||
this.account = mock(CountryBasedPaymentAccount.class);
|
||||
|
@ -47,7 +44,7 @@ public class ReceiptValidatorTest {
|
|||
this.validator = new ReceiptValidator(offer, account, predicates);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
verifyNoMoreInteractions(offer);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package haveno.core.payment;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TradeLimitsTest {
|
||||
@Test
|
||||
|
|
|
@ -22,10 +22,10 @@ import haveno.common.config.BaseCurrencyNetwork;
|
|||
import haveno.common.config.Config;
|
||||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.locale.Res;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class AltCoinAddressValidatorTest {
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@ package haveno.core.provider.mempool;
|
|||
import com.google.gson.Gson;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -32,6 +31,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TxValidatorTest {
|
||||
private static final Logger log = LoggerFactory.getLogger(TxValidatorTest.class);
|
||||
|
||||
|
@ -70,12 +72,12 @@ public class TxValidatorTest {
|
|||
String jsonTxt = mempoolData.get(txValidator.getTxId());
|
||||
if (jsonTxt == null || jsonTxt.isEmpty()) {
|
||||
log.warn("{} was not found in the mempool", txValidator.getTxId());
|
||||
Assert.assertFalse(expectedResult); // tx was not found in explorer
|
||||
assertFalse(expectedResult); // tx was not found in explorer
|
||||
} else {
|
||||
//txValidator.parseJsonValidateMakerFeeTx(jsonTxt, btcFeeReceivers);
|
||||
log.warn("expectedResult {}", expectedResult );
|
||||
log.warn("getResult {}", txValidator.getResult() );
|
||||
Assert.assertTrue(expectedResult == txValidator.getResult());
|
||||
assertTrue(expectedResult == txValidator.getResult());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
|
||||
package haveno.core.provider.price;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@Ignore
|
||||
@Disabled
|
||||
public class MarketPriceFeedServiceTest {
|
||||
private static final Logger log = LoggerFactory.getLogger(MarketPriceFeedServiceTest.class);
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ package haveno.core.trade;
|
|||
import haveno.core.offer.Offer;
|
||||
import haveno.core.offer.OfferPayload;
|
||||
import haveno.core.offer.OpenOffer;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static protobuf.PersistableEnvelope.MessageCase.TRADABLE_LIST;
|
||||
|
|
|
@ -27,16 +27,16 @@ import haveno.core.locale.GlobalSettings;
|
|||
import haveno.core.locale.Res;
|
||||
import haveno.core.xmr.nodes.LocalBitcoinNode;
|
||||
import javafx.collections.ObservableList;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Currency;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -46,7 +46,7 @@ public class PreferencesTest {
|
|||
private Preferences preferences;
|
||||
private PersistenceManager persistenceManager;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
final Locale en_US = new Locale("en", "US");
|
||||
Locale.setDefault(en_US);
|
||||
|
|
|
@ -23,19 +23,19 @@ import haveno.core.arbitration.ArbitratorTest;
|
|||
import haveno.core.arbitration.MediatorTest;
|
||||
import haveno.core.filter.Filter;
|
||||
import haveno.core.proto.CoreProtoResolver;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class UserPayloadModelVOTest {
|
||||
@Ignore("TODO InvalidKeySpecException at haveno.common.crypto.Sig.getPublicKeyFromBytes(Sig.java:135)")
|
||||
@Disabled("TODO InvalidKeySpecException at haveno.common.crypto.Sig.getPublicKeyFromBytes(Sig.java:135)")
|
||||
public void testRoundtrip() {
|
||||
UserPayload vo = new UserPayload();
|
||||
vo.setAccountId("accountId");
|
||||
UserPayload newVo = UserPayload.fromProto(vo.toProtoMessage().getUserPayload(), new CoreProtoResolver());
|
||||
}
|
||||
|
||||
@Ignore("TODO InvalidKeySpecException at haveno.common.crypto.Sig.getPublicKeyFromBytes(Sig.java:135)")
|
||||
@Disabled("TODO InvalidKeySpecException at haveno.common.crypto.Sig.getPublicKeyFromBytes(Sig.java:135)")
|
||||
public void testRoundtripFull() {
|
||||
UserPayload vo = new UserPayload();
|
||||
vo.setAccountId("accountId");
|
||||
|
|
|
@ -6,8 +6,8 @@ import haveno.core.locale.GlobalSettings;
|
|||
import haveno.core.locale.Res;
|
||||
import haveno.core.monetary.Price;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -15,8 +15,8 @@ import java.util.concurrent.TimeUnit;
|
|||
import static com.natpryce.makeiteasy.MakeItEasy.a;
|
||||
import static com.natpryce.makeiteasy.MakeItEasy.make;
|
||||
import static com.natpryce.makeiteasy.MakeItEasy.with;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class FormattingUtilsTest {
|
||||
private static final Property<Price, String> currencyCode = new Property<>();
|
||||
|
@ -24,7 +24,7 @@ public class FormattingUtilsTest {
|
|||
private static final Maker<Price> usdPrice = a(lookup ->
|
||||
new Price(Fiat.parseFiat(lookup.valueOf(currencyCode, "USD"), lookup.valueOf(priceString, "100"))));
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
Locale.setDefault(new Locale("en", "US"));
|
||||
GlobalSettings.setLocale(new Locale("en", "US"));
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
|
||||
package haveno.core.util;
|
||||
|
||||
import haveno.common.proto.ProtoUtil;
|
||||
import haveno.core.offer.OfferDirection;
|
||||
import haveno.core.offer.OpenOffer;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import protobuf.OpenOffer.State;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static haveno.common.proto.ProtoUtil.enumFromProto;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@SuppressWarnings("UnusedAssignment")
|
||||
public class ProtoUtilTest {
|
||||
|
@ -41,9 +42,9 @@ public class ProtoUtilTest {
|
|||
|
||||
@Test
|
||||
public void testUnknownEnum() {
|
||||
protobuf.OpenOffer.State result = protobuf.OpenOffer.State.PB_ERROR;
|
||||
State result = State.PB_ERROR;
|
||||
try {
|
||||
OpenOffer.State finalResult = OpenOffer.State.valueOf(result.name());
|
||||
OpenOffer.State.valueOf(result.name());
|
||||
fail();
|
||||
} catch (IllegalArgumentException ignore) {
|
||||
}
|
||||
|
@ -51,10 +52,10 @@ public class ProtoUtilTest {
|
|||
|
||||
@Test
|
||||
public void testUnknownEnumFix() {
|
||||
protobuf.OpenOffer.State result = protobuf.OpenOffer.State.PB_ERROR;
|
||||
State result = State.PB_ERROR;
|
||||
try {
|
||||
OpenOffer.State finalResult = ProtoUtil.enumFromProto(OpenOffer.State.class, result.name());
|
||||
assertEquals(OpenOffer.State.AVAILABLE, ProtoUtil.enumFromProto(OpenOffer.State.class, "AVAILABLE"));
|
||||
enumFromProto(OpenOffer.State.class, result.name());
|
||||
assertEquals(OpenOffer.State.AVAILABLE, enumFromProto(OpenOffer.State.class, "AVAILABLE"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
fail();
|
||||
}
|
||||
|
|
|
@ -21,18 +21,18 @@ import haveno.core.locale.GlobalSettings;
|
|||
import haveno.core.locale.Res;
|
||||
import haveno.core.util.validation.RegexValidator;
|
||||
import haveno.core.util.validation.RegexValidatorFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
|
||||
public class RegexValidatorTest {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
Locale.setDefault(new Locale("en", "US"));
|
||||
GlobalSettings.setLocale(new Locale("en", "US"));
|
||||
|
|
|
@ -21,12 +21,12 @@ import haveno.core.monetary.Price;
|
|||
import haveno.core.trade.HavenoUtils;
|
||||
import haveno.core.xmr.wallet.Restrictions;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class CoinUtilTest {
|
||||
|
||||
|
@ -64,9 +64,9 @@ public class CoinUtilTest {
|
|||
HavenoUtils.xmrToAtomicUnits(0.2).longValueExact(),
|
||||
1);
|
||||
assertEquals(
|
||||
"Minimum trade amount allowed should be adjusted to the smallest trade allowed.",
|
||||
HavenoUtils.formatXmr(Restrictions.MIN_TRADE_AMOUNT, true),
|
||||
HavenoUtils.formatXmr(result, true)
|
||||
HavenoUtils.formatXmr(result, true),
|
||||
"Minimum trade amount allowed should be adjusted to the smallest trade allowed."
|
||||
);
|
||||
|
||||
try {
|
||||
|
@ -78,9 +78,9 @@ public class CoinUtilTest {
|
|||
fail("Expected IllegalArgumentException to be thrown when amount is too low.");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
assertEquals(
|
||||
"Unexpected exception message.",
|
||||
"amount needs to be above minimum of 0.0001 xmr",
|
||||
iae.getMessage()
|
||||
iae.getMessage(),
|
||||
"Unexpected exception message."
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -90,9 +90,9 @@ public class CoinUtilTest {
|
|||
HavenoUtils.xmrToAtomicUnits(0.2).longValueExact(),
|
||||
1);
|
||||
assertEquals(
|
||||
"Minimum allowed trade amount should not be adjusted.",
|
||||
"0.10 XMR",
|
||||
HavenoUtils.formatXmr(result, true)
|
||||
HavenoUtils.formatXmr(result, true),
|
||||
"Minimum allowed trade amount should not be adjusted."
|
||||
);
|
||||
|
||||
result = CoinUtil.getAdjustedAmount(
|
||||
|
@ -101,9 +101,9 @@ public class CoinUtilTest {
|
|||
HavenoUtils.xmrToAtomicUnits(0.25).longValueExact(),
|
||||
1);
|
||||
assertEquals(
|
||||
"Minimum trade amount allowed should respect maxTradeLimit and factor, if possible.",
|
||||
"0.10 XMR",
|
||||
HavenoUtils.formatXmr(result, true)
|
||||
HavenoUtils.formatXmr(result, true),
|
||||
"Minimum trade amount allowed should respect maxTradeLimit and factor, if possible."
|
||||
);
|
||||
|
||||
// TODO(chirhonul): The following seems like it should raise an exception or otherwise fail.
|
||||
|
@ -117,9 +117,9 @@ public class CoinUtilTest {
|
|||
HavenoUtils.xmrToAtomicUnits(0.00005).longValueExact(),
|
||||
1);
|
||||
assertEquals(
|
||||
"Minimum trade amount allowed with low maxTradeLimit should still respect that limit, even if result does not respect the factor specified.",
|
||||
"0.00005 XMR",
|
||||
HavenoUtils.formatXmr(result, true)
|
||||
HavenoUtils.formatXmr(result, true),
|
||||
"Minimum trade amount allowed with low maxTradeLimit should still respect that limit, even if result does not respect the factor specified."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ import haveno.core.xmr.setup.WalletConfig;
|
|||
import haveno.network.Socks5MultiDiscovery;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.PeerAddress;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class BtcNetworkConfigTest {
|
|||
|
||||
private WalletConfig delegate;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
delegate = mock(WalletConfig.class);
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@ import haveno.core.xmr.nodes.BtcNodeConverter.Facade;
|
|||
import haveno.core.xmr.nodes.BtcNodes.BtcNode;
|
||||
import haveno.network.DnsLookupException;
|
||||
import org.bitcoinj.core.PeerAddress;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
|
@ -21,14 +21,14 @@ import com.google.common.collect.Lists;
|
|||
import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy;
|
||||
import haveno.core.xmr.nodes.BtcNodes.BtcNode;
|
||||
import org.bitcoinj.core.PeerAddress;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
|
@ -19,14 +19,14 @@ package haveno.core.xmr.nodes;
|
|||
|
||||
import haveno.core.user.Preferences;
|
||||
import haveno.core.xmr.nodes.BtcNodes.BtcNode;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static haveno.core.xmr.nodes.BtcNodes.BitcoinNodesOption.CUSTOM;
|
||||
import static haveno.core.xmr.nodes.BtcNodes.BitcoinNodesOption.PUBLIC;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
package haveno.core.xmr.wallet;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public class RestrictionsTest {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue