9
9
import org .iota .jota .config .types .FileConfig ;
10
10
import org .iota .jota .error .ArgumentException ;
11
11
import org .iota .jota .model .Bundle ;
12
- import org .iota .jota .model .Transaction ;
13
12
import org .iota .jota .pow .pearldiver .PearlDiverLocalPoW ;
14
13
import org .iota .jota .store .JsonFlatFileStore ;
15
14
import org .iota .jota .utils .BundleValidator ;
16
- import org .iota .jota .utils .Signing ;
17
15
import org .junit .jupiter .api .AfterEach ;
18
16
import org .junit .jupiter .api .BeforeEach ;
19
17
import org .junit .jupiter .api .Test ;
22
20
import java .io .File ;
23
21
import java .io .IOException ;
24
22
import java .util .Date ;
25
- import java .util .LinkedList ;
26
- import java .util .List ;
27
23
import java .util .concurrent .ExecutionException ;
28
24
29
25
import static org .junit .jupiter .api .Assertions .*;
@@ -40,8 +36,8 @@ public class IotaAccountIntegrationTest {
40
36
41
37
private static final String TEST_SEED = "IJEEPFTJEFGFRDTSQGLGEAUZPUJFP9LDMDOOYUNOZFJ9JMJFALJATJGHEUPHHFVTFDYSGZNKMRK9EQKWG" ;
42
38
private static final String TEST_SEED_ID = "J9SPZIPMIHEGZEBNDLMBTVVTCGQREQXZFXUYTJTYVQCR9TUZWZDBSJBOZLTTLJYXCGGVAIEQFPWLNUGHD" ;
43
- private static final String ADDR_0_SEC_3 = "TAKWNELREDNHLFYCQ9LMGZVYGTPTABFDEPQZILJAYAZSSCPXMEGCVAH9AHTJRDPVDCGIH9APCWG9KBSGA9VKXRLMU9" ;
44
- private static final String ADDR_1_SEC_3 = "LJGVBUTNFABXQUGMQROIMVXAPHAPXGZUFDMLALGSNUBAZLONQCKAUIMNUIHEDVRMBUEPUMCLHQZHVHCZBRGGLRBGAC" ;
39
+ private static final String ADDR_1_SEC_3 = "TAKWNELREDNHLFYCQ9LMGZVYGTPTABFDEPQZILJAYAZSSCPXMEGCVAH9AHTJRDPVDCGIH9APCWG9KBSGA9VKXRLMU9" ;
40
+ private static final String ADDR_2_SEC_3 = "LJGVBUTNFABXQUGMQROIMVXAPHAPXGZUFDMLALGSNUBAZLONQCKAUIMNUIHEDVRMBUEPUMCLHQZHVHCZBRGGLRBGAC" ;
45
41
private IotaAPI iotaAPI ;
46
42
47
43
private File file ;
@@ -51,7 +47,10 @@ public class IotaAccountIntegrationTest {
51
47
@ BeforeEach
52
48
public void setUp () throws Exception {
53
49
file = File .createTempFile ("client" , "account" );
54
- iotaAPI = new IotaAPI .Builder ().config (new FileConfig ()).localPoW (new PearlDiverLocalPoW ()).build ();
50
+ iotaAPI = new IotaAPI .Builder ()
51
+ .config (new FileConfig ())
52
+ .localPoW (new PearlDiverLocalPoW ())
53
+ .build ();
55
54
}
56
55
57
56
@ AfterEach
@@ -65,7 +64,12 @@ public void tearDown() throws IOException {
65
64
@ Test
66
65
void load () {
67
66
store = new AccountFileStore (file );
68
- IotaAccount account = new IotaAccount .Builder (TEST_SEED ).mwm (9 ).store (store ).api (iotaAPI ).build ();
67
+ IotaAccount account = new IotaAccount .Builder (TEST_SEED )
68
+ .securityLevel (3 )
69
+ .mwm (9 )
70
+ .store (store )
71
+ .api (iotaAPI )
72
+ .build ();
69
73
70
74
assertTrue (account .loaded , "Account should be loaded after build" );
71
75
assertEquals (TEST_SEED_ID , account .getId (), "Account ID should be set to the seed id " );
@@ -105,7 +109,7 @@ void sendLongZeroMessage() throws ArgumentException, SendException, InterruptedE
105
109
106
110
@ Test
107
111
void sendValueTest () throws AccountError , InterruptedException , ExecutionException {
108
- IotaAPI iotaAPI = fakeBalance (ADDR_0_SEC_3 , 5l );
112
+ IotaAPI iotaAPI = fakeBalance (ADDR_1_SEC_3 , 5l );
109
113
110
114
JsonFlatFileStore json = new JsonFlatFileStore (this .getClass ().getResourceAsStream ("/accounts/client-test.store" ), System .out );
111
115
store = new AccountFileStore (json );
@@ -119,24 +123,12 @@ void sendValueTest() throws AccountError, InterruptedException, ExecutionExcepti
119
123
"Another IOTA Accounts test run at " + new Date ().toString (),
120
124
"IOTA9ACCOUNTS" ).get ();
121
125
122
- List <Transaction > res = iotaAPI .findTransactionObjectsByBundle (sent .getBundleHash ());
123
- Bundle remote = new Bundle (res );
124
-
125
- Signing sig = new Signing ();
126
- boolean valid = sig .validateSignatures (sent , sent .getTransactions ().get (1 ).getAddress ());
127
-
128
- String [] fragments = new String [] {
129
- sent .getTransactions ().get (2 ).getSignatureFragments (),
130
- sent .getTransactions ().get (1 ).getSignatureFragments ()
131
- };
132
- boolean valid2 = sig .validateSignatures (sent .getTransactions ().get (1 ).getAddress (), fragments , sent .getBundleHash ());
133
-
134
126
assertTrue (BundleValidator .isBundle (sent ), "Should be a valid bundle" );
135
127
}
136
128
137
129
@ Test
138
130
void sendLongValueTest () throws AccountError , InterruptedException , ExecutionException {
139
- IotaAPI iotaAPI = fakeBalance (ADDR_0_SEC_3 , 10l );
131
+ IotaAPI iotaAPI = fakeBalance (ADDR_1_SEC_3 , 10l );
140
132
141
133
JsonFlatFileStore json = new JsonFlatFileStore (this .getClass ().getResourceAsStream ("/accounts/client-test.store" ), System .out );
142
134
store = new AccountFileStore (json );
@@ -146,26 +138,45 @@ void sendLongValueTest() throws AccountError, InterruptedException, ExecutionExc
146
138
Date timeOut = new Date (Long .MAX_VALUE );
147
139
ConditionalDepositAddress cda = account .newDepositAddress (timeOut , false , 10 ).get ();
148
140
149
- Bundle sent = account .send (cda .getDepositAddress ().getHashCheckSum (), 1 ,
141
+ Bundle sent = account .send (cda .getDepositAddress ().getHashCheckSum (), 10 ,
150
142
lorem , "IOTA9ACCOUNTS" ).get ();
151
143
152
144
assertTrue (BundleValidator .isBundle (sent ), "Should be a valid bundle" );
153
145
}
154
146
155
147
@ Test
156
148
void sendLongMultiValueTest () throws AccountError , InterruptedException , ExecutionException {
157
- IotaAPI iotaAPI = fakeBalance (ADDR_0_SEC_3 , 5l );
158
- iotaAPI = fakeBalance (ADDR_1_SEC_3 , 5l , iotaAPI );
149
+ IotaAPI iotaAPI = fakeBalance (ADDR_1_SEC_3 , 5l );
150
+ iotaAPI = fakeBalance (ADDR_2_SEC_3 , 5l , iotaAPI );
159
151
160
- JsonFlatFileStore json = new JsonFlatFileStore (this .getClass ().getResourceAsStream ("/accounts/client-test.store" ), System .out );
152
+ JsonFlatFileStore json = new JsonFlatFileStore (this .getClass ().getResourceAsStream ("/accounts/client-testMulti.store" ), System .out );
153
+ store = new AccountFileStore (json );
154
+
155
+ IotaAccount account = new IotaAccount .Builder (TEST_SEED ).mwm (9 ).store (store ).api (iotaAPI ).build ();
156
+
157
+ Date timeOut = new Date (Long .MAX_VALUE );
158
+ ConditionalDepositAddress cda = account .newDepositAddress (timeOut , false , 10 ).get ();
159
+
160
+ Bundle sent = account .send (cda .getDepositAddress ().getHashCheckSum (), 10 ,
161
+ lorem , "IOTA9ACCOUNTS" ).get ();
162
+
163
+ assertTrue (BundleValidator .isBundle (sent ), "Should be a valid bundle" );
164
+ }
165
+
166
+ @ Test
167
+ void sendLongMultiValueRemainderTest () throws AccountError , InterruptedException , ExecutionException {
168
+ IotaAPI iotaAPI = fakeBalance (ADDR_1_SEC_3 , 6l );
169
+ iotaAPI = fakeBalance (ADDR_2_SEC_3 , 5l , iotaAPI );
170
+
171
+ JsonFlatFileStore json = new JsonFlatFileStore (this .getClass ().getResourceAsStream ("/accounts/client-testMulti.store" ), System .out );
161
172
store = new AccountFileStore (json );
162
173
163
174
IotaAccount account = new IotaAccount .Builder (TEST_SEED ).mwm (9 ).store (store ).api (iotaAPI ).build ();
164
175
165
176
Date timeOut = new Date (Long .MAX_VALUE );
166
177
ConditionalDepositAddress cda = account .newDepositAddress (timeOut , false , 10 ).get ();
167
178
168
- Bundle sent = account .send (cda .getDepositAddress ().getHashCheckSum (), 1 ,
179
+ Bundle sent = account .send (cda .getDepositAddress ().getHashCheckSum (), 10 ,
169
180
lorem , "IOTA9ACCOUNTS" ).get ();
170
181
171
182
assertTrue (BundleValidator .isBundle (sent ), "Should be a valid bundle" );
0 commit comments