Repository navigation
Expand file tree
/
Copy pathIotaCoreApiTest.java
More file actions
137 lines (116 loc) · 5.63 KB
/
Copy pathIotaCoreApiTest.java
File metadata and controls
137 lines (116 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package jota;
import com.google.gson.Gson;
import jota.dto.response.*;
import org.hamcrest.core.IsNull;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertThat;
/**
* @author Adrian
*/
public class IotaCoreApiTest {
private static final String TEST_BUNDLE = "XZKJUUMQOYUQFKMWQZNTFMSS9FKJLOEV9DXXXWPMQRTNCOUSUQNTBIJTVORLOQPLYZOTMLFRHYKMTGZZU";
private static final String TEST_ADDRESS_WITH_CHECKSUM = "PNGMCSNRCTRHCHPXYTPKEJYPCOWKOMRXZFHH9N9VDIKMNVAZCMIYRHVJIAZARZTUETJVFDMBEBIQE9QTHBFWDAOEFA";
private static final String TEST_HASH = "OOAARHCXXCPMNZPUEYOOUIUCTWZSQGKNIECIKRBNUUJEVMLJAWGCXREXEQGNJUJKUXXQAWWAZYKB99999";
private static IotaAPICore proxy;
@Before
public void createProxyInstance() {
proxy = new IotaAPICore.Builder().build();
}
@Test
public void shouldGetNodeInfo() {
GetNodeInfoResponse nodeInfo = proxy.getNodeInfo();
System.out.println(new Gson().toJson(nodeInfo));
assertThat(nodeInfo.getAppVersion(), IsNull.notNullValue());
assertThat(nodeInfo.getAppName(), IsNull.notNullValue());
assertThat(nodeInfo.getJreVersion(), IsNull.notNullValue());
assertThat(nodeInfo.getJreAvailableProcessors(), IsNull.notNullValue());
assertThat(nodeInfo.getJreFreeMemory(), IsNull.notNullValue());
assertThat(nodeInfo.getJreMaxMemory(), IsNull.notNullValue());
assertThat(nodeInfo.getJreTotalMemory(), IsNull.notNullValue());
assertThat(nodeInfo.getLatestMilestone(), IsNull.notNullValue());
assertThat(nodeInfo.getLatestMilestoneIndex(), IsNull.notNullValue());
assertThat(nodeInfo.getLatestSolidSubtangleMilestone(), IsNull.notNullValue());
assertThat(nodeInfo.getLatestSolidSubtangleMilestoneIndex(), IsNull.notNullValue());
assertThat(nodeInfo.getNeighbors(), IsNull.notNullValue());
assertThat(nodeInfo.getPacketsQueueSize(), IsNull.notNullValue());
assertThat(nodeInfo.getTime(), IsNull.notNullValue());
assertThat(nodeInfo.getTips(), IsNull.notNullValue());
assertThat(nodeInfo.getTransactionsToRequest(), IsNull.notNullValue());
}
@Test
public void shouldGetNeighbors() {
GetNeighborsResponse neighbors = proxy.getNeighbors();
assertThat(neighbors.getNeighbors(), IsNull.notNullValue());
}
@Test(expected = IllegalAccessError.class)
public void shouldAddNeighbors() {
AddNeighborsResponse res = proxy.addNeighbors("udp://8.8.8.8:14265");
assertThat(res, IsNull.notNullValue());
}
@Test(expected = IllegalAccessError.class)
public void shouldRemoveNeighbors() {
RemoveNeighborsResponse res = proxy.removeNeighbors("udp://8.8.8.8:14265");
assertThat(res, IsNull.notNullValue());
}
@Test
public void shouldGetTips() {
GetTipsResponse tips = proxy.getTips();
assertThat(tips, IsNull.notNullValue());
}
@Test
public void shouldFindTransactionsByAddresses() {
FindTransactionResponse trans = proxy.findTransactionsByAddresses(TEST_ADDRESS_WITH_CHECKSUM);
assertThat(trans.getHashes(), IsNull.notNullValue());
}
@Test
public void shouldFindTransactionsByApprovees() {
FindTransactionResponse trans = proxy.findTransactionsByApprovees(TEST_HASH);
assertThat(trans.getHashes(), IsNull.notNullValue());
}
@Test
public void shouldFindTransactionsByBundles() {
FindTransactionResponse trans = proxy.findTransactionsByBundles(TEST_HASH);
assertThat(trans.getHashes(), IsNull.notNullValue());
}
@Test
public void shouldFindTransactionsByDigests() {
FindTransactionResponse trans = proxy.findTransactionsByDigests(TEST_HASH);
assertThat(trans.getHashes(), IsNull.notNullValue());
}
@Test
public void shouldGetTrytes() {
GetTrytesResponse res = proxy.getTrytes(TEST_HASH);
assertThat(res.getTrytes(), IsNull.notNullValue());
}
@Test(expected = IllegalAccessError.class)
public void shouldNotGetInclusionStates() {
GetInclusionStateResponse res = proxy.getInclusionStates(new String[]{"DBPECSH9YLSSTQDGERUHJBBJTKVUDBMTJLG9WPHBINGHIFOSJMDJLARTVOXXWEFQJLLBINOHCZGYFSMUEXWPPMTOFW"}, new String[]{"EJDQOQHMLJGBMFWB9WJSPRCYIGNPO9WRHDCEQXIMPVPIJ9JV9RJGVHNX9EPGXFOOKBABCVMMAAX999999"});
assertThat(res.getStates(), IsNull.notNullValue());
}
@Test
public void shouldGetInclusionStates() {
GetInclusionStateResponse res = proxy.getInclusionStates(new String[]{TEST_ADDRESS_WITH_CHECKSUM}, new String[]{proxy.getNodeInfo().getLatestSolidSubtangleMilestone()});
assertThat(res.getStates(), IsNull.notNullValue());
}
@Test // very long execution
public void shouldGetTransactionsToApprove() {
GetTransactionsToApproveResponse res = proxy.getTransactionsToApprove(27);
assertThat(res.getTrunkTransaction(), IsNull.notNullValue());
assertThat(res.getBranchTransaction(), IsNull.notNullValue());
}
@Test
public void shouldFindTransactions() {
String test = TEST_BUNDLE;
FindTransactionResponse resp = proxy.findTransactions(new String[]{test}, new String[]{test}, new String[]{test}, new String[]{test});
System.out.println(new Gson().toJson(resp));
}
@Test
public void shouldGetBalances() {
GetBalancesResponse res = proxy.getBalances(100, new String[]{TEST_ADDRESS_WITH_CHECKSUM});
assertThat(res.getBalances(), IsNull.notNullValue());
assertThat(res.getMilestone(), IsNull.notNullValue());
assertThat(res.getMilestoneIndex(), IsNull.notNullValue());
assertThat(res.getDuration(), IsNull.notNullValue());
}
}