diff --git a/.gitignore b/.gitignore
index 6994b5f..1b433f7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ key.wif
/.settings/
/.classpath
/.project
+*.iml
diff --git a/java-opentimestamps.iml b/java-opentimestamps.iml
deleted file mode 100644
index 86c91bb..0000000
--- a/java-opentimestamps.iml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/test/java/com/eternitywall/TestBitcoin.java b/src/test/java/com/eternitywall/TestBitcoin.java
index 2ba3737..c288b34 100644
--- a/src/test/java/com/eternitywall/TestBitcoin.java
+++ b/src/test/java/com/eternitywall/TestBitcoin.java
@@ -2,7 +2,6 @@
import com.eternitywall.ots.BitcoinNode;
import com.eternitywall.ots.BlockHeader;
-import com.eternitywall.ots.Timestamp;
import com.eternitywall.ots.Utils;
import org.json.JSONObject;
import org.junit.Test;
@@ -13,13 +12,9 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-/**
- * Created by casatta on 06/03/17.
- */
public class TestBitcoin {
private static Logger log = Utils.getLogger(TestBitcoin.class.getName());
-
@Test
public void testBitcoin() throws Exception {
try {
@@ -38,9 +33,5 @@ public void testBitcoin() throws Exception {
} catch (Exception e) {
log.info("no bitcoin node");
}
-
}
-
-
-
}
diff --git a/src/test/java/com/eternitywall/TestCalendar.java b/src/test/java/com/eternitywall/TestCalendar.java
index db8bc90..cb4ed65 100644
--- a/src/test/java/com/eternitywall/TestCalendar.java
+++ b/src/test/java/com/eternitywall/TestCalendar.java
@@ -8,10 +8,7 @@
import org.bitcoinj.core.NetworkParameters;
import org.junit.Test;
-
-import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -26,10 +23,8 @@
import static org.junit.Assert.assertTrue;
public class TestCalendar {
-
private static Logger log = Utils.getLogger(TestCalendar.class.getName());
-
@Test
public void TestSingle() throws Exception {
String calendarUrl = "https://finney.calendar.eternitywall.com";
@@ -40,9 +35,6 @@ public void TestSingle() throws Exception {
assertTrue(Arrays.equals(timestamp.getDigest() , digest));
}
-
-
-
@Test
public void TestPrivate() throws Exception {
byte[] digest = Utils.randBytes(32);
@@ -52,7 +44,8 @@ public void TestPrivate() throws Exception {
// auth.calendar.eternitywall.com = KwT2r9sL........
Path path = Paths.get("key.wif");
- if(!Files.exists(path)){
+
+ if (!Files.exists(path)){
assertTrue(true);
return;
}
@@ -60,38 +53,42 @@ public void TestPrivate() throws Exception {
Properties properties = new Properties();
properties.load(new FileInputStream("key.wif"));
HashMap privateUrls = new HashMap<>();
- for(String key : properties.stringPropertyNames()) {
+
+ for (String key : properties.stringPropertyNames()) {
String value = properties.getProperty(key);
privateUrls.put(key,value);
}
+
assertFalse(privateUrls.size() == 0);
- for(Map.Entry entry : privateUrls.entrySet()) {
+ for (Map.Entry entry : privateUrls.entrySet()) {
String calendarUrl = "https://"+entry.getKey();
String wifKey = entry.getValue();
Calendar calendar = new Calendar(calendarUrl);
ECKey key;
+
try {
BigInteger privKey = new BigInteger(wifKey);
key = ECKey.fromPrivate(privKey);
- }catch (Exception e){
+ } catch (Exception e){
DumpedPrivateKey dumpedPrivateKey = new DumpedPrivateKey(NetworkParameters.prodNet(), wifKey);
key = dumpedPrivateKey.getKey();
}
+
calendar.setKey(key);
Timestamp timestamp = calendar.submit(digest);
assertTrue(timestamp != null);
assertTrue(Arrays.equals(timestamp.getDigest() , digest));
}
-
}
@Test
public void TestPrivateWif() throws Exception {
byte[] digest = Utils.randBytes(32);
Path path = Paths.get("key.wif");
- if(!Files.exists(path)){
+
+ if (!Files.exists(path)){
assertTrue(true);
return;
}
@@ -99,13 +96,15 @@ public void TestPrivateWif() throws Exception {
Properties properties = new Properties();
properties.load(new FileInputStream("key.wif"));
HashMap privateUrls = new HashMap<>();
- for(String key : properties.stringPropertyNames()) {
+
+ for (String key : properties.stringPropertyNames()) {
String value = properties.getProperty(key);
privateUrls.put(key,value);
}
+
assertFalse(privateUrls.size() == 0);
- for(Map.Entry entry : privateUrls.entrySet()) {
+ for (Map.Entry entry : privateUrls.entrySet()) {
String calendarUrl = "https://"+entry.getKey();
String wifKey = entry.getValue();
@@ -118,7 +117,6 @@ public void TestPrivateWif() throws Exception {
assertTrue(timestamp != null);
assertTrue(Arrays.equals(timestamp.getDigest() , digest));
}
-
}
@Test
@@ -142,7 +140,8 @@ public void TestSingleAsyncPrivate() throws Exception {
ArrayBlockingQueue> queue = new ArrayBlockingQueue<>(1);
byte[] digest = Utils.randBytes(32);
Path path = Paths.get("signature.key");
- if(!Files.exists(path)){
+
+ if (!Files.exists(path)){
assertTrue(true);
return;
}
@@ -150,13 +149,15 @@ public void TestSingleAsyncPrivate() throws Exception {
Properties properties = new Properties();
properties.load(new FileInputStream("signature.key"));
HashMap privateUrls = new HashMap<>();
- for(String key : properties.stringPropertyNames()) {
+
+ for (String key : properties.stringPropertyNames()) {
String value = properties.getProperty(key);
privateUrls.put(key,value);
}
+
assertFalse(privateUrls.size() == 0);
- for(Map.Entry entry : privateUrls.entrySet()) {
+ for (Map.Entry entry : privateUrls.entrySet()) {
String calendarUrl = "https://"+entry.getKey();
String signature = entry.getValue();
@@ -172,8 +173,6 @@ public void TestSingleAsyncPrivate() throws Exception {
assertTrue(timestamp.get() != null);
assertTrue(Arrays.equals(timestamp.get().getDigest() , digest));
}
-
-
}
@Test
@@ -200,18 +199,19 @@ public void TestMulti() throws Exception {
}
int count = 0;
- for (final String calendarUrl : calendarsUrl) {
+ for (final String calendarUrl : calendarsUrl) {
try {
Optional stamp = queue.take();
//timestamp.merge(stamp);
- if(stamp.isPresent()) {
+
+ if (stamp.isPresent()) {
count++;
}
+
if (count >= m) {
break;
}
-
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -220,14 +220,13 @@ public void TestMulti() throws Exception {
if (count < m) {
log.severe("Failed to create timestamp: requested " + String.valueOf(m) + " attestation" + ((m > 1) ? "s" : "") + " but received only " + String.valueOf(count));
}
+
assertFalse(count < m);
//shut down the executor service now
executor.shutdown();
}
-
-
@Test
public void TestMultiWithInvalidCalendar() throws Exception {
@@ -245,25 +244,25 @@ public void TestMultiWithInvalidCalendar() throws Exception {
CalendarAsyncSubmit task = new CalendarAsyncSubmit(calendarUrl, digest);
task.setQueue(queue);
executor.submit(task);
-
} catch (Exception e) {
e.printStackTrace();
}
}
int count = 0;
- for (final String calendarUrl : calendarsUrl) {
+ for (final String calendarUrl : calendarsUrl) {
try {
Optional stamp = queue.take();
//timestamp.merge(stamp);
+
if(stamp.isPresent()) {
count++;
}
+
if (count >= m) {
break;
}
-
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -272,13 +271,13 @@ public void TestMultiWithInvalidCalendar() throws Exception {
if (count < m) {
log.severe("Failed to create timestamp: requested " + String.valueOf(m) + " attestation" + ((m > 1) ? "s" : "") + " but received only " + String.valueOf(count));
}
+
assertFalse(count < m);
//shut down the executor service now
executor.shutdown();
}
-
@Test
public void rfc6979() {
BigInteger privKey = new BigInteger("235236247357325473457345");
@@ -287,5 +286,4 @@ public void rfc6979() {
System.out.println(a);
assertTrue(a.equals("IBY7a75Ygps/o1BqTQ0OpFL+a8WHfd9jNO/8820ST0gyQ0SAuIWKm8/M90aG1G40oJvjrlcoiKngKAYYsJS6I0s="));
}
-
}
diff --git a/src/test/java/com/eternitywall/TestLongReceipt.java b/src/test/java/com/eternitywall/TestLongReceipt.java
index ddb3957..74eeb93 100644
--- a/src/test/java/com/eternitywall/TestLongReceipt.java
+++ b/src/test/java/com/eternitywall/TestLongReceipt.java
@@ -34,12 +34,14 @@ public void testException() throws Exception {
final byte[] bytes = DatatypeConverter.parseBase64Binary(el);
StreamDeserializationContext ctx = new StreamDeserializationContext(bytes);
Timestamp timestamp = Timestamp.deserialize(ctx, digestByte);
+
try {
root.merge(timestamp);
} catch (Exception e) {
assertTrue(false);
}
}
+
StreamSerializationContext streamSerializationContext = new StreamSerializationContext();
root.serialize(streamSerializationContext);
assertTrue(true);
@@ -48,6 +50,5 @@ public void testException() throws Exception {
Timestamp timestamp = Timestamp.deserialize(ctx2, digestByte);
assertNotNull(timestamp);
//System.out.println(timestamp.strTree(2));
-
}
}
diff --git a/src/test/java/com/eternitywall/TestMultiInsight.java b/src/test/java/com/eternitywall/TestMultiInsight.java
index 2c41174..d87797d 100644
--- a/src/test/java/com/eternitywall/TestMultiInsight.java
+++ b/src/test/java/com/eternitywall/TestMultiInsight.java
@@ -1,14 +1,7 @@
package com.eternitywall;
-import com.eternitywall.ots.BlockHeader;
-import com.eternitywall.ots.MultiInsight;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Created by casatta on 07/03/17.
- */
public class TestMultiInsight {
@Test
diff --git a/src/test/java/com/eternitywall/TestOpenTimestamps.java b/src/test/java/com/eternitywall/TestOpenTimestamps.java
index 593d25d..b663f1e 100644
--- a/src/test/java/com/eternitywall/TestOpenTimestamps.java
+++ b/src/test/java/com/eternitywall/TestOpenTimestamps.java
@@ -5,8 +5,6 @@
import com.eternitywall.ots.*;
import com.eternitywall.ots.attestation.TimeAttestation;
import com.eternitywall.ots.exceptions.VerificationException;
-import com.eternitywall.ots.op.OpAppend;
-import com.eternitywall.ots.op.OpCrypto;
import com.eternitywall.ots.op.OpSHA256;
import java.util.ArrayList;
import java.util.List;
@@ -15,7 +13,6 @@
import org.junit.Before;
import org.junit.Test;
-
import java.io.*;
import java.net.URL;
import java.security.NoSuchAlgorithmException;
@@ -29,9 +26,6 @@
import static org.junit.Assert.*;
-/**
- * Created by casatta on 28/02/17.
- */
public class TestOpenTimestamps{
private ExecutorService executor;
private byte[] incomplete;
@@ -46,7 +40,6 @@ public class TestOpenTimestamps{
private byte[] differentBlockchainOts;
private String differentBlockchainOtsInfo;
-
private String helloWorldHashHex="03ba204e50d126e4674c005e04d82e84c21366780af1f43bd54a37816b6ab340";
private String baseUrl = "https://raw.githubusercontent.com/opentimestamps/java-opentimestamps/master";
@@ -98,7 +91,6 @@ public void info() throws ExecutionException, InterruptedException, IOException
assertEquals(differentBlockchainOtsInfo, result3);
}
-
@Test
public void stamp() throws NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
{
@@ -115,18 +107,17 @@ public void stamp() throws NoSuchAlgorithmException, IOException, ExecutionExcep
byte[] digest = detached.fileDigest();
assertTrue(Arrays.equals(digest, Utils.hexToBytes(helloWorldHashHex)));
}
-
}
@Test
public void merkle() throws NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
-
List files = new ArrayList<>();
files.add(helloworld);
files.add(merkle2Ots);
files.add(incomplete);
List fileTimestamps = new ArrayList<>();
+
for (byte[] file : files){
InputStream is = new ByteArrayInputStream(helloworld);
DetachedTimestampFile detachedTimestampFile = DetachedTimestampFile.from(new OpSHA256(), is);
@@ -134,14 +125,15 @@ public void merkle() throws NoSuchAlgorithmException, IOException, ExecutionExce
}
Timestamp merkleTip = OpenTimestamps.makeMerkleTree(fileTimestamps);
+
// For each fileTimestamps check the tip
for (DetachedTimestampFile fileTimestamp : fileTimestamps){
Set tips = fileTimestamp.getTimestamp().allTips();
+
for (byte[] tip : tips){
assertTrue( Arrays.equals(tip, merkleTip.getDigest()) );
}
}
-
}
@Test(expected = Exception.class)
@@ -160,16 +152,16 @@ public void verify2() throws Exception {
@Test
public void verify() throws NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
-
{
DetachedTimestampFile detachedOts = DetachedTimestampFile.deserialize(helloworldOts);
DetachedTimestampFile detached = DetachedTimestampFile.from(Hash.from(helloworld, OpSHA256._TAG));
+
try {
HashMap results = OpenTimestamps.verify(detachedOts, detached);
assertTrue(results.size()>0);
assertTrue(results.containsKey(VerifyResult.Chains.BITCOIN));
assertEquals(1432827678L, results.get(VerifyResult.Chains.BITCOIN).timestamp.longValue());
- }catch(Exception e){
+ } catch (Exception e){
assertNull(e);
}
}
@@ -178,14 +170,14 @@ public void verify() throws NoSuchAlgorithmException, IOException, ExecutionExce
{
DetachedTimestampFile detachedOts = DetachedTimestampFile.deserialize(incompleteOts);
DetachedTimestampFile detached = DetachedTimestampFile.from(Hash.from(incomplete, OpSHA256._TAG));
+
try {
HashMap results = OpenTimestamps.verify(detachedOts, detached);
assertEquals(results.size(), 0);
- }catch(Exception e){
+ } catch (Exception e){
assertNull(e);
}
}
-
}
@Test(expected = VerificationException.class)
@@ -224,7 +216,6 @@ public void upgrade() throws ExecutionException, InterruptedException, IOExcepti
} catch (Exception e) {
assertNull(e);
}
-
}
@Test
@@ -250,7 +241,6 @@ public void test() throws ExecutionException, InterruptedException, IOException
} catch (Exception e) {
assertNull(e);
}
-
}
@Test
@@ -295,7 +285,6 @@ public void shrink() throws Exception {
TimeAttestation resultAttestationBitcoin = timestamp.shrink();
assertEquals(timestamp.allAttestations().size(), 2);
assertTrue(timestamp.getAttestations().contains(resultAttestationBitcoin));
-
}
{
@@ -329,12 +318,10 @@ public void shrink() throws Exception {
assertEquals(timestamp.allAttestations().size(), 2);
assertTrue(timestamp.getAttestations().contains(resultAttestationBitcoin));
}
-
}
@After
public void tearDown() {
executor.shutdown();
}
-
}
diff --git a/src/test/java/com/eternitywall/TestStreamDeserializationContext.java b/src/test/java/com/eternitywall/TestStreamDeserializationContext.java
index f5dc05c..5c4ca3a 100644
--- a/src/test/java/com/eternitywall/TestStreamDeserializationContext.java
+++ b/src/test/java/com/eternitywall/TestStreamDeserializationContext.java
@@ -1,6 +1,5 @@
package com.eternitywall;
-import com.eternitywall.ots.OpenTimestamps;
import com.eternitywall.ots.StreamDeserializationContext;
import com.eternitywall.ots.StreamSerializationContext;
import com.eternitywall.ots.Timestamp;
@@ -9,21 +8,17 @@
import com.eternitywall.ots.Utils;
import org.junit.Test;
-
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import static org.junit.Assert.*;
-/**
- * Created by casatta on 24/03/17.
- */
public class TestStreamDeserializationContext {
-
@Test
public void testVaruint() {
int value=0x1;
+
for(int i=0;i<20;i++) {
value = value << 1;
StreamSerializationContext ssc = new StreamSerializationContext();
@@ -35,6 +30,7 @@ public void testVaruint() {
assertEquals(value, read);
}
}
+
@Test
public void testReadvaruint() {
final byte[] uri = "https://finney.calendar.eternitywall.com".getBytes(StandardCharsets.US_ASCII);
@@ -50,12 +46,10 @@ public void testReadvaruint() {
assertTrue(Arrays.equals(uri, pendingAttestationCheck.getUri()));
}
-
@Test
public void testTimestamp() {
- byte []ots = Utils.hexToBytes("F0105C3F2B3F8524A32854E07AD8ADDE9C1908F10458D95A36F008088D287213A8B9880083DFE30D2EF90C8E2C2B68747470733A2F2F626F622E6274632E63616C656E6461722E6F70656E74696D657374616D70732E6F7267");
- byte []digest = Utils.hexToBytes("7aa9273d2a50dbe0cc5a6ccc444a5ca90c9491dd2ac91849e45195ae46f64fe352c3a63ba02775642c96131df39b5b85");
-
+ byte[] ots = Utils.hexToBytes("F0105C3F2B3F8524A32854E07AD8ADDE9C1908F10458D95A36F008088D287213A8B9880083DFE30D2EF90C8E2C2B68747470733A2F2F626F622E6274632E63616C656E6461722E6F70656E74696D657374616D70732E6F7267");
+ byte[] digest = Utils.hexToBytes("7aa9273d2a50dbe0cc5a6ccc444a5ca90c9491dd2ac91849e45195ae46f64fe352c3a63ba02775642c96131df39b5b85");
//System.out.println("ots hex: " + Utils.bytesToHex(ots));
StreamDeserializationContext streamDeserializationContext = new StreamDeserializationContext(ots);
@@ -68,6 +62,5 @@ public void testTimestamp() {
//System.out.println("fullOts hex:" + Utils.bytesToHex(otsSerialized));
assertTrue(Arrays.equals(ots, otsSerialized));
-
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/eternitywall/TestTimestamp.java b/src/test/java/com/eternitywall/TestTimestamp.java
index 8478910..34741ed 100644
--- a/src/test/java/com/eternitywall/TestTimestamp.java
+++ b/src/test/java/com/eternitywall/TestTimestamp.java
@@ -5,15 +5,11 @@
import com.eternitywall.ots.StreamSerializationContext;
import com.eternitywall.ots.Timestamp;
import com.eternitywall.ots.attestation.PendingAttestation;
-import com.eternitywall.ots.attestation.TimeAttestation;
import com.eternitywall.ots.op.Op;
import com.eternitywall.ots.op.OpAppend;
-import com.eternitywall.ots.op.OpPrepend;
import com.eternitywall.ots.op.OpSHA256;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.nio.charset.Charset;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -28,7 +24,6 @@
public class TestTimestamp {
-
@Test
public void addOp() {
//Adding operations to timestamps
@@ -54,6 +49,7 @@ public void setResultTimestamp() {
assertTrue( Arrays.equals( t1.ops.get(opAppend1).ops.get(opAppend2).msg, Utils.toBytes("foobarbaz", "UTF-8")) );
t1.ops.put(opAppend1, new Timestamp(Utils.toBytes("foobar", "UTF-8")) );
+
for (Map.Entry entry : t1.ops.get(opAppend1).ops.entrySet()) {
Timestamp timestamp = entry.getValue();
Op op = entry.getKey();
@@ -61,7 +57,6 @@ public void setResultTimestamp() {
}
}
-
void Tserialize(Timestamp expected_instance, byte[] expected_serialized){
StreamSerializationContext ssc = new StreamSerializationContext();
expected_instance.serialize(ssc);
@@ -74,7 +69,6 @@ void Tserialize(Timestamp expected_instance, byte[] expected_serialized){
assertTrue(expected_instance.equals(actual_instance));
}
-
@Test
public void serialization() throws IOException {
// Timestamp serialization/deserialization
@@ -145,7 +139,6 @@ public void serialization() throws IOException {
baos.write(Utils.hexToBytes("83dfe30d2ef90c8e" + "07" + "06"));
baos.write(Utils.toBytes("deeper", "UTF-8"));
Tserialize(stamp, baos.toByteArray());
-
}
@Test
@@ -155,17 +148,20 @@ public void merge() {
Timestamp stampA = new Timestamp(Utils.toBytes("a", "UTF-8"));
Timestamp stampB = new Timestamp(Utils.toBytes("b", "UTF-8"));
Exception err = null;
+
try {
stampA.merge(stampB);
} catch (Exception e) {
err = e;
}
+
assertNotNull(err);
Timestamp stamp1 = new Timestamp(Utils.toBytes("a", "UTF-8"));
Timestamp stamp2 = new Timestamp(Utils.toBytes("a", "UTF-8"));
stamp2.attestations.add(new PendingAttestation(Utils.toBytes("foobar", "UTF-8")));
err = null;
+
try {
stamp1.merge(stamp2);
assertTrue(stamp1.equals(stamp2));
@@ -173,12 +169,12 @@ public void merge() {
e.printStackTrace();
err = e;
}
+
assertNull(err);
}
@Test
- public void makeMerkleTree()
- throws NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
+ public void makeMerkleTree() throws NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
defTimestamp(2, Utils.hexToBytes("b413f47d13ee2fe6c845b2ee141af81de858df4ec549a58b7970bb96645bc8d2"));
defTimestamp(3, Utils.hexToBytes("e6aa639123d8aac95d13d365ec3779dade4b49c083a8fed97d7bfc0d89bb6a5e"));
@@ -207,14 +203,16 @@ public void defTimestamp(int n, byte[] expected_merkle_root){
byte[] bytes = {(byte) i};
roots.add( new Timestamp( bytes ));
}
+
Timestamp merkleTip = Merkle.makeMerkleTree(roots);
assertTrue(Arrays.equals(merkleTip.getDigest(),expected_merkle_root));
for (Timestamp root : roots){
Set tips = root.allTips();
+
for (byte[] tip : tips){
assertTrue( Arrays.equals(tip, merkleTip.getDigest()) );
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/eternitywall/TestUtils.java b/src/test/java/com/eternitywall/TestUtils.java
index 0989ac4..d568a60 100644
--- a/src/test/java/com/eternitywall/TestUtils.java
+++ b/src/test/java/com/eternitywall/TestUtils.java
@@ -3,18 +3,13 @@
import com.eternitywall.ots.Utils;
import org.junit.Test;
-
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import static org.junit.Assert.*;
-/**
- * Created by casatta on 27/02/17.
- */
public class TestUtils {
-
Utils utils = new Utils();
@Test
@@ -28,7 +23,6 @@ public void arraysCopy() throws Exception {
assertNull(Utils.arraysCopy(null));
}
-
@Test
public void arraysConcat() {
byte[] array = "foo".getBytes();
@@ -45,7 +39,6 @@ public void bytesToHex() {
assertTrue("2030615a".equals(anObject));
}
-
@Test
public void testRandBytes() {
try {
@@ -75,20 +68,19 @@ public void testHexBytes() {
Utils.hexToBytes("0");
assertFalse(true);
} catch (IllegalArgumentException e) {
-
+ // Empty
}
try {
Utils.hexToBytes("xx");
assertFalse(true);
} catch (IllegalArgumentException e) {
-
+ // Empty
}
byte[] arr=Utils.hexToBytes("0000");
assertTrue("0000".equals(Utils.bytesToHex(arr).toLowerCase()));
-
byte[] arr2= Utils.hexToBytes("0aef");
assertTrue("0aef".equals(Utils.bytesToHex(arr2).toLowerCase()));
}
@@ -98,7 +90,5 @@ public void testArrayFill() {
byte[] a = new byte[10];
Utils.arrayFill(a, (byte)0);
assertEquals("00000000000000000000", Utils.bytesToHex(a).toLowerCase());
-
}
}
-
diff --git a/src/test/java/com/eternitywall/http/TestHttp.java b/src/test/java/com/eternitywall/http/TestHttp.java
index 6ec181a..1318e64 100644
--- a/src/test/java/com/eternitywall/http/TestHttp.java
+++ b/src/test/java/com/eternitywall/http/TestHttp.java
@@ -2,22 +2,16 @@
import org.junit.Test;
-import java.net.MalformedURLException;
import java.net.URL;
import static org.junit.Assert.assertEquals;
-/**
- * Created by casatta on 30/03/17.
- */
public class TestHttp {
@Test
public void test() throws Exception {
Request request= new Request(new URL("http://httpbin.org/status/418"));
Response call = request.call();
- assertEquals((Integer)418,call.getStatus());
-
+ assertEquals((Integer)418, call.getStatus());
}
-
}
diff --git a/src/test/java/com/eternitywall/http/TestHttps.java b/src/test/java/com/eternitywall/http/TestHttps.java
index 753ebd7..622887d 100644
--- a/src/test/java/com/eternitywall/http/TestHttps.java
+++ b/src/test/java/com/eternitywall/http/TestHttps.java
@@ -1,15 +1,11 @@
package com.eternitywall.http;
-import com.eternitywall.http.Request;
import org.junit.Test;
import java.net.URL;
import static org.junit.Assert.assertNotNull;
-/**
- * Created by casatta on 28/02/17.
- */
public class TestHttps {
@Test
diff --git a/src/test/java/com/eternitywall/ots/TestOtsCli.java b/src/test/java/com/eternitywall/ots/TestOtsCli.java
index e3f89a0..bb8038e 100644
--- a/src/test/java/com/eternitywall/ots/TestOtsCli.java
+++ b/src/test/java/com/eternitywall/ots/TestOtsCli.java
@@ -21,7 +21,6 @@ public void testCommandLineHandlesUpgradeCommandWithWrongFileName() throws Excep
}
private class StringLoggerForTest {
-
private ByteArrayOutputStream baos;
private StreamHandler sh;
@@ -39,5 +38,4 @@ public String contents() throws Exception {
return this.baos.toString();
}
}
-
}
diff --git a/src/test/java/com/eternitywall/ots/attestation/TestBitcoinBlockHeaderAttestation.java b/src/test/java/com/eternitywall/ots/attestation/TestBitcoinBlockHeaderAttestation.java
index 548e4da..e871222 100644
--- a/src/test/java/com/eternitywall/ots/attestation/TestBitcoinBlockHeaderAttestation.java
+++ b/src/test/java/com/eternitywall/ots/attestation/TestBitcoinBlockHeaderAttestation.java
@@ -1,17 +1,11 @@
package com.eternitywall.ots.attestation;
-import static org.junit.Assert.assertTrue;
-
import com.eternitywall.ots.StreamDeserializationContext;
-import com.eternitywall.ots.StreamSerializationContext;
import com.eternitywall.ots.Utils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.util.Arrays;
-import javax.xml.bind.DatatypeConverter;
import org.junit.Test;
-
public class TestBitcoinBlockHeaderAttestation {
@Test
@@ -26,5 +20,4 @@ public void deserializationTrailingGarbage() throws IOException {
TimeAttestation.deserialize(ctx);
// TODO exception TrailingGarbageError
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/eternitywall/ots/attestation/TestPendingAttestation.java b/src/test/java/com/eternitywall/ots/attestation/TestPendingAttestation.java
index 0bb90a3..dc1636a 100644
--- a/src/test/java/com/eternitywall/ots/attestation/TestPendingAttestation.java
+++ b/src/test/java/com/eternitywall/ots/attestation/TestPendingAttestation.java
@@ -1,6 +1,5 @@
package com.eternitywall.ots.attestation;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.eternitywall.ots.StreamDeserializationContext;
@@ -12,10 +11,8 @@
import javax.xml.bind.DatatypeConverter;
import org.junit.Test;
-
public class TestPendingAttestation {
-
@Test
public void serialization() throws IOException {
// Serialization of pending attestations
@@ -35,10 +32,8 @@ public void serialization() throws IOException {
assertTrue(Arrays.equals(pendingAttestation2._TAG(), PendingAttestation._TAG));
assertTrue(Arrays.equals(pendingAttestation2.getUri(), Utils.toBytes("foobar", "UTF-8")));
-
}
-
@Test
public void deserialization() throws IOException {
// Deserialization of attestations
@@ -85,7 +80,6 @@ public void invalidUriDeserialization() throws IOException {
ctx = new StreamDeserializationContext(baos.toByteArray());
TimeAttestation.deserialize(ctx);
// TODO exception DeserializationError
-
}
@Test
@@ -99,5 +93,4 @@ public void deserializationTrailingGarbage() throws IOException {
TimeAttestation.deserialize(ctx);
// TODO exception TrailingGarbageError
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/eternitywall/ots/attestation/TestUnknownAttestation.java b/src/test/java/com/eternitywall/ots/attestation/TestUnknownAttestation.java
index 07cc8bf..981103b 100644
--- a/src/test/java/com/eternitywall/ots/attestation/TestUnknownAttestation.java
+++ b/src/test/java/com/eternitywall/ots/attestation/TestUnknownAttestation.java
@@ -1,8 +1,6 @@
package com.eternitywall.ots.attestation;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import com.eternitywall.ots.StreamDeserializationContext;
@@ -10,12 +8,8 @@
import com.eternitywall.ots.Utils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.Serializable;
import java.util.Arrays;
-import javax.xml.bind.DatatypeConverter;
import org.junit.Test;
-import org.slf4j.helpers.Util;
-
public class TestUnknownAttestation {
@@ -48,7 +42,6 @@ public void serialization() throws IOException {
assertTrue(Arrays.equals(expected_serialized, ctx1.getOutput()));
}
-
@Test
public void deserializationTooLong() throws IOException {
// Deserialization of attestations with oversized payloads
@@ -71,6 +64,4 @@ public void deserializationTooLong() throws IOException {
UnknownAttestation a1 = (UnknownAttestation) TimeAttestation.deserialize(ctx1);
// TODO: exception
}
-
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/eternitywall/ots/crypto/TestKeccakDigest.java b/src/test/java/com/eternitywall/ots/crypto/TestKeccakDigest.java
index 9529db4..b3f55bc 100644
--- a/src/test/java/com/eternitywall/ots/crypto/TestKeccakDigest.java
+++ b/src/test/java/com/eternitywall/ots/crypto/TestKeccakDigest.java
@@ -3,13 +3,8 @@
import com.eternitywall.ots.Utils;
import org.junit.Test;
-
-
import static org.junit.Assert.assertEquals;
-/**
- * Created by casatta on 06/03/17.
- */
public class TestKeccakDigest {
@Test
diff --git a/src/test/java/com/eternitywall/ots/op/TestOp.java b/src/test/java/com/eternitywall/ots/op/TestOp.java
index b54394b..c41f3d1 100644
--- a/src/test/java/com/eternitywall/ots/op/TestOp.java
+++ b/src/test/java/com/eternitywall/ots/op/TestOp.java
@@ -21,7 +21,6 @@ public void testAppend() {
Utils.toBytes("msgsuffix", "UTF-8")));
}
-
@Test
public void testPrepend() {
// Prepend operation
@@ -60,7 +59,6 @@ public void testEquality() {
assertNotSame ( new OpAppend(Utils.toBytes("foo", "UTF-8")), new OpPrepend(Utils.toBytes("foo", "UTF-8")));
}
-
@Test
public void testOrdering() {
// Operation ordering
@@ -76,5 +74,4 @@ public void testOrdering() {
assertTrue(op3.compareTo(op4) < 0);
assertFalse(op3.compareTo(op4) > 0);
}
-
}
diff --git a/src/test/java/com/eternitywall/ots/op/TestOps.java b/src/test/java/com/eternitywall/ots/op/TestOps.java
index bc8a93f..6c03678 100644
--- a/src/test/java/com/eternitywall/ots/op/TestOps.java
+++ b/src/test/java/com/eternitywall/ots/op/TestOps.java
@@ -5,16 +5,10 @@
import com.eternitywall.ots.Utils;
import org.junit.Test;
-
-
-import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import static org.junit.Assert.*;
-/**
- * Created by casatta on 06/03/17.
- */
public class TestOps {
@Test
@@ -92,5 +86,4 @@ public void test100M() throws Exception{
byte[] fileDigest = timestampFile.fileDigest();
assertTrue(Arrays.equals(Utils.hexToBytes(hash), fileDigest));
}
-
}