use static imports for assert methods everywhere

This commit is contained in:
Andreas Schildbach 2022-04-14 10:40:26 +02:00
parent 1570946c18
commit d9b484295f
4 changed files with 28 additions and 20 deletions

View file

@ -17,12 +17,14 @@
package org.bitcoinj.crypto;
import com.google.common.collect.ImmutableList;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Michael Sean Gilligan
*/
@ -30,8 +32,8 @@ public class HDPathTest {
@Test
public void testPrimaryConstructor() {
HDPath path = new HDPath(true, Collections.emptyList());
Assert.assertTrue("Has private key returns false incorrectly", path.hasPrivateKey);
Assert.assertEquals("Path not empty", path.size(), 0);
assertTrue("Has private key returns false incorrectly", path.hasPrivateKey);
assertEquals("Path not empty", path.size(), 0);
}
@Test
@ -45,11 +47,11 @@ public class HDPathTest {
HDPath path4 = basePath.extend(ChildNumber.ZERO_HARDENED, ChildNumber.ONE_HARDENED, ChildNumber.ZERO_HARDENED, ChildNumber.ONE);
HDPath path5 = basePath.extend(ChildNumber.ZERO_HARDENED, ChildNumber.ONE_HARDENED, ChildNumber.ZERO_HARDENED, ChildNumber.ONE, ChildNumber.ZERO);
Assert.assertEquals("m/0H", path1.toString());
Assert.assertEquals("m/0H/1H", path2.toString());
Assert.assertEquals("m/0H/1H/0H", path3.toString());
Assert.assertEquals("m/0H/1H/0H/1", path4.toString());
Assert.assertEquals("m/0H/1H/0H/1/0", path5.toString());
assertEquals("m/0H", path1.toString());
assertEquals("m/0H/1H", path2.toString());
assertEquals("m/0H/1H/0H", path3.toString());
assertEquals("m/0H/1H/0H/1", path4.toString());
assertEquals("m/0H/1H/0H/1/0", path5.toString());
}
@Test
@ -76,7 +78,7 @@ public class HDPathTest {
String generatedStrPath = path.toString();
Assert.assertEquals(generatedStrPath, expectedStrPath);
assertEquals(generatedStrPath, expectedStrPath);
}
}
@ -113,8 +115,8 @@ public class HDPathTest {
boolean expectedHasPrivateKey = (Boolean) tv[i + 2];
HDPath path = HDPath.parsePath(strPath);
Assert.assertEquals(path, expectedPath);
Assert.assertEquals(path.hasPrivateKey, expectedHasPrivateKey);
assertEquals(path, expectedPath);
assertEquals(path.hasPrivateKey, expectedHasPrivateKey);
}
}
}

View file

@ -17,10 +17,11 @@
package org.bitcoinj.crypto;
import org.junit.Assert;
import org.junit.Test;
import static org.bitcoinj.core.Utils.HEX;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
public class HDUtilsTest {
@Test
@ -108,7 +109,7 @@ public class HDUtilsTest {
};
for (int i = 0; i < tv.length; i += 3) {
Assert.assertArrayEquals("Case " + i, getBytes(tv, i + 2), HDUtils.hmacSha512(getBytes(tv, i), getBytes(tv, i + 1)));
assertArrayEquals("Case " + i, getBytes(tv, i + 2), HDUtils.hmacSha512(getBytes(tv, i), getBytes(tv, i + 1)));
}
}
@ -119,6 +120,6 @@ public class HDUtilsTest {
@Test
public void testLongToByteArray() {
byte[] bytes = HDUtils.longTo4ByteArray(1026);
Assert.assertEquals("00000402", HEX.encode(bytes));
assertEquals("00000402", HEX.encode(bytes));
}
}

View file

@ -17,7 +17,6 @@
package org.bitcoinj.script;
import com.google.common.collect.ImmutableList;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@ -27,6 +26,7 @@ import java.util.Collection;
import java.util.Random;
import static org.bitcoinj.script.ScriptOpCodes.*;
import static org.junit.Assert.assertEquals;
/**
* ScriptChunk.size() determines the size of a serialized ScriptChunk without actually performing serialization.
@ -79,6 +79,6 @@ public class ScriptChunkSizeTest {
@Test
public void testSize() {
Assert.assertEquals(scriptChunk.toByteArray().length, scriptChunk.size());
assertEquals(scriptChunk.toByteArray().length, scriptChunk.size());
}
}

View file

@ -30,7 +30,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.hamcrest.core.IsNot;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -46,7 +45,13 @@ import static org.bitcoinj.core.Utils.HEX;
import static org.bitcoinj.script.ScriptOpCodes.OP_0;
import static org.bitcoinj.script.ScriptOpCodes.OP_INVALIDOPCODE;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.*;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Before;
public class ScriptTest {
@ -154,7 +159,7 @@ public class ScriptTest {
// Assert that the input script created contains the original multisig
// script as the last chunk
ScriptChunk scriptChunk = inputScript.getChunks().get(inputScript.getChunks().size() - 1);
Assert.assertArrayEquals(scriptChunk.data, multisigScript.getProgram());
assertArrayEquals(scriptChunk.data, multisigScript.getProgram());
// Create regular multisig input script
inputScript = ScriptBuilder.createMultiSigInputScript(ImmutableList.of(party1TransactionSignature, party2TransactionSignature));
@ -165,7 +170,7 @@ public class ScriptTest {
// Assert that the input script created does not end with the original
// multisig script
scriptChunk = inputScript.getChunks().get(inputScript.getChunks().size() - 1);
Assert.assertThat(scriptChunk.data, IsNot.not(equalTo(multisigScript.getProgram())));
assertThat(scriptChunk.data, IsNot.not(equalTo(multisigScript.getProgram())));
}
@Test