moving away from JUnit 4 completely to JUnit 5 Jupiter

This commit is contained in:
napoly 2023-03-25 18:11:58 +01:00 committed by woodser
parent a052fd7767
commit 65bc78d3d7
114 changed files with 1352 additions and 1338 deletions

View File

@ -1,57 +0,0 @@
package haveno.apitest;
import lombok.extern.slf4j.Slf4j;
import org.junit.runner.Description;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
import static java.lang.String.format;
@Slf4j
public class JUnitHelper {
private static boolean allPass;
public static void runTests(Class<?>... testClasses) {
JUnitCore jUnitCore = new JUnitCore();
jUnitCore.addListener(new RunListener() {
public void testStarted(Description description) {
log.info("{}", description);
}
public void testIgnored(Description description) {
log.info("Ignored {}", description);
}
public void testFailure(Failure failure) {
log.error("Failed {}", failure.getTrace());
}
});
Result result = jUnitCore.run(testClasses);
printTestResults(result);
}
public static boolean allTestsPassed() {
return allPass;
}
private static void printTestResults(Result result) {
log.info("Total tests: {}, Failed: {}, Ignored: {}",
result.getRunCount(),
result.getFailureCount(),
result.getIgnoreCount());
if (result.wasSuccessful()) {
log.info("All {} tests passed", result.getRunCount());
allPass = true;
} else if (result.getFailureCount() > 0) {
log.error("{} test(s) failed", result.getFailureCount());
result.getFailures().iterator().forEachRemaining(f -> log.error(format("%s.%s()%n\t%s",
f.getDescription().getTestClass().getName(),
f.getDescription().getMethodName(),
f.getTrace())));
}
}
}

View File

@ -17,10 +17,10 @@
package haveno.asset;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Abstract base class for all {@link Asset} unit tests. Subclasses must implement the

View File

