updated tests (#8)

This commit is contained in:
Oliver Nitzschke
2016-12-07 15:19:24 +01:00
committed by Gianluigi Davassi
parent d0dbff07fe
commit 9173bb9fb6
3 changed files with 13 additions and 42 deletions
+2 -8
View File
@@ -1,11 +1,10 @@
package jota.utils;
import jota.dto.response.GetBundleResponse;
import org.apache.commons.lang3.NotImplementedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jota.dto.response.GetBundleResponse;
/**
* Client Side computation service
*
@@ -26,14 +25,9 @@ public class IotaAPIUtils {
public static String newAddress(String seed, int index, boolean checksum) {
final int[] key = Signing.key(Converter.trits(seed), index, 2);
log.debug("key Length = {}", key.length );
final int[] digests = Signing.digests(key);
log.debug("digests Length = {}", digests.length );
final int[] addressTrits = Signing.address(digests);
log.debug("addressTrits Length = {}", addressTrits.length );
String address = Converter.trytes(addressTrits);
if (checksum) {
@@ -1,20 +0,0 @@
package jota;
import jota.utils.IotaAPIUtils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by Adrian on 02.12.2016.
*/
public class AddressGenerationTest {
private static String TEST_SEED = "ZEB99QTOMYDSKIFCXTLTVSWQFKO9CRKQKMRDR9HWVOVSGZMWPFQIMSCXXWUULHD9MZKMFJZAYZHZYA9VZ";
private static String FIRST_ADDRESS = "LCZXWAQUHBXST9IEPPMJICTWLKJA9HVASXWDIRCVNM9TUAGZY9SRRJLZMZQIZKBAESXXNABFATUAYQYYW";
@Test
public void shouldAddChecksum() {
assertEquals(IotaAPIUtils.newAddress(TEST_SEED,0, false),FIRST_ADDRESS);
}
}
+11 -14
View File
@@ -3,8 +3,6 @@ package jota;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import jota.dto.response.*;
import jota.utils.IotaAPIUtils;
import org.hamcrest.core.Is;
import org.hamcrest.core.IsNull;
import org.junit.Before;
@@ -12,7 +10,6 @@ import org.junit.Test;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
/**
@@ -78,19 +75,19 @@ public class IotaAPIProxyTest {
@Test
public void shouldFindTransactionsByApprovees() {
FindTransactionResponse trans = proxy.findTransactionsByApprovees(new String[]{"123ABC"});
FindTransactionResponse trans = proxy.findTransactionsByApprovees(new String[]{TEST_HASH});
assertThat(trans, IsNull.notNullValue());
}
@Test
public void shouldFindTransactionsByBundles() {
FindTransactionResponse trans = proxy.findTransactionsByBundles(new String[]{"123ABC"});
FindTransactionResponse trans = proxy.findTransactionsByBundles(TEST_HASH);
assertThat(trans, IsNull.notNullValue());
}
@Test
public void shouldFindTransactionsByDigests() {
FindTransactionResponse trans = proxy.findTransactionsByDigests(new String[]{"123ABC"});
FindTransactionResponse trans = proxy.findTransactionsByDigests(TEST_HASH);
assertThat(trans, IsNull.notNullValue());
}
@@ -100,13 +97,13 @@ public class IotaAPIProxyTest {
@Test
public void shouldGetTrytes() {
GetTrytesResponse res = proxy.getTrytes(TEST_HASH);
assertThat(res, IsNull.nullValue());
assertThat(res, IsNull.notNullValue());
}
@Test
public void shouldGetInclusionStates() {
GetInclusionStateResponse res = proxy.getInclusionStates(new String[]{TEST_ADDRESS_WITH_CHECKSUM},
new String[]{"123"});
GetInclusionStateResponse res = proxy.getInclusionStates(new String[]{TEST_ADDRESS_WITH_CHECKSUM}, new String[]{"DNSBRJWNOVUCQPILOQIFDKBFJMVOTGHLIMLLRXOHFTJZGRHJUEDAOWXQRYGDI9KHYFGYDWQJZKX999999"});
assertThat(res, IsNull.notNullValue());
}
@@ -118,7 +115,7 @@ public class IotaAPIProxyTest {
@Test
public void shouldGetBalances() {
GetBalancesResponse res = proxy.getBalances(100, new String[]{"HBBYKAKTILIPVUKFOTSLHGENPTXYBNKXZFQFR9VQFWNBMTQNRVOUKPVPRNBSZVVILMAFBKOTBLGLWLOHQ"});
GetBalancesResponse res = proxy.getBalances(100, new String[]{TEST_ADDRESS_WITH_CHECKSUM});
System.err.println(res);
assertThat(res, IsNull.notNullValue());
}
@@ -129,9 +126,9 @@ public class IotaAPIProxyTest {
assertThat(proxy, IsNull.notNullValue());
}
/*@Test TODO Fix me
@Test
public void shouldCreateANewAddress() {
final GetNewAddressResponse res = proxy.newAddress(TEST_SEED, 4, false);
assertThat(res.getAddress(), Is.is("GBPQGDMZ99FRNUBLCCIAXOEWNED9T9AMEHCGMMMFYTP9VINCVSNPAXUXBHQ9DIPTOOTP9XXUAUBDBMWMP"));
}*/
final GetNewAddressResponse res = proxy.getNewAddress(TEST_SEED, 0, false, 1, false);
assertThat(res.getAddress(), Is.is(Collections.singletonList(TEST_ADDRESS_WITHOUT_CHECKSUM)));
}
}