updated tests (#13)

* updated tests

* Bundle: fixed addEntry
This commit is contained in:
Oliver Nitzschke
2016-12-22 14:55:13 +01:00
committed by Gianluigi Davassi
parent bee2aa3302
commit 9af3d2d027
4 changed files with 73 additions and 63 deletions
+13 -45
View File
@@ -1,48 +1,7 @@
package jota;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jota.dto.request.IotaAttachToTangleRequest;
import jota.dto.request.IotaBroadcastTransactionRequest;
import jota.dto.request.IotaCommandRequest;
import jota.dto.request.IotaFindTransactionsRequest;
import jota.dto.request.IotaGetBalancesRequest;
import jota.dto.request.IotaGetInclusionStateRequest;
import jota.dto.request.IotaGetTransactionsToApproveRequest;
import jota.dto.request.IotaGetTrytesRequest;
import jota.dto.request.IotaNeighborsRequest;
import jota.dto.request.IotaStoreTransactionsRequest;
import jota.dto.response.AddNeighborsResponse;
import jota.dto.response.BroadcastTransactionsResponse;
import jota.dto.response.FindTransactionResponse;
import jota.dto.response.GetAttachToTangleResponse;
import jota.dto.response.GetBalancesAndFormatResponse;
import jota.dto.response.GetBalancesResponse;
import jota.dto.response.GetBundleResponse;
import jota.dto.response.GetInclusionStateResponse;
import jota.dto.response.GetNeighborsResponse;
import jota.dto.response.GetNewAddressResponse;
import jota.dto.response.GetNodeInfoResponse;
import jota.dto.response.GetTipsResponse;
import jota.dto.response.GetTransactionsToApproveResponse;
import jota.dto.response.GetTrytesResponse;
import jota.dto.response.InterruptAttachingToTangleResponse;
import jota.dto.response.RemoveNeighborsResponse;
import jota.dto.response.StoreTransactionsResponse;
import jota.dto.request.*;
import jota.dto.response.*;
import jota.model.Bundle;
import jota.model.Input;
import jota.model.Transaction;
@@ -51,11 +10,20 @@ import jota.utils.Converter;
import jota.utils.InputValidator;
import jota.utils.IotaAPIUtils;
import okhttp3.OkHttpClient;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* IotaAPIProxy Builder. Usage:
*
@@ -413,7 +381,7 @@ public class IotaAPIProxy {
// Get total length, message / maxLength (2187 trytes)
signatureMessageLength += Math.floor(transfer.getMessage().length() / 2187);
String msgCopy = new String(transfer.getMessage());
String msgCopy = transfer.getMessage();
// While there is still a message, copy it
while (!msgCopy.isEmpty()) {
@@ -598,7 +566,7 @@ public class IotaAPIProxy {
// Increase totalBalance of all aggregated inputs
totalBalance += balance;
if (thresholdReached == false && totalBalance >= threshold) {
if (!thresholdReached && totalBalance >= threshold) {
thresholdReached = true;
break;
}
+6 -10
View File
@@ -1,7 +1,6 @@
package jota.model;
import jota.pow.Curl;
import jota.utils.Constants;
import jota.utils.Converter;
import java.util.ArrayList;
@@ -43,18 +42,14 @@ public class Bundle {
this.length = length;
}
public void addEntry(int signatureMessageLength, String slice, long value, String tag, long timestamp) {
public void addEntry(int signatureMessageLength, String address, long value, String tag, long timestamp) {
for (int i = 0; i < signatureMessageLength; i++) {
//TODO
/* var transactionObject = new Object();
transactionObject.address = address;
transactionObject.value = i == 0 ? value : 0;
transactionObject.tag = tag;
transactionObject.timestamp = timestamp;
List<Transaction> transactions = new ArrayList<>(getTransactions());
transactions.add(new Transaction(address, String.valueOf(i == 0 ? value : 0), tag, String.valueOf(timestamp)));
setTransactions(transactions);
this.bundle[this.bundle.length] = transactionObject;
*/
}
}
@@ -84,6 +79,7 @@ public class Bundle {
while (lastIndexTrits.length < 27) {
lastIndexTrits[lastIndexTrits.length] = 0;
}
int[] t = Converter.trits(this.getTransactions().get(i).getAddress() + Converter.trytes(valueTrits) + this.getTransactions().get(i).getTag() + Converter.trytes(timestampTrits) + Converter.trytes(currentIndexTrits) + Converter.trytes(lastIndexTrits));
curl.absorb(t, 0, t.length);
}
@@ -41,6 +41,14 @@ public class Transaction {
this.nonce = nonce;
}
public Transaction(String address, String value, String tag, String timestamp) {
this.address = address;
this.value = value;
this.tag = tag;
this.timestamp = timestamp;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);