@ -18,7 +18,7 @@
package haveno.asset.coins;
import haveno.asset.AbstractAssetTest;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class BitcoinCashTest extends AbstractAssetTest {

View File

@ -18,7 +18,7 @@
package haveno.asset.coins;
import haveno.asset.AbstractAssetTest;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class BitcoinTest extends AbstractAssetTest {

View File

@ -18,7 +18,7 @@
package haveno.asset.coins;
import haveno.asset.AbstractAssetTest;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class LitecoinTest extends AbstractAssetTest {

View File

@ -18,7 +18,7 @@
package haveno.asset.coins;
import haveno.asset.AbstractAssetTest;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class MoneroTest extends AbstractAssetTest {

View File

@ -50,7 +50,7 @@ configure(subprojects) {
guiceVersion = '4.2.2'
moneroJavaVersion = '0.7.15'
httpclient5Version = '5.0'
hamcrestVersion = '1.3'
hamcrestVersion = '2.2'
httpclientVersion = '4.5.12'
httpcoreVersion = '4.4.13'
ioVersion = '2.6'
@ -63,8 +63,7 @@ configure(subprojects) {
joptVersion = '5.0.4'
jsonsimpleVersion = '1.1.1'
jsonrpc4jVersion = '1.6.0.bisq.1'
junitVersion = '4.12'
jupiterVersion = '5.7.0'
jupiterVersion = '5.9.2'
kotlinVersion = '1.3.41'
langVersion = '3.11'
logbackVersion = '1.1.11'
@ -89,10 +88,6 @@ configure(subprojects) {
maven { url 'https://mvnrepository.com' }
}
dependencies {
testImplementation "junit:junit:$junitVersion"
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
@ -250,6 +245,9 @@ configure(project(':assets')) {
implementation "com.google.guava:guava:$guavaVersion"
implementation "org.apache.commons:commons-lang3:$langVersion"
implementation "org.slf4j:slf4j-api:$slf4jVersion"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jupiterVersion"
}
}
@ -285,7 +283,9 @@ configure(project(':common')) {
implementation "org.bouncycastle:bcpg-jdk15on:$bcVersion"
implementation "org.jetbrains:annotations:$jetbrainsAnnotationsVersion"
implementation "org.slf4j:slf4j-api:$slf4jVersion"
testImplementation "org.hamcrest:hamcrest-all:$hamcrestVersion"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jupiterVersion"
runtimeOnly("io.grpc:grpc-netty-shaded:$grpcVersion") {
exclude(module: 'guava')
exclude(module: 'animal-sniffer-annotations')
@ -332,6 +332,9 @@ configure(project(':p2p')) {
}
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$jupiterVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jupiterVersion"
testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
testImplementation "ch.qos.logback:logback-core:$logbackVersion"
testImplementation "org.apache.commons:commons-lang3:$langVersion"
@ -398,7 +401,9 @@ configure(project(':core')) {
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
testImplementation "com.natpryce:make-it-easy:$easyVersion"
testImplementation "org.hamcrest:hamcrest-all:$hamcrestVersion"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jupiterVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
implementation "org.openjfx:javafx-base:$javafxVersion:$os"
@ -556,7 +561,7 @@ configure(project(':cli')) {
testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$jupiterVersion"
testRuntimeOnly "javax.annotation:javax.annotation-api:$javaxAnnotationVersion"
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jupiterVersion"
}
test {
@ -624,6 +629,9 @@ configure(project(':desktop')) {
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
testImplementation "com.natpryce:make-it-easy:$easyVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jupiterVersion"
implementation("io.github.monero-ecosystem:monero-java:$moneroJavaVersion") {
exclude(module: 'jackson-core')
@ -679,7 +687,7 @@ configure(project(':monitor')) {
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$jupiterVersion"
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jupiterVersion"
implementation "org.openjfx:javafx-base:$javafxVersion:$os"
implementation "org.openjfx:javafx-graphics:$javafxVersion:$os"
@ -725,6 +733,8 @@ configure(project(':seednode')) {
exclude(module: 'guava')
}
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jupiterVersion"
}
}
@ -908,7 +918,7 @@ configure(project(':apitest')) {
testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$jupiterVersion"
testRuntimeOnly "javax.annotation:javax.annotation-api:$javaxAnnotationVersion"
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jupiterVersion"
}
}

View File

@ -17,7 +17,7 @@
package haveno.common.app;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
@ -26,9 +26,9 @@ import java.util.HashSet;
import static haveno.common.app.Capability.SEED_NODE;
import static haveno.common.app.Capability.TRADE_STATISTICS;
import static haveno.common.app.Capability.TRADE_STATISTICS_2;
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;
public class CapabilitiesTest {

View File

@ -17,11 +17,11 @@
package haveno.common.app;
import org.junit.Test;
import org.junit.jupiter.api.Test;
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;
public class VersionTest {

View File

@ -1,16 +1,16 @@
package haveno.common.config;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
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;
public class ConfigFileEditorTests {
@ -19,7 +19,7 @@ public class ConfigFileEditorTests {
private ConfigFileReader reader;
private ConfigFileEditor editor;
@Before
@BeforeEach
public void setUp() throws IOException {
file = File.createTempFile("haveno", "properties");
reader = new ConfigFileReader(file);

View File

@ -1,6 +1,6 @@
package haveno.common.config;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

View File

@ -1,18 +1,16 @@
package haveno.common.config;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigFileReaderTests {
@ -20,10 +18,7 @@ public class ConfigFileReaderTests {
private PrintWriter writer;
private ConfigFileReader reader;
@Rule
public ExpectedException exception = ExpectedException.none();
@Before
@BeforeEach
public void setUp() throws IOException {
file = File.createTempFile("haveno", "properties");
reader = new ConfigFileReader(file);
@ -35,11 +30,12 @@ public class ConfigFileReaderTests {
writer.close();
assertTrue(file.delete());
exception.expect(ConfigException.class);
exception.expectMessage(containsString("Config file"));
exception.expectMessage(containsString("does not exist"));
Exception exception = assertThrows(ConfigException.class, () -> reader.getLines());
reader.getLines();
String expectedMessage = "does not exist";
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
@Test

View File

@ -1,8 +1,6 @@
package haveno.common.config;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -21,21 +19,22 @@ import static haveno.common.config.Config.DEFAULT_CONFIG_FILE_NAME;
import static haveno.common.config.Config.HELP;
import static haveno.common.config.Config.TORRC_FILE;
import static haveno.common.config.Config.USER_DATA_DIR;
import static java.io.File.createTempFile;
import static java.lang.String.format;
import static org.hamcrest.CoreMatchers.containsString;
import static java.lang.System.getProperty;
import static java.nio.file.Files.createTempDirectory;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.isEmptyString;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.hamcrest.Matchers.emptyString;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigTests {
@Rule
public ExpectedException exceptionRule = ExpectedException.none();
// Note: "DataDirProperties" in the test method names below represent the group of
// configuration options that influence the location of a Haveno node's data directory.
// These options include appName, userDataDir, appDataDir and configFile
@ -45,8 +44,8 @@ public class ConfigTests {
Config config = new Config();
String defaultAppName = config.defaultAppName;
String regex = "Haveno\\d{2,}Temp";
assertTrue(format("Temp app name '%s' failed to match '%s'", defaultAppName, regex),
defaultAppName.matches(regex));
assertTrue(defaultAppName.matches(regex),
format("Temp app name '%s' failed to match '%s'", defaultAppName, regex));
}
@Test
@ -76,7 +75,7 @@ public class ConfigTests {
@Test
public void whenAppDataDirOptionIsSet_thenDataDirPropertiesReflectItsValue() throws IOException {
File appDataDir = Files.createTempDirectory("myapp").toFile();
File appDataDir = createTempDirectory("myapp").toFile();
Config config = configWithOpts(opt(APP_DATA_DIR, appDataDir));
assertThat(config.appName, equalTo(config.defaultAppName));
assertThat(config.userDataDir, equalTo(config.defaultUserDataDir));
@ -86,7 +85,7 @@ public class ConfigTests {
@Test
public void whenUserDataDirOptionIsSet_thenDataDirPropertiesReflectItsValue() throws IOException {
File userDataDir = Files.createTempDirectory("myuserdata").toFile();
File userDataDir = createTempDirectory("myuserdata").toFile();
Config config = configWithOpts(opt(USER_DATA_DIR, userDataDir));
assertThat(config.appName, equalTo(config.defaultAppName));
assertThat(config.userDataDir, equalTo(userDataDir));
@ -96,7 +95,7 @@ public class ConfigTests {
@Test
public void whenAppNameAndAppDataDirOptionsAreSet_thenDataDirPropertiesReflectTheirValues() throws IOException {
File appDataDir = Files.createTempDirectory("myapp").toFile();
File appDataDir = createTempDirectory("myapp").toFile();
Config config = configWithOpts(opt(APP_NAME, "My-Haveno"), opt(APP_DATA_DIR, appDataDir));
assertThat(config.appName, equalTo("My-Haveno"));
assertThat(config.userDataDir, equalTo(config.defaultUserDataDir));
@ -106,7 +105,7 @@ public class ConfigTests {
@Test
public void whenOptionIsSetAtCommandLineAndInConfigFile_thenCommandLineValueTakesPrecedence() throws IOException {
File configFile = File.createTempFile("haveno", "properties");
File configFile = createTempFile("haveno", "properties");
try (PrintWriter writer = new PrintWriter(configFile)) {
writer.println(new ConfigFileOption(APP_NAME, "Haveno-configFileValue"));
}
@ -116,14 +115,17 @@ public class ConfigTests {
@Test
public void whenUnrecognizedOptionIsSet_thenConfigExceptionIsThrown() {
exceptionRule.expect(ConfigException.class);
exceptionRule.expectMessage("problem parsing option 'bogus': bogus is not a recognized option");
configWithOpts(opt("bogus"));
Exception exception = assertThrows(ConfigException.class, () -> configWithOpts(opt("bogus")));
String expectedMessage = "problem parsing option 'bogus': bogus is not a recognized option";
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
@Test
public void whenUnrecognizedOptionIsSetInConfigFile_thenNoExceptionIsThrown() throws IOException {
File configFile = File.createTempFile("haveno", "properties");
File configFile = createTempFile("haveno", "properties");
try (PrintWriter writer = new PrintWriter(configFile)) {
writer.println(new ConfigFileOption("bogusOption", "bogusValue"));
writer.println(new ConfigFileOption(APP_NAME, "HavenoTest"));
@ -134,40 +136,43 @@ public class ConfigTests {
@Test
public void whenOptionFileArgumentDoesNotExist_thenConfigExceptionIsThrown() {
String filepath = "/does/not/exist";
if (System.getProperty("os.name").startsWith("Windows")) {
filepath = "C:\\does\\not\\exist";
}
exceptionRule.expect(ConfigException.class);
exceptionRule.expectMessage(format("problem parsing option 'torrcFile': File [%s] does not exist", filepath));
configWithOpts(opt(TORRC_FILE, filepath));
String filepath = getProperty("os.name").startsWith("Windows") ? "C:\\does\\not\\exist" : "/does/not/exist";
Exception exception = assertThrows(ConfigException.class, () -> configWithOpts(opt(TORRC_FILE, filepath)));
String expectedMessage = format("problem parsing option 'torrcFile': File [%s] does not exist", filepath);
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
@Test
public void whenConfigFileOptionIsSetToNonExistentFile_thenConfigExceptionIsThrown() {
String filepath = "/no/such/haveno.properties";
if (System.getProperty("os.name").startsWith("Windows")) {
filepath = "C:\\no\\such\\haveno.properties";
}
exceptionRule.expect(ConfigException.class);
exceptionRule.expectMessage(format("The specified config file '%s' does not exist", filepath));
configWithOpts(opt(CONFIG_FILE, filepath));
String filepath = getProperty("os.name").startsWith("Windows") ? "C:\\no\\such\\haveno.properties" : "/no/such/haveno.properties";
Exception exception = assertThrows(ConfigException.class, () -> configWithOpts(opt(CONFIG_FILE, filepath)));
String expectedMessage = format("The specified config file '%s' does not exist", filepath);
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
@Test
public void whenConfigFileOptionIsSetInConfigFile_thenConfigExceptionIsThrown() throws IOException {
File configFile = File.createTempFile("haveno", "properties");
File configFile = createTempFile("haveno", "properties");
try (PrintWriter writer = new PrintWriter(configFile)) {
writer.println(new ConfigFileOption(CONFIG_FILE, "/tmp/other.haveno.properties"));
}
exceptionRule.expect(ConfigException.class);
exceptionRule.expectMessage(format("The '%s' option is disallowed in config files", CONFIG_FILE));
configWithOpts(opt(CONFIG_FILE, configFile.getAbsolutePath()));
Exception exception = assertThrows(ConfigException.class, () -> configWithOpts(opt(CONFIG_FILE, configFile.getAbsolutePath())));
String expectedMessage = format("The '%s' option is disallowed in config files", CONFIG_FILE);
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
@Test
public void whenConfigFileOptionIsSetToExistingFile_thenConfigFilePropertyReflectsItsValue() throws IOException {
File configFile = File.createTempFile("haveno", "properties");
File configFile = createTempFile("haveno", "properties");
Config config = configWithOpts(opt(CONFIG_FILE, configFile.getAbsolutePath()));
assertThat(config.configFile, equalTo(configFile));
}
@ -183,7 +188,7 @@ public class ConfigTests {
@Test
public void whenAppNameIsSetInConfigFile_thenDataDirPropertiesReflectItsValue() throws IOException {
File configFile = File.createTempFile("haveno", "properties");
File configFile = createTempFile("haveno", "properties");
try (PrintWriter writer = new PrintWriter(configFile)) {
writer.println(new ConfigFileOption(APP_NAME, "My-Haveno"));
}
@ -217,8 +222,8 @@ public class ConfigTests {
System.setOut(outTest);
System.setErr(errTest);
new Config();
assertThat(outBytes.toString(), isEmptyString());
assertThat(errBytes.toString(), isEmptyString());
assertThat(outBytes.toString(), is(emptyString()));
assertThat(errBytes.toString(), is(emptyString()));
} finally {
System.setOut(outOrig);
System.setErr(errOrig);
@ -236,18 +241,22 @@ public class ConfigTests {
}
@Test
public void whenAppDataDirCannotBeCreated_thenUncheckedIoExceptionIsThrown() throws IOException {
public void whenAppDataDirCannotBeCreatedThenUncheckedIoExceptionIsThrown() {
// set a userDataDir that is actually a file so appDataDir cannot be created
File aFile = Files.createTempFile("A", "File").toFile();
exceptionRule.expect(UncheckedIOException.class);
exceptionRule.expectMessage(containsString("Application data directory"));
exceptionRule.expectMessage(containsString("could not be created"));
configWithOpts(opt(USER_DATA_DIR, aFile));
Exception exception = assertThrows(UncheckedIOException.class, () -> {
File aFile = Files.createTempFile("A", "File").toFile();
configWithOpts(opt(USER_DATA_DIR, aFile));
});
String expectedMessage = "could not be created";
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
@Test
public void whenAppDataDirIsSymbolicLink_thenAppDataDirCreationIsNoOp() throws IOException {
Path parentDir = Files.createTempDirectory("parent");
Path parentDir = createTempDirectory("parent");
Path targetDir = parentDir.resolve("target");
Path symlink = parentDir.resolve("symlink");
Files.createDirectory(targetDir);

View File

@ -17,26 +17,27 @@
package haveno.common.util;
import org.junit.Test;
import org.junit.jupiter.api.Test;
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.assertThrows;
public class MathUtilsTest {
@Test(expected = IllegalArgumentException.class)
@Test
public void testRoundDoubleWithInfiniteArg() {
MathUtils.roundDouble(Double.POSITIVE_INFINITY, 2);
assertThrows(IllegalArgumentException.class, () -> MathUtils.roundDouble(Double.POSITIVE_INFINITY, 2));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testRoundDoubleWithNaNArg() {
MathUtils.roundDouble(Double.NaN, 2);
assertThrows(IllegalArgumentException.class, () ->MathUtils.roundDouble(Double.NaN, 2));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testRoundDoubleWithNegativePrecision() {
MathUtils.roundDouble(3, -1);
assertThrows(IllegalArgumentException.class, () ->MathUtils.roundDouble(3, -1));
}
@SuppressWarnings("OptionalGetWithoutIsPresent")

View File

@ -17,7 +17,7 @@
package haveno.common.util;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
@ -25,7 +25,7 @@ import java.util.Collections;
import java.util.List;
import java.util.function.BiPredicate;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class PermutationTest {

View File

@ -1,22 +1,20 @@
package haveno.common.util;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import static haveno.common.util.Preconditions.checkDir;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertSame;
import static java.lang.String.format;
import static java.lang.System.getProperty;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class PreconditionsTests {
@Rule
public ExpectedException exceptionRule = ExpectedException.none();
@Test
public void whenDirIsValid_thenDirIsReturned() throws IOException {
File dir = Files.createTempDirectory("TestDir").toFile();
@ -26,12 +24,12 @@ public class PreconditionsTests {
@Test
public void whenDirDoesNotExist_thenThrow() {
String filepath = "/does/not/exist";
if (System.getProperty("os.name").startsWith("Windows")) {
filepath = "C:\\does\\not\\exist";
}
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage(equalTo(String.format("Directory '%s' does not exist", filepath)));
checkDir(new File(filepath));
String filepath = getProperty("os.name").startsWith("Windows") ? "C:\\does\\not\\exist" : "/does/not/exist";
Exception exception = assertThrows(IllegalArgumentException.class, () -> checkDir(new File(filepath)));
String expectedMessage = format("Directory '%s' does not exist", filepath);
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
}

View File

@ -17,10 +17,10 @@
package haveno.common.util;
import org.junit.Test;
import org.junit.jupiter.api.Test;
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 UtilitiesTest {

View File

@ -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);

View File

@ -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());

View File

@ -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};

View File

@ -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 {

View File

@ -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);

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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"));

View File

@ -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

View File

@ -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 {

View File

@ -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."
);
}
}

View File

@ -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)));
}
}

View File

@ -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 {

View File

@ -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;

View File

@ -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();

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -17,7 +17,7 @@
package haveno.core.payment;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TradeLimitsTest {
@Test

View File

@ -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 {

View File

@ -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());
}
});
}

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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");

View File

@ -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"));

View File

@ -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();
}

View File

@ -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"));

View File

@ -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."
);
}
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -20,10 +20,10 @@ package haveno.daemon.grpc.interceptor;
import haveno.daemon.grpc.GrpcVersionService;
import io.grpc.ServerInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.nio.file.Paths;
@ -49,7 +49,7 @@ public class GrpcServiceRateMeteringConfigTest {
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
private static Optional<ServerInterceptor> versionServiceInterceptor;
@BeforeClass
@BeforeAll
public static void setup() {
// This is the tested rate meter, it allows 3 calls every 2 seconds.
builder.addCallRateMeter(GrpcVersionService.class.getSimpleName(),
@ -77,7 +77,7 @@ public class GrpcServiceRateMeteringConfigTest {
HOURS);
}
@Before
@BeforeEach
public void buildConfigFile() {
if (configFile == null)
configFile = builder.build();
@ -157,7 +157,7 @@ public class GrpcServiceRateMeteringConfigTest {
assertEquals(expectedCallsCount, rateMeter.getCallsCount());
}
@AfterClass
@AfterAll
public static void teardown() {
if (configFile != null)
configFile.deleteOnExit();

View File

@ -55,18 +55,18 @@ import haveno.desktop.main.presentation.MarketPricePresentation;
import haveno.desktop.util.Transitions;
import haveno.network.p2p.network.BridgeAddressProvider;
import haveno.network.p2p.seed.SeedNodeRepository;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static junit.framework.TestCase.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class GuiceSetupTest {
private Injector injector;
@Before
@BeforeEach
public void setUp() {
Res.setup();
CurrencyUtil.setup();

View File

@ -24,30 +24,28 @@ import haveno.desktop.common.view.View;
import haveno.desktop.common.view.ViewFactory;
import haveno.desktop.common.view.ViewLoader;
import javafx.fxml.LoadException;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.util.ResourceBundle;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
// TODO Some refactorings seem to have broken those tests. Investigate and remove @Ignore as soon its fixed.
@Ignore
// TODO Some refactorings seem to have broken those tests. Investigate and remove @Disabled as soon its fixed.
@Disabled
public class FxmlViewLoaderTests {
private ViewLoader viewLoader;
private ViewFactory viewFactory;
@Rule
public ExpectedException thrown = ExpectedException.none();
@Before
@BeforeEach
public void setUp() {
viewFactory = mock(ViewFactory.class);
ResourceBundle resourceBundle = mock(ResourceBundle.class);
@ -73,9 +71,8 @@ public class FxmlViewLoaderTests {
@Test
public void fxmlFileMissingFxControllerAttributeShouldThrow() {
thrown.expect(ViewfxException.class);
thrown.expectMessage("Does it declare an fx:controller attribute?");
viewLoader.load(MissingFxController.class);
Throwable exception = assertThrows(ViewfxException.class, () -> viewLoader.load(MissingFxController.class));
assertEquals("Does it declare an fx:controller attribute?", exception.getMessage());
}
@ -96,10 +93,9 @@ public class FxmlViewLoaderTests {
@Test
public void malformedFxmlFileShouldThrow() {
thrown.expect(ViewfxException.class);
thrown.expectMessage("Failed to load view from FXML file");
thrown.expectCause(instanceOf(LoadException.class));
viewLoader.load(Malformed.class);
Throwable exception = assertThrows(ViewfxException.class, () -> viewLoader.load(Malformed.class));
assertTrue(exception.getCause() instanceof LoadException);
assertEquals("Failed to load view from FXML file", exception.getMessage());
}
@ -109,9 +105,8 @@ public class FxmlViewLoaderTests {
@Test
public void missingFxmlFileShouldThrow() {
thrown.expect(ViewfxException.class);
thrown.expectMessage("Does it exist?");
viewLoader.load(MissingFxmlFile.class);
Throwable exception = assertThrows(ViewfxException.class, () -> viewLoader.load(MissingFxmlFile.class));
assertEquals("Does it exist?", exception.getMessage());
}
@ -121,11 +116,10 @@ public class FxmlViewLoaderTests {
@Test
public void customFxmlFileLocationShouldOverrideDefaultConvention() {
thrown.expect(ViewfxException.class);
thrown.expectMessage("Failed to load view class");
thrown.expectMessage("CustomLocation");
thrown.expectMessage("[unconventionally/located.fxml] could not be loaded");
viewLoader.load(CustomLocation.class);
Throwable exception = assertThrows(ViewfxException.class, () -> viewLoader.load(CustomLocation.class));
assertTrue(exception.getMessage().contains("Failed to load view class"));
assertTrue(exception.getMessage().contains("CustomLocation"));
assertTrue(exception.getMessage().contains("[unconventionally/located.fxml] could not be loaded"));
}
}

View File

@ -20,7 +20,7 @@ package haveno.desktop.common.support;
import haveno.desktop.common.view.AbstractView;
import haveno.desktop.common.view.CachingViewLoader;
import haveno.desktop.common.view.ViewLoader;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;

View File

@ -19,13 +19,13 @@ package haveno.desktop.components;
import javafx.scene.control.Label;
import javafx.scene.text.Text;
import org.junit.Ignore;
import org.junit.jupiter.api.Disabled;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ColoredDecimalPlacesWithZerosTextTest {
@Ignore
@Disabled
public void testOnlyZeroDecimals() {
ColoredDecimalPlacesWithZerosText text = new ColoredDecimalPlacesWithZerosText("1.0000", 3);
Label beforeZeros = (Label) text.getChildren().get(0);
@ -34,7 +34,7 @@ public class ColoredDecimalPlacesWithZerosTextTest {
assertEquals("000", zeroDecimals.getText());
}
@Ignore
@Disabled
public void testOneZeroDecimal() {
ColoredDecimalPlacesWithZerosText text = new ColoredDecimalPlacesWithZerosText("1.2570", 3);
Text beforeZeros = (Text) text.getChildren().get(0);
@ -43,7 +43,7 @@ public class ColoredDecimalPlacesWithZerosTextTest {
assertEquals("0", zeroDecimals.getText());
}
@Ignore
@Disabled
public void testMultipleZeroDecimal() {
ColoredDecimalPlacesWithZerosText text = new ColoredDecimalPlacesWithZerosText("1.2000", 3);
Text beforeZeros = (Text) text.getChildren().get(0);
@ -52,7 +52,7 @@ public class ColoredDecimalPlacesWithZerosTextTest {
assertEquals("000", zeroDecimals.getText());
}
@Ignore
@Disabled
public void testZeroDecimalsWithRange() {
ColoredDecimalPlacesWithZerosText text = new ColoredDecimalPlacesWithZerosText("0.1000 - 0.1250", 3);
assertEquals(5, text.getChildren().size());
@ -68,7 +68,7 @@ public class ColoredDecimalPlacesWithZerosTextTest {
assertEquals("0", zeroDecimals2.getText());
}
@Ignore
@Disabled
public void testNoColorizing() {
ColoredDecimalPlacesWithZerosText text = new ColoredDecimalPlacesWithZerosText("1.2570", 0);
Text beforeZeros = (Text) text.getChildren().get(0);

View File

@ -21,12 +21,12 @@ import com.google.common.collect.Lists;
import haveno.core.xmr.wallet.XmrWalletService;
import javafx.collections.FXCollections;
import monero.wallet.model.MoneroTxWallet;
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.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;

View File

@ -18,12 +18,12 @@
package haveno.desktop.main.funds.transactions;
import com.google.common.collect.Lists;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.function.Supplier;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

View File

@ -22,9 +22,9 @@ import haveno.core.support.dispute.arbitration.ArbitrationManager;
import haveno.core.trade.Tradable;
import haveno.core.trade.Trade;
import monero.wallet.model.MoneroTxWallet;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.mock;
public class TransactionAwareTradableFactoryTest {

View File

@ -25,12 +25,12 @@ import haveno.core.xmr.wallet.XmrWalletService;
import javafx.collections.FXCollections;
import monero.wallet.model.MoneroTxWallet;
import org.bitcoinj.core.Sha256Hash;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Set;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ -45,7 +45,7 @@ public class TransactionAwareTradeTest {
private RefundManager refundManager;
private XmrWalletService xmrWalletService;
@Before
@BeforeEach
public void setUp() {
this.transaction = mock(MoneroTxWallet.class);
when(transaction.getHash()).thenReturn(XID.toString());

View File

@ -25,8 +25,8 @@ import haveno.desktop.main.offer.offerbook.OfferBookListItemMaker;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.collections.FXCollections;
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 static com.natpryce.makeiteasy.MakeItEasy.make;
import static com.natpryce.makeiteasy.MakeItEasy.with;
@ -34,14 +34,14 @@ import static haveno.desktop.main.offer.offerbook.OfferBookListItemMaker.xmrBuyI
import static haveno.desktop.main.offer.offerbook.OfferBookListItemMaker.xmrSellItem;
import static haveno.desktop.maker.PreferenceMakers.empty;
import static haveno.desktop.maker.TradeCurrencyMakers.usd;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class OfferBookChartViewModelTest {
@Before
@BeforeEach
public void setUp() {
GlobalSettings.setDefaultTradeCurrency(usd);
}

View File

@ -27,14 +27,14 @@ import haveno.desktop.main.offer.offerbook.OfferBookListItem;
import haveno.desktop.main.offer.offerbook.OfferBookListItemMaker;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static com.natpryce.makeiteasy.MakeItEasy.make;
import static com.natpryce.makeiteasy.MakeItEasy.with;
import static haveno.desktop.main.offer.offerbook.OfferBookListItemMaker.id;
import static haveno.desktop.main.offer.offerbook.OfferBookListItemMaker.xmrBuyItem;
import static haveno.desktop.main.offer.offerbook.OfferBookListItemMaker.xmrSellItem;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

View File

@ -32,9 +32,9 @@ import javafx.collections.ObservableSet;
import javafx.util.Pair;
import org.bitcoinj.core.Coin;
import org.bitcoinj.utils.Fiat;
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;
@ -47,7 +47,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
public class TradesChartsViewModelTest {
@ -94,7 +94,7 @@ public class TradesChartsViewModelTest {
null,
null);
@Before
@BeforeEach
public void setup() throws IOException {
tradeStatisticsManager = mock(TradeStatisticsManager.class);
model = new TradesChartsViewModel(tradeStatisticsManager, mock(Preferences.class), mock(PriceFeedService.class),
@ -177,7 +177,7 @@ public class TradesChartsViewModelTest {
}
// TODO JMOCKIT
@Ignore
@Disabled
@Test
public void testItemLists() throws ParseException {
// Helper class to add historic trades

View File

@ -17,13 +17,13 @@ import haveno.core.user.User;
import haveno.core.xmr.model.XmrAddressEntry;
import haveno.core.xmr.wallet.XmrWalletService;
import javafx.collections.FXCollections;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.UUID;
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;
@ -36,7 +36,7 @@ public class CreateOfferDataModelTest {
private Preferences preferences;
private OfferUtil offerUtil;
@Before
@BeforeEach
public void setUp() {
final CryptoCurrency xmr = new CryptoCurrency("XMR", "monero");
GlobalSettings.setDefaultTradeCurrency(xmr);

View File

@ -44,16 +44,16 @@ import haveno.core.xmr.model.XmrAddressEntry;
import haveno.core.xmr.wallet.XmrWalletService;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.collections.FXCollections;
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.time.Instant;
import java.util.UUID;
import static haveno.desktop.maker.PreferenceMakers.empty;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
@ -65,7 +65,7 @@ public class CreateOfferViewModelTest {
private final CoinFormatter coinFormatter = new ImmutableCoinFormatter(
Config.baseCurrencyNetworkParameters().getMonetaryFormat());
@Before
@BeforeEach
public void setUp() {
final CryptoCurrency btc = new CryptoCurrency("XMR", "monero");
GlobalSettings.setDefaultTradeCurrency(btc);

View File

@ -51,9 +51,9 @@ import haveno.core.util.coin.ImmutableCoinFormatter;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -73,10 +73,10 @@ import static haveno.desktop.main.offer.offerbook.OfferBookListItemMaker.xmrBuyI
import static haveno.desktop.main.offer.offerbook.OfferBookListItemMaker.xmrItemWithRange;
import static haveno.desktop.maker.PreferenceMakers.empty;
import static haveno.desktop.maker.TradeCurrencyMakers.usd;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
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.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
@ -87,7 +87,7 @@ public class OfferBookViewModelTest {
private static final Logger log = LoggerFactory.getLogger(OfferBookViewModelTest.class);
private User user;
@Before
@BeforeEach
public void setUp() {
GlobalSettings.setDefaultTradeCurrency(usd);
Res.setBaseCurrencyCode(usd.getCode());
@ -103,7 +103,7 @@ public class OfferBookViewModelTest {
return new PriceUtil(priceFeedService, tradeStatisticsManager, empty);
}
@Ignore("PaymentAccountPayload needs to be set (has been changed with PB changes)")
@Disabled("PaymentAccountPayload needs to be set (has been changed with PB changes)")
public void testIsAnyPaymentAccountValidForOffer() {
Collection<PaymentAccount> paymentAccounts;
paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSepaAccount("EUR", "DE", "1212324",

View File

@ -17,7 +17,9 @@
package haveno.desktop.main.overlays;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class OverlayTest {
@ -28,9 +30,9 @@ public class OverlayTest {
new D<>();
}
@Test(expected = RuntimeException.class)
@Test
public void typeUnsafeCreation() {
new B();
assertThrows(RuntimeException.class, () -> new B());
}
private static class A extends Overlay<A> {

View File

@ -20,13 +20,13 @@ package haveno.desktop.main.overlays.windows.downloadupdate;
import com.google.common.collect.Lists;
import haveno.desktop.main.overlays.windows.downloadupdate.HavenoInstaller.FileDescriptor;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.net.URL;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
@Slf4j
public class HavenoInstallerTest {

View File

@ -17,7 +17,7 @@
package haveno.desktop.main.overlays.windows.downloadupdate;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class VerifyTaskTest {

View File

@ -26,12 +26,12 @@ import haveno.desktop.maker.PreferenceMakers;
import haveno.network.p2p.NodeAddress;
import javafx.collections.FXCollections;
import javafx.collections.ObservableMap;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
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;

View File

@ -22,15 +22,15 @@ import haveno.core.locale.CryptoCurrency;
import haveno.core.locale.FiatCurrency;
import haveno.core.locale.TradeCurrency;
import haveno.core.user.Preferences;
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.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ -46,7 +46,7 @@ public class CurrencyListTest {
private List<CurrencyListItem> delegate;
private CurrencyList testedEntity;
@Before
@BeforeEach
public void setUp() {
Locale.setDefault(locale);

View File

@ -9,8 +9,8 @@ import haveno.core.offer.OfferPayload;
import haveno.core.util.VolumeUtil;
import haveno.core.util.coin.CoinFormatter;
import haveno.core.util.coin.ImmutableCoinFormatter;
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.util.Locale;
@ -21,14 +21,14 @@ import static com.natpryce.makeiteasy.MakeItEasy.with;
import static haveno.desktop.maker.OfferMaker.xmrUsdOffer;
import static haveno.desktop.maker.VolumeMaker.usdVolume;
import static haveno.desktop.maker.VolumeMaker.volumeString;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class DisplayUtilsTest {
private final CoinFormatter formatter = new ImmutableCoinFormatter(Config.baseCurrencyNetworkParameters().getMonetaryFormat());
@Before
@BeforeEach
public void setUp() {
Locale.setDefault(Locale.US);
GlobalSettings.setLocale(Locale.US);

View File

@ -24,8 +24,8 @@ import haveno.core.trade.HavenoUtils;
import haveno.core.user.DontShowAgainLookup;
import haveno.core.user.Preferences;
import javafx.util.StringConverter;
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.util.HashMap;
@ -34,14 +34,14 @@ import java.util.Map;
import static haveno.desktop.maker.TradeCurrencyMakers.euro;
import static haveno.desktop.maker.TradeCurrencyMakers.monero;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class GUIUtilTest {
@Before
@BeforeEach
public void setup() {
Locale.setDefault(new Locale("en", "US"));
GlobalSettings.setLocale(new Locale("en", "US"));

View File

@ -22,8 +22,8 @@ import haveno.core.locale.Res;
import haveno.core.util.coin.CoinFormatter;
import haveno.core.util.coin.ImmutableCoinFormatter;
import org.bitcoinj.core.CoinMaker;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Locale;
@ -32,13 +32,13 @@ import static com.natpryce.makeiteasy.MakeItEasy.make;
import static com.natpryce.makeiteasy.MakeItEasy.with;
import static org.bitcoinj.core.CoinMaker.oneBitcoin;
import static org.bitcoinj.core.CoinMaker.satoshis;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ImmutableCoinFormatterTest {
private final CoinFormatter formatter = new ImmutableCoinFormatter(Config.baseCurrencyNetworkParameters().getMonetaryFormat());
@Before
@BeforeEach
public void setUp() {
Locale.setDefault(new Locale("en", "US"));
Res.setBaseCurrencyCode("XMR");

View File

@ -17,12 +17,14 @@
package haveno.desktop.util;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class MovingAverageUtilsTest {
private static final int NAN = -99;
@ -50,7 +52,7 @@ public class MovingAverageUtilsTest {
private static void testMA(int period, int[] input, int[] expected) {
var output = calcMA(period, input);
Assert.assertArrayEquals(output, expected);
assertArrayEquals(output, expected);
}
@Test
@ -107,24 +109,28 @@ public class MovingAverageUtilsTest {
);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void nonsensicalPeriod1() {
var impossible = new int[]{};
testMA(
0,
new int[]{10, 20},
impossible
);
assertThrows(IllegalArgumentException.class, () -> {
var impossible = new int[]{};
testMA(
0,
new int[]{10, 20},
impossible
);
});
}
@Test(expected = IllegalArgumentException.class)
@Test
public void nonsensicalPeriod2() {
var impossible = new int[]{};
testMA(
-1,
new int[]{10, 20},
impossible
);
assertThrows(IllegalArgumentException.class, () -> {
var impossible = new int[]{};
testMA(
-1,
new int[]{10, 20},
impossible
);
});
}
@Test

View File

@ -2,16 +2,16 @@ package haveno.desktop.util.validation;
import haveno.core.locale.Res;
import haveno.core.payment.validation.AccountNrValidator;
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.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class AccountNrValidatorTest {
@Before
@BeforeEach
public void setup() {
Locale.setDefault(new Locale("en", "US"));
Res.setBaseCurrencyCode("XMR");

View File

@ -7,14 +7,14 @@ import haveno.core.locale.Res;
import haveno.core.payment.validation.AdvancedCashValidator;
import haveno.core.payment.validation.EmailValidator;
import haveno.core.util.validation.RegexValidator;
import org.junit.Before;
import org.junit.Test;
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;
public class AdvancedCashValidatorTest {
@Before
@BeforeEach
public void setup() {
final BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();

View File

@ -2,17 +2,17 @@ package haveno.desktop.util.validation;
import haveno.core.locale.Res;
import haveno.core.payment.validation.BranchIdValidator;
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 BranchIdValidatorTest {
@Before
@BeforeEach
public void setup() {
Locale.setDefault(new Locale("en", "US"));
Res.setBaseCurrencyCode("XMR");

View File

@ -6,14 +6,14 @@ import haveno.core.locale.CurrencyUtil;
import haveno.core.locale.Res;
import haveno.core.payment.validation.CapitualValidator;
import haveno.core.util.validation.RegexValidator;
import org.junit.Before;
import org.junit.Test;
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;
public class CapitualValidatorTest {
@Before
@BeforeEach
public void setup() {
final BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();

View File

@ -22,15 +22,15 @@ import haveno.common.config.Config;
import haveno.core.locale.CurrencyUtil;
import haveno.core.locale.Res;
import haveno.core.payment.validation.FiatVolumeValidator;
import org.junit.Before;
import org.junit.Test;
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;
public class FiatVolumeValidatorTest {
@Before
@BeforeEach
public void setup() {
final BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();

View File

@ -24,15 +24,15 @@ import haveno.core.locale.Res;
import haveno.core.payment.validation.InteracETransferAnswerValidator;
import haveno.core.payment.validation.LengthValidator;
import haveno.core.util.validation.RegexValidator;
import org.junit.Before;
import org.junit.Test;
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;
public class InteracETransferAnswerValidatorTest {
@Before
@BeforeEach
public void setup() {
final BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();

View File

@ -24,15 +24,15 @@ import haveno.core.locale.Res;
import haveno.core.payment.validation.InteracETransferQuestionValidator;
import haveno.core.payment.validation.LengthValidator;
import haveno.core.util.validation.RegexValidator;
import org.junit.Before;
import org.junit.Test;
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;
public class InteracETransferQuestionValidatorTest {
@Before
@BeforeEach
public void setup() {
final BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();

View File

@ -27,15 +27,15 @@ import haveno.core.payment.validation.InteracETransferQuestionValidator;
import haveno.core.payment.validation.InteracETransferValidator;
import haveno.core.payment.validation.LengthValidator;
import haveno.core.util.validation.RegexValidator;
import org.junit.Before;
import org.junit.Test;
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;
public class InteracETransferValidatorTest {
@Before
@BeforeEach
public void setup() {
final BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();

View File

@ -22,15 +22,15 @@ import haveno.common.config.Config;
import haveno.core.locale.CurrencyUtil;
import haveno.core.locale.Res;
import haveno.core.payment.validation.LengthValidator;
import org.junit.Before;
import org.junit.Test;
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;
public class LengthValidatorTest {
@Before
@BeforeEach
public void setup() {
final BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();

View File

@ -2,17 +2,17 @@ package haveno.desktop.util.validation;
import haveno.core.locale.Res;
import haveno.core.payment.validation.NationalAccountIdValidator;
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.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;
public class NationalAccountIdValidatorTest {
@Before
@BeforeEach
public void setup() {
Locale.setDefault(new Locale("en", "US"));
Res.setBaseCurrencyCode("XMR");

View File

@ -3,19 +3,19 @@ package haveno.desktop.util.validation;
import haveno.core.locale.Res;
import haveno.core.payment.validation.PhoneNumberValidator;
import haveno.core.util.validation.InputValidator.ValidationResult;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
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.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class PhoneNumberValidatorTest {
private PhoneNumberValidator validator;
private ValidationResult validationResult;
@Before
@BeforeEach
public void setup() {
Res.setup();
}
@ -24,7 +24,7 @@ public class PhoneNumberValidatorTest {
public void testMissingCountryCode() {
validator = new PhoneNumberValidator();
validationResult = validator.validate("+12124567890");
assertFalse("Should not be valid if validator's country code is missing", validationResult.isValid);
assertFalse(validationResult.isValid, "Should not be valid if validator's country code is missing");
assertEquals(Res.get("validation.phone.missingCountryCode"), validationResult.errorMessage);
assertNull(validator.getNormalizedPhoneNumber());
}
@ -33,12 +33,12 @@ public class PhoneNumberValidatorTest {
public void testNoInput() {
validator = new PhoneNumberValidator("AT");
validationResult = validator.validate("");
assertFalse("'' should not be a valid number in AT", validationResult.isValid);
assertFalse(validationResult.isValid, "'' should not be a valid number in AT");
assertEquals(Res.get("validation.empty"), validationResult.errorMessage);
assertNull(validator.getNormalizedPhoneNumber());
validationResult = validator.validate(null);
assertFalse("'' should not be a valid number in AT", validationResult.isValid);
assertFalse(validationResult.isValid, "'' should not be a valid number in AT");
assertEquals(Res.get("validation.empty"), validationResult.errorMessage);
assertNull(validator.getNormalizedPhoneNumber());
}
@ -69,12 +69,12 @@ public class PhoneNumberValidatorTest {
public void testInvalidAustriaNumbers() {
validator = new PhoneNumberValidator("AT"); // AT country code is +43
validationResult = validator.validate("+43 1 214");
assertFalse("+43 1 214 should not be a valid number in AT", validationResult.isValid);
assertFalse(validationResult.isValid, "+43 1 214 should not be a valid number in AT");
assertEquals(Res.get("validation.phone.insufficientDigits", "+43 1 214"), validationResult.errorMessage);
assertNull(validator.getNormalizedPhoneNumber());
validationResult = validator.validate("+42 1 650 454 0987");
assertFalse("+42 1 650 454 0987 should not be a valid number in AT", validationResult.isValid);
assertFalse(validationResult.isValid, "+42 1 650 454 0987 should not be a valid number in AT");
assertEquals(Res.get("validation.phone.invalidDialingCode", "+42 1 650 454 0987", "AT", validator.getCallingCode()),
validationResult.errorMessage);
assertNull(validator.getNormalizedPhoneNumber());
@ -136,7 +136,7 @@ public class PhoneNumberValidatorTest {
public void testInvalidCanadaNumber() {
validator = new PhoneNumberValidator("CA");
validationResult = validator.validate("+2 1 650 454 0987");
assertFalse("+2 1 650 454 0987 should not be a valid number in CA", validationResult.isValid);
assertFalse(validationResult.isValid, "+2 1 650 454 0987 should not be a valid number in CA");
assertEquals(Res.get("validation.phone.invalidDialingCode", "+2 1 650 454 0987", "CA", validator.getCallingCode()),
validationResult.errorMessage);
assertNull(validator.getNormalizedPhoneNumber());
@ -263,13 +263,13 @@ public class PhoneNumberValidatorTest {
public void testInvalidUSNumbers() {
validator = new PhoneNumberValidator("US");
validationResult = validator.validate("+1 512 GR8 0150");
assertFalse("+1 512 GR8 0150 should not be a valid number in US", validationResult.isValid);
assertFalse(validationResult.isValid, "+1 512 GR8 0150 should not be a valid number in US");
assertEquals(Res.get("validation.phone.invalidCharacters", "+1 512 GR8 0150", "US", validator.getCallingCode()),
validationResult.errorMessage);
assertNull(validator.getNormalizedPhoneNumber());
validationResult = validator.validate("+1 212-3456-0150-9832");
assertFalse("+1 212-3456-0150-9832 should not be a valid number in US", validationResult.isValid);
assertFalse(validationResult.isValid, "+1 212-3456-0150-9832 should not be a valid number in US");
assertEquals(Res.get("validation.phone.tooManyDigits", "+1 212-3456-0150-9832", "US", validator.getCallingCode()),
validationResult.errorMessage);
assertNull(validator.getNormalizedPhoneNumber());

View File

@ -22,15 +22,15 @@ import haveno.common.config.Config;
import haveno.core.locale.CurrencyUtil;
import haveno.core.locale.Res;
import haveno.core.util.validation.RegexValidator;
import org.junit.Before;
import org.junit.Test;
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;
public class RegexValidatorTest {
@Before
@BeforeEach
public void setup() {
final BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();

View File

@ -23,15 +23,15 @@ import haveno.core.locale.CurrencyUtil;
import haveno.core.locale.Res;
import haveno.core.payment.validation.XmrValidator;
import haveno.core.trade.HavenoUtils;
import org.junit.Before;
import org.junit.Test;
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;
public class XmrValidatorTest {
@Before
@BeforeEach
public void setup() {
final BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();

View File

@ -2578,6 +2578,11 @@
<sha256 value="a0f823d513c8d4692935f24c2fe6e77cc4a7b6147a9e8a518f722e50bbf86138" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.jupiter" name="junit-jupiter-api" version="5.9.2">
<artifact name="junit-jupiter-api-5.9.2.jar">
<sha256 value="f767a170f97127b0ad3582bf3358eabbbbe981d9f96411853e629d9276926fd5" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.jupiter" name="junit-jupiter-engine" version="5.7.0">
<artifact name="junit-jupiter-engine-5.7.0.jar">
<sha256 value="dfa26af94644ac2612dde6625852fcb550a0d21caa243257de54cba738ba87af" origin="Generated by Gradle"/>
@ -2586,6 +2591,11 @@
<sha256 value="b702e250875d331ee3c6b88f37299fbe951f43992f4b2e4a8f144e2e4cf2c7e8" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.jupiter" name="junit-jupiter-engine" version="5.9.2">
<artifact name="junit-jupiter-engine-5.9.2.jar">
<sha256 value="74cfc49388f760413ff348ca2c9ab39527484b57deecd157f2275a5f8a5fe971" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.jupiter" name="junit-jupiter-params" version="5.7.0">
<artifact name="junit-jupiter-params-5.7.0.jar">
<sha256 value="ca9f555c37b9bf79effd2e834af549e4feb52ad8ac9e348fe5b430d4d8a482b7" origin="Generated by Gradle"/>
@ -2594,6 +2604,11 @@
<sha256 value="23873e305a9751109839ad08b6b37dfadd1036f43b359b3b1b7bd2601fc73260" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.jupiter" name="junit-jupiter-params" version="5.9.2">
<artifact name="junit-jupiter-params-5.9.2.jar">
<sha256 value="bde91900a5ce5d6663bb44bc708494b35daefcd73e1bb7afa61a4affe38ea97d" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.platform" name="junit-platform-commons" version="1.7.0">
<artifact name="junit-platform-commons-1.7.0.jar">
<sha256 value="5330ee87cc7586e6e25175a34e9251624ff12ff525269d3415d0b4ca519b6fea" origin="Generated by Gradle"/>
@ -2610,6 +2625,11 @@
<sha256 value="ce852e34c6a184aa6c80ee8df0471713a7408134134f08e3c1c3dd87c6b59ab7" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.platform" name="junit-platform-commons" version="1.9.2">
<artifact name="junit-platform-commons-1.9.2.jar">
<sha256 value="624a3d745ef1d28e955a6a67af8edba0fdfc5c9bad680a73f67a70bb950a683d" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.platform" name="junit-platform-engine" version="1.7.0">
<artifact name="junit-platform-engine-1.7.0.jar">
<sha256 value="75f21a20dc594afdc875736725b408cec6d0344874d29f34b2dd3075500236f2" origin="Generated by Gradle"/>
@ -2626,6 +2646,11 @@
<sha256 value="0168643266060ed928ef5a81823003ecfae79a9a8c0bbfd76f4201c6c9d771c5" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.platform" name="junit-platform-engine" version="1.9.2">
<artifact name="junit-platform-engine-1.9.2.jar">
<sha256 value="25f23dc535a091e9dc80c008faf29dcb92be902e6911f77a736fbaf019908367" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.knowm.xchange" name="xchange-binance" version="4.4.2">
<artifact name="xchange-binance-4.4.2.jar">
<sha256 value="751a8cb76d75613ed38440a1a69e3a053e3cf869882b89eb8978b51c497111bb" origin="Generated by Gradle"/>

View File

@ -22,10 +22,8 @@ import haveno.common.crypto.KeyRing;
import haveno.common.crypto.KeyStorage;
import haveno.common.file.FileUtil;
import haveno.common.proto.network.NetworkEnvelope;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -38,13 +36,10 @@ import java.security.cert.CertificateException;
public class EncryptionServiceTests {
private static final Logger log = LoggerFactory.getLogger(EncryptionServiceTests.class);
@Rule
public ExpectedException thrown = ExpectedException.none();
private KeyRing keyRing;
private File dir;
@Before
@BeforeEach
public void setup() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, CryptoException {
dir = File.createTempFile("temp_tests", "");
@ -56,7 +51,7 @@ public class EncryptionServiceTests {
keyRing = new KeyRing(keyStorage, null, true);
}
@After
@AfterEach
public void tearDown() throws IOException {
FileUtil.deleteDirectory(dir);
}

View File

@ -18,10 +18,10 @@
package haveno.network.p2p;
import haveno.network.p2p.network.LocalhostNetworkNode;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -40,7 +40,7 @@ import java.util.concurrent.CountDownLatch;
// TODO deactivated because outdated
@SuppressWarnings({"UnusedAssignment", "EmptyMethod"})
@Ignore
@Disabled
public class PeerServiceTest {
private static final Logger log = LoggerFactory.getLogger(PeerServiceTest.class);
private static final int MAX_CONNECTIONS = 100;
@ -53,7 +53,7 @@ public class PeerServiceTest {
private final List<DummySeedNode> seedNodes = new ArrayList<>();
private final String test_dummy_dir = "test_dummy_dir";
@Before
@BeforeEach
public void setup() throws InterruptedException {
LocalhostNetworkNode.setSimulateTorDelayTorNode(50);
LocalhostNetworkNode.setSimulateTorDelayHiddenService(8);
@ -73,7 +73,7 @@ public class PeerServiceTest {
}
}
@After
@AfterEach
public void tearDown() throws InterruptedException {
Thread.sleep(sleepTime);

View File

@ -18,8 +18,8 @@
package haveno.network.p2p.network;
import haveno.network.p2p.TestUtils;
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;
@ -31,7 +31,7 @@ import java.util.concurrent.CountDownLatch;
// Connection establishment takes about 4 sec.
//TODO P2P network tests are outdated
@Ignore
@Disabled
public class LocalhostNetworkNodeTest {
private static final Logger log = LoggerFactory.getLogger(LocalhostNetworkNodeTest.class);

View File

@ -24,8 +24,8 @@ import com.google.common.util.concurrent.SettableFuture;
import haveno.network.p2p.TestUtils;
import haveno.network.p2p.mocks.MockPayload;
import org.jetbrains.annotations.NotNull;
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;
@ -40,7 +40,7 @@ import java.util.concurrent.CountDownLatch;
// Connection establishment takes about 4 sec.
//TODO P2P network tests are outdated
@SuppressWarnings("ConstantConditions")
@Ignore
@Disabled
public class TorNetworkNodeTest {
private static final Logger log = LoggerFactory.getLogger(TorNetworkNodeTest.class);
private CountDownLatch latch;

View File

@ -22,19 +22,19 @@ import haveno.network.p2p.network.CloseConnectionReason;
import haveno.network.p2p.network.Connection;
import haveno.network.p2p.network.InboundConnection;
import haveno.network.p2p.network.PeerType;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
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.isA;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.never;
@ -46,14 +46,14 @@ public class PeerManagerTest {
private int maxConnectionsPeer;
private int maxConnectionsNonDirect;
@Before
@BeforeEach
public void setUp() throws IOException {
node = new MockNode(2);
maxConnectionsPeer = Math.max(4, (int) Math.round(node.getMaxConnections() * 1.3));
maxConnectionsNonDirect = Math.max(8, (int) Math.round(node.getMaxConnections() * 1.7));
}
@After
@AfterEach
public void tearDown() {
node.getPersistenceManager().shutdown();
}
@ -151,7 +151,7 @@ public class PeerManagerTest {
}
@Test
@Ignore
@Disabled
public void testCheckMaxConnectionsNonDirectLimitExceeded() throws InterruptedException {
for (int i = 0; i < maxConnectionsNonDirect + 1; i++) {
node.addOutboundConnection(PeerType.INITIAL_DATA_EXCHANGE);

View File

@ -33,9 +33,8 @@ import haveno.network.p2p.storage.payload.CapabilityRequiringPayload;
import haveno.network.p2p.storage.payload.PersistableNetworkPayload;
import haveno.network.p2p.storage.payload.ProtectedStorageEntry;
import haveno.network.p2p.storage.payload.ProtectedStoragePayload;
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 org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@ -46,6 +45,9 @@ import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
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;
@ -63,7 +65,7 @@ public class P2PDataStorageBuildGetDataResponseTest {
private NodeAddress localNodeAddress;
@Before
@BeforeEach
public void setUp() {
MockitoAnnotations.initMocks(this);
this.testState = new TestState();
@ -144,13 +146,13 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 1, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertFalse(outPNPTruncated.get());
Assert.assertFalse(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
Assert.assertTrue(getDataResponse.getDataSet().isEmpty());
assertFalse(outPNPTruncated.get());
assertFalse(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
assertTrue(getDataResponse.getDataSet().isEmpty());
}
// TESTCASE: Given a GetDataRequest w/ known PNP, nothing is sent back
@ -172,13 +174,13 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 1, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertFalse(outPNPTruncated.get());
Assert.assertFalse(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
Assert.assertTrue(getDataResponse.getDataSet().isEmpty());
assertFalse(outPNPTruncated.get());
assertFalse(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
assertTrue(getDataResponse.getDataSet().isEmpty());
}
// TESTCASE: Given a GetDataRequest w/o known PNP, send it back
@ -198,13 +200,13 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 1, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertFalse(outPNPTruncated.get());
Assert.assertFalse(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().contains(onlyLocal));
Assert.assertTrue(getDataResponse.getDataSet().isEmpty());
assertFalse(outPNPTruncated.get());
assertFalse(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertTrue(getDataResponse.getPersistableNetworkPayloadSet().contains(onlyLocal));
assertTrue(getDataResponse.getDataSet().isEmpty());
}
// TESTCASE: Given a GetDataRequest w/o known PNP, don't send more than truncation limit
@ -227,17 +229,17 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 1, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertTrue(outPNPTruncated.get());
Assert.assertFalse(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertEquals(1, getDataResponse.getPersistableNetworkPayloadSet().size());
assertTrue(outPNPTruncated.get());
assertFalse(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertEquals(1, getDataResponse.getPersistableNetworkPayloadSet().size());
Set<PersistableNetworkPayload> persistableNetworkPayloadSet = getDataResponse.getPersistableNetworkPayloadSet();
// We use a set at the filter so it is not deterministic which item get truncated
Assert.assertEquals(1, persistableNetworkPayloadSet.size());
Assert.assertTrue(getDataResponse.getDataSet().isEmpty());
assertEquals(1, persistableNetworkPayloadSet.size());
assertTrue(getDataResponse.getDataSet().isEmpty());
}
// TESTCASE: Given a GetDataRequest w/o known PNP, but missing required capabilities, nothing is sent back
@ -259,13 +261,13 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 2, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertFalse(outPNPTruncated.get());
Assert.assertFalse(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
Assert.assertTrue(getDataResponse.getDataSet().isEmpty());
assertFalse(outPNPTruncated.get());
assertFalse(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
assertTrue(getDataResponse.getDataSet().isEmpty());
}
// TESTCASE: Given a GetDataRequest w/o known PNP that requires capabilities (and they match) send it back
@ -287,13 +289,13 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 2, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertFalse(outPNPTruncated.get());
Assert.assertFalse(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().contains(onlyLocal));
Assert.assertTrue(getDataResponse.getDataSet().isEmpty());
assertFalse(outPNPTruncated.get());
assertFalse(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertTrue(getDataResponse.getPersistableNetworkPayloadSet().contains(onlyLocal));
assertTrue(getDataResponse.getDataSet().isEmpty());
}
// TESTCASE: Given a GetDataRequest w/ unknown PSE, nothing is sent back
@ -312,13 +314,13 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 1, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertFalse(outPNPTruncated.get());
Assert.assertFalse(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
Assert.assertTrue(getDataResponse.getDataSet().isEmpty());
assertFalse(outPNPTruncated.get());
assertFalse(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
assertTrue(getDataResponse.getDataSet().isEmpty());
}
// TESTCASE: Given a GetDataRequest w/ known PSE, nothing is sent back
@ -340,13 +342,13 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 1, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertFalse(outPNPTruncated.get());
Assert.assertFalse(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
Assert.assertTrue(getDataResponse.getDataSet().isEmpty());
assertFalse(outPNPTruncated.get());
assertFalse(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
assertTrue(getDataResponse.getDataSet().isEmpty());
}
// TESTCASE: Given a GetDataRequest w/o known PSE, send it back
@ -365,13 +367,13 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 1, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertFalse(outPNPTruncated.get());
Assert.assertFalse(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
Assert.assertTrue(getDataResponse.getDataSet().contains(onlyLocal));
assertFalse(outPNPTruncated.get());
assertFalse(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
assertTrue(getDataResponse.getDataSet().contains(onlyLocal));
}
// TESTCASE: Given a GetDataRequest w/o known PNP, don't send more than truncation limit
@ -393,14 +395,14 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 1, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertFalse(outPNPTruncated.get());
Assert.assertTrue(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
Assert.assertEquals(1, getDataResponse.getDataSet().size());
Assert.assertTrue(
assertFalse(outPNPTruncated.get());
assertTrue(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
assertEquals(1, getDataResponse.getDataSet().size());
assertTrue(
getDataResponse.getDataSet().contains(onlyLocal1)
|| getDataResponse.getDataSet().contains(onlyLocal2));
}
@ -422,13 +424,13 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 2, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertFalse(outPNPTruncated.get());
Assert.assertFalse(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
Assert.assertTrue(getDataResponse.getDataSet().isEmpty());
assertFalse(outPNPTruncated.get());
assertFalse(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
assertTrue(getDataResponse.getDataSet().isEmpty());
}
// TESTCASE: Given a GetDataRequest w/o known PNP that requires capabilities (and they match) send it back
@ -449,13 +451,13 @@ public class P2PDataStorageBuildGetDataResponseTest {
GetDataResponse getDataResponse = this.testState.mockedStorage.buildGetDataResponse(
getDataRequest, 2, outPNPTruncated, outPSETruncated, peerCapabilities);
Assert.assertFalse(outPNPTruncated.get());
Assert.assertFalse(outPSETruncated.get());
Assert.assertEquals(1, getDataResponse.getRequestNonce());
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
Assert.assertTrue(getDataResponse.getDataSet().contains(onlyLocal));
assertFalse(outPNPTruncated.get());
assertFalse(outPSETruncated.get());
assertEquals(1, getDataResponse.getRequestNonce());
assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
assertTrue(getDataResponse.getPersistableNetworkPayloadSet().isEmpty());
assertTrue(getDataResponse.getDataSet().contains(onlyLocal));
}
}

View File

@ -28,15 +28,16 @@ import haveno.network.p2p.storage.payload.MailboxStoragePayload;
import haveno.network.p2p.storage.payload.ProtectedMailboxStorageEntry;
import haveno.network.p2p.storage.payload.ProtectedStorageEntry;
import haveno.network.p2p.storage.payload.ProtectedStoragePayload;
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.security.KeyPair;
import java.security.NoSuchAlgorithmException;
import java.util.Optional;
import static haveno.network.p2p.storage.TestState.SavedTestState;
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;
@ -49,7 +50,7 @@ import static org.mockito.Mockito.when;
public class P2PDataStorageClientAPITest {
private TestState testState;
@Before
@BeforeEach
public void setUp() {
this.testState = new TestState();
@ -67,9 +68,9 @@ public class P2PDataStorageClientAPITest {
ProtectedStorageEntry protectedStorageEntry = this.testState.mockedStorage.getProtectedStorageEntry(protectedStoragePayload, ownerKeys);
SavedTestState beforeState = this.testState.saveTestState(protectedStorageEntry);
Assert.assertTrue(this.testState.mockedStorage.addProtectedStorageEntry(protectedStorageEntry, TestState.getTestNodeAddress(), null));
assertTrue(this.testState.mockedStorage.addProtectedStorageEntry(protectedStorageEntry, TestState.getTestNodeAddress(), null));
this.testState.verifyProtectedStorageAdd(beforeState, protectedStorageEntry, true, true, true, true);
this.testState.assertProtectedStorageAdd(beforeState, protectedStorageEntry, true, true, true, true);
}
// TESTCASE: Adding an entry from the getProtectedStorageEntry API of an existing item correctly updates the item
@ -80,13 +81,13 @@ public class P2PDataStorageClientAPITest {
ProtectedStoragePayload protectedStoragePayload = new ExpirableProtectedStoragePayloadStub(ownerKeys.getPublic());
ProtectedStorageEntry protectedStorageEntry = this.testState.mockedStorage.getProtectedStorageEntry(protectedStoragePayload, ownerKeys);
Assert.assertTrue(this.testState.mockedStorage.addProtectedStorageEntry(protectedStorageEntry, TestState.getTestNodeAddress(), null));
assertTrue(this.testState.mockedStorage.addProtectedStorageEntry(protectedStorageEntry, TestState.getTestNodeAddress(), null));
SavedTestState beforeState = this.testState.saveTestState(protectedStorageEntry);
protectedStorageEntry = this.testState.mockedStorage.getProtectedStorageEntry(protectedStoragePayload, ownerKeys);
this.testState.mockedStorage.addProtectedStorageEntry(protectedStorageEntry, TestState.getTestNodeAddress(), null);
this.testState.verifyProtectedStorageAdd(beforeState, protectedStorageEntry, true, true, true, true);
this.testState.assertProtectedStorageAdd(beforeState, protectedStorageEntry, true, true, true, true);
}
// TESTCASE: Adding an entry from the getProtectedStorageEntry API of an existing item (added from onMessage path) correctly updates the item
@ -104,9 +105,9 @@ public class P2PDataStorageClientAPITest {
SavedTestState beforeState = this.testState.saveTestState(protectedStorageEntry);
protectedStorageEntry = this.testState.mockedStorage.getProtectedStorageEntry(protectedStoragePayload, ownerKeys);
Assert.assertTrue(this.testState.mockedStorage.addProtectedStorageEntry(protectedStorageEntry, TestState.getTestNodeAddress(), null));
assertTrue(this.testState.mockedStorage.addProtectedStorageEntry(protectedStorageEntry, TestState.getTestNodeAddress(), null));
this.testState.verifyProtectedStorageAdd(beforeState, protectedStorageEntry, true, true, true, true);
this.testState.assertProtectedStorageAdd(beforeState, protectedStorageEntry, true, true, true, true);
}
// TESTCASE: Updating an entry from the getRefreshTTLMessage API correctly errors if the item hasn't been seen
@ -119,7 +120,7 @@ public class P2PDataStorageClientAPITest {
RefreshOfferMessage refreshOfferMessage = this.testState.mockedStorage.getRefreshTTLMessage(protectedStoragePayload, ownerKeys);
SavedTestState beforeState = this.testState.saveTestState(refreshOfferMessage);
Assert.assertFalse(this.testState.mockedStorage.refreshTTL(refreshOfferMessage, TestState.getTestNodeAddress()));
assertFalse(this.testState.mockedStorage.refreshTTL(refreshOfferMessage, TestState.getTestNodeAddress()));
this.testState.verifyRefreshTTL(beforeState, refreshOfferMessage, false);
}
@ -141,7 +142,7 @@ public class P2PDataStorageClientAPITest {
this.testState.incrementClock();
SavedTestState beforeState = this.testState.saveTestState(refreshOfferMessage);
Assert.assertTrue(this.testState.mockedStorage.refreshTTL(refreshOfferMessage, TestState.getTestNodeAddress()));
assertTrue(this.testState.mockedStorage.refreshTTL(refreshOfferMessage, TestState.getTestNodeAddress()));
this.testState.verifyRefreshTTL(beforeState, refreshOfferMessage, true);
}
@ -165,7 +166,7 @@ public class P2PDataStorageClientAPITest {
this.testState.incrementClock();
SavedTestState beforeState = this.testState.saveTestState(refreshOfferMessage);
Assert.assertTrue(this.testState.mockedStorage.refreshTTL(refreshOfferMessage, TestState.getTestNodeAddress()));
assertTrue(this.testState.mockedStorage.refreshTTL(refreshOfferMessage, TestState.getTestNodeAddress()));
this.testState.verifyRefreshTTL(beforeState, refreshOfferMessage, true);
}
@ -182,7 +183,7 @@ public class P2PDataStorageClientAPITest {
this.testState.mockedStorage.getMailboxDataWithSignedSeqNr(mailboxStoragePayload, receiverKeys, receiverKeys.getPublic());
SavedTestState beforeState = this.testState.saveTestState(protectedMailboxStorageEntry);
Assert.assertTrue(this.testState.mockedStorage.remove(protectedMailboxStorageEntry, TestState.getTestNodeAddress()));
assertTrue(this.testState.mockedStorage.remove(protectedMailboxStorageEntry, TestState.getTestNodeAddress()));
this.testState.verifyProtectedStorageRemove(beforeState, protectedMailboxStorageEntry, false, false, true, true);
}
@ -198,13 +199,13 @@ public class P2PDataStorageClientAPITest {
ProtectedMailboxStorageEntry protectedMailboxStorageEntry =
this.testState.mockedStorage.getMailboxDataWithSignedSeqNr(mailboxStoragePayload, senderKeys, receiverKeys.getPublic());
Assert.assertTrue(this.testState.mockedStorage.addProtectedStorageEntry(protectedMailboxStorageEntry, TestState.getTestNodeAddress(), null));
assertTrue(this.testState.mockedStorage.addProtectedStorageEntry(protectedMailboxStorageEntry, TestState.getTestNodeAddress(), null));
protectedMailboxStorageEntry =
this.testState.mockedStorage.getMailboxDataWithSignedSeqNr(mailboxStoragePayload, receiverKeys, receiverKeys.getPublic());
SavedTestState beforeState = this.testState.saveTestState(protectedMailboxStorageEntry);
Assert.assertTrue(this.testState.mockedStorage.remove(protectedMailboxStorageEntry, TestState.getTestNodeAddress()));
assertTrue(this.testState.mockedStorage.remove(protectedMailboxStorageEntry, TestState.getTestNodeAddress()));
this.testState.verifyProtectedStorageRemove(beforeState, protectedMailboxStorageEntry, true, true, true, true);
}
@ -231,7 +232,7 @@ public class P2PDataStorageClientAPITest {
this.testState.mockedStorage.getMailboxDataWithSignedSeqNr(mailboxStoragePayload, receiverKeys, receiverKeys.getPublic());
SavedTestState beforeState = this.testState.saveTestState(protectedMailboxStorageEntry);
Assert.assertTrue(this.testState.mockedStorage.remove(protectedMailboxStorageEntry, TestState.getTestNodeAddress()));
assertTrue(this.testState.mockedStorage.remove(protectedMailboxStorageEntry, TestState.getTestNodeAddress()));
this.testState.verifyProtectedStorageRemove(beforeState, protectedMailboxStorageEntry, true, true, true, true);
}

Some files were not shown because too many files have changed in this diff Show More