@@ -57,18 +57,20 @@ public class E2EAggregateTest extends E2EBaseTest {
57
57
private final Account bob = new Account (new KeyPair (), getNetworkType ());
58
58
private final Account mike = new Account (new KeyPair (), getNetworkType ());
59
59
60
- private final MosaicId mosaicX = new MosaicId (UInt64Utils .fromLongArray (new long [] {481110499 ,231112638 }));
61
- private final MosaicId mosaicY = new MosaicId (UInt64Utils .fromLongArray (new long [] {519256100 ,642862634 }));
62
-
63
-
60
+ private final MosaicId mosaicX = new MosaicId (UInt64Utils .fromLongArray (new long [] { 481110499 , 231112638 }));
61
+ private final MosaicId mosaicY = new MosaicId (UInt64Utils .fromLongArray (new long [] { 519256100 , 642862634 }));
62
+
64
63
@ BeforeAll
65
64
void addListener () {
66
- disposables .add (listener .status (alice .getAddress ())
67
- .subscribe (err -> logger .error ("Operation failed for alice: {}" , err ), t -> logger .error ("exception thrown" , t )));
68
- disposables .add (listener .status (bob .getAddress ())
69
- .subscribe (err -> logger .error ("Operation failed for bob: {}" , err ), t -> logger .error ("exception thrown" , t )));
70
- disposables .add (listener .status (mike .getAddress ())
71
- .subscribe (err -> logger .error ("Operation failed for mike: {}" , err ), t -> logger .error ("exception thrown" , t )));
65
+ disposables .add (
66
+ listener .status (alice .getAddress ()).subscribe (err -> logger .error ("Operation failed for alice: {}" , err ),
67
+ t -> logger .error ("exception thrown" , t )));
68
+ disposables
69
+ .add (listener .status (bob .getAddress ()).subscribe (err -> logger .error ("Operation failed for bob: {}" , err ),
70
+ t -> logger .error ("exception thrown" , t )));
71
+ disposables
72
+ .add (listener .status (mike .getAddress ()).subscribe (err -> logger .error ("Operation failed for mike: {}" , err ),
73
+ t -> logger .error ("exception thrown" , t )));
72
74
// send funds to alice and bob
73
75
logger .info ("Mosaic X: {}" , mosaicX .getIdAsHex ());
74
76
logger .info ("Mosaic Y: {}" , mosaicY .getIdAsHex ());
@@ -97,36 +99,28 @@ void escrowBetweenTwoParties() {
97
99
sendMosaic (seedAccount , bob .getAddress (), new Mosaic (mosaicY , BigInteger .TEN ));
98
100
logger .info ("Escrow between {} and {}" , alice , bob );
99
101
// send mosaic X from alice to bob
100
- TransferTransaction aliceToBob = TransferTransaction .create (getDeadline (),
101
- bob .getAddress (),
102
- Arrays .asList (NetworkCurrencyMosaic .ONE ),
103
- PlainMessage .Empty ,
104
- getNetworkType ());
102
+ TransferTransaction aliceToBob = transact .transfer ().mosaics (NetworkCurrencyMosaic .ONE ).to (bob .getAddress ())
103
+ .build ();
105
104
// send mosaic Y from bob to alice
106
- TransferTransaction bobToAlice = TransferTransaction .create (getDeadline (),
107
- alice .getAddress (),
108
- Arrays .asList (new Mosaic (mosaicY , BigInteger .TEN )),
109
- PlainMessage .Empty ,
110
- getNetworkType ());
105
+ TransferTransaction bobToAlice = transact .transfer ().mosaics (new Mosaic (mosaicY , BigInteger .TEN ))
106
+ .to (alice .getAddress ()).build ();
111
107
// aggregate bonded with the 2 transactions - escrow
112
- AggregateTransaction escrow = AggregateTransaction . createBonded ( getDeadline (),
113
- Arrays . asList (aliceToBob .toAggregate (alice .getPublicAccount ()),
114
- bobToAlice .toAggregate (bob .getPublicAccount ())),
115
- getNetworkType () );
108
+ AggregateTransaction escrow = transact . aggregateBonded ()
109
+ . innerTransactions (aliceToBob .toAggregate (alice .getPublicAccount ()),
110
+ bobToAlice .toAggregate (bob .getPublicAccount ()))
111
+ . build ( );
116
112
// alice sign the escrow trans
117
113
SignedTransaction signedEscrow = api .sign (escrow , alice );
118
114
// lock funds for escrow
119
- LockFundsTransaction lock = LockFundsTransaction .create (getDeadline (),
120
- NetworkCurrencyMosaic .TEN ,
121
- BigInteger .valueOf (480 ),
122
- signedEscrow ,
123
- getNetworkType ());
115
+ LockFundsTransaction lock = transact .lockFunds ().mosaic (NetworkCurrencyMosaic .TEN )
116
+ .duration (BigInteger .valueOf (480 )).signedTransaction (signedEscrow ).build ();
124
117
// alice sign and announce the lock
125
118
logger .info ("announcing {}" , lock );
126
119
SignedTransaction signedLock = api .sign (lock , alice );
127
120
transactionHttp .announce (signedLock ).blockingFirst ();
128
121
// wait for lock confirmation
129
- logger .info ("got confirmation: {}" , listener .confirmed (alice .getAddress ()).timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ());
122
+ logger .info ("got confirmation: {}" ,
123
+ listener .confirmed (alice .getAddress ()).timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ());
130
124
sleepForAWhile ();
131
125
// announce escrow
132
126
logger .info ("announcing {}" , escrow );
@@ -135,7 +129,8 @@ void escrowBetweenTwoParties() {
135
129
listener .aggregateBondedAdded (alice .getAddress ()).timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ();
136
130
137
131
// bob sign the escrow
138
- AggregateTransaction pendingEscrow = accountHttp .aggregateBondedTransactions (bob .getPublicAccount ()).timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ().get (0 );
132
+ AggregateTransaction pendingEscrow = accountHttp .aggregateBondedTransactions (bob .getPublicAccount ())
133
+ .timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ().get (0 );
139
134
CosignatureSignedTransaction signedCosig = CosignatureTransaction .create (pendingEscrow ).signWith (bob );
140
135
// bob announce the cosignature
141
136
logger .info ("announcing escrow" );
@@ -166,7 +161,7 @@ void escrowBetweenTwoParties() {
166
161
}
167
162
});
168
163
}
169
-
164
+
170
165
@ Test
171
166
void escrowBetweenTwoPartiesComplete () {
172
167
returnAllToSeed (alice );
@@ -176,22 +171,16 @@ void escrowBetweenTwoPartiesComplete() {
176
171
sendMosaic (seedAccount , bob .getAddress (), new Mosaic (mosaicY , BigInteger .TEN ));
177
172
logger .info ("Escrow between {} and {}" , alice , bob );
178
173
// send mosaic X from alice to bob
179
- TransferTransaction aliceToBob = TransferTransaction .create (getDeadline (),
180
- bob .getAddress (),
181
- Arrays .asList (NetworkCurrencyMosaic .ONE ),
182
- PlainMessage .Empty ,
183
- getNetworkType ());
174
+ TransferTransaction aliceToBob = transact .transfer ().mosaics (NetworkCurrencyMosaic .ONE ).to (bob .getAddress ())
175
+ .build ();
184
176
// send mosaic Y from bob to alice
185
- TransferTransaction bobToAlice = TransferTransaction .create (getDeadline (),
186
- alice .getAddress (),
187
- Arrays .asList (new Mosaic (mosaicY , BigInteger .TEN )),
188
- PlainMessage .Empty ,
189
- getNetworkType ());
177
+ TransferTransaction bobToAlice = transact .transfer ().mosaics (new Mosaic (mosaicY , BigInteger .TEN ))
178
+ .to (alice .getAddress ()).build ();
190
179
// aggregate bonded with the 2 transactions - escrow
191
- AggregateTransaction escrow = AggregateTransaction . createComplete ( getDeadline (),
192
- Arrays . asList (aliceToBob .toAggregate (alice .getPublicAccount ()),
193
- bobToAlice .toAggregate (bob .getPublicAccount ())),
194
- getNetworkType () );
180
+ AggregateTransaction escrow = transact . aggregateComplete ()
181
+ . innerTransactions (aliceToBob .toAggregate (alice .getPublicAccount ()),
182
+ bobToAlice .toAggregate (bob .getPublicAccount ()))
183
+ . build ( );
195
184
// alice sign the escrow trans
196
185
SignedTransaction signedEscrow = api .signWithCosigners (escrow , alice , Arrays .asList (bob ));
197
186
// announce escrow
@@ -223,7 +212,7 @@ void escrowBetweenTwoPartiesComplete() {
223
212
}
224
213
});
225
214
}
226
-
215
+
227
216
@ Test
228
217
void escrowBetweenThreeParties () {
229
218
returnAllToSeed (alice );
@@ -236,38 +225,25 @@ void escrowBetweenThreeParties() {
236
225
sleepForAWhile ();
237
226
logger .info ("Escrow between {}, {} and {}" , alice , bob , mike );
238
227
// send mosaic X from alice to bob
239
- TransferTransaction aliceToBob = TransferTransaction .create (getDeadline (),
240
- bob .getAddress (),
241
- Arrays .asList (NetworkCurrencyMosaic .ONE ),
242
- PlainMessage .Empty ,
243
- getNetworkType ());
228
+ TransferTransaction aliceToBob = transact .transfer ().mosaics (NetworkCurrencyMosaic .ONE ).to (bob .getAddress ())
229
+ .build ();
244
230
// send mosaic Y from bob to alice
245
- TransferTransaction bobToAlice = TransferTransaction .create (getDeadline (),
246
- alice .getAddress (),
247
- Arrays .asList (new Mosaic (mosaicY , BigInteger .TEN )),
248
- PlainMessage .Empty ,
249
- getNetworkType ());
231
+ TransferTransaction bobToAlice = transact .transfer ().mosaics (new Mosaic (mosaicY , BigInteger .TEN ))
232
+ .to (alice .getAddress ()).build ();
250
233
// send mosaic Y from bob to alice
251
- TransferTransaction mikeToAlice = TransferTransaction .create (getDeadline (),
252
- alice .getAddress (),
253
- Arrays .asList (NetworkCurrencyMosaic .ONE ),
254
- PlainMessage .Empty ,
255
- getNetworkType ());
234
+ TransferTransaction mikeToAlice = transact .transfer ().mosaics (NetworkCurrencyMosaic .ONE ).to (alice .getAddress ())
235
+ .build ();
256
236
// aggregate bonded with the 3 transactions - escrow
257
- AggregateTransaction escrow = AggregateTransaction .createBonded (getDeadline (),
258
- Arrays .asList (
259
- aliceToBob .toAggregate (alice .getPublicAccount ()),
237
+ AggregateTransaction escrow = transact .aggregateBonded ()
238
+ .innerTransactions (aliceToBob .toAggregate (alice .getPublicAccount ()),
260
239
bobToAlice .toAggregate (bob .getPublicAccount ()),
261
- mikeToAlice .toAggregate (mike .getPublicAccount ())),
262
- getNetworkType () );
240
+ mikeToAlice .toAggregate (mike .getPublicAccount ()))
241
+ . build ( );
263
242
// alice sign the escrow trans
264
243
SignedTransaction signedEscrow = api .sign (escrow , alice );
265
244
// lock funds for escrow
266
- LockFundsTransaction lock = LockFundsTransaction .create (getDeadline (),
267
- NetworkCurrencyMosaic .TEN ,
268
- BigInteger .valueOf (480 ),
269
- signedEscrow ,
270
- getNetworkType ());
245
+ LockFundsTransaction lock = transact .lockFunds ().mosaic (NetworkCurrencyMosaic .TEN )
246
+ .duration (BigInteger .valueOf (480 )).signedTransaction (signedEscrow ).build ();
271
247
// alice sign and announce the lock
272
248
logger .info ("announcing {}" , lock );
273
249
SignedTransaction signedLock = api .sign (lock , alice );
@@ -280,18 +256,20 @@ void escrowBetweenThreeParties() {
280
256
transactionHttp .announceAggregateBonded (signedEscrow ).blockingFirst ();
281
257
// wait for escrow confirmation
282
258
listener .aggregateBondedAdded (alice .getAddress ()).timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ();
283
-
259
+
284
260
// bob sign the escrow
285
- AggregateTransaction pendingEscrowBob = accountHttp .aggregateBondedTransactions (bob .getPublicAccount ()).timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ().get (0 );
261
+ AggregateTransaction pendingEscrowBob = accountHttp .aggregateBondedTransactions (bob .getPublicAccount ())
262
+ .timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ().get (0 );
286
263
CosignatureSignedTransaction signedCosigBob = CosignatureTransaction .create (pendingEscrowBob ).signWith (bob );
287
264
// bob announce the cosignature
288
265
logger .info ("announcing cosig bob" );
289
266
transactionHttp .announceAggregateBondedCosignature (signedCosigBob ).blockingFirst ();
290
267
// wait for cosig event
291
268
listener .cosignatureAdded (bob .getAddress ()).timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ();
292
-
269
+
293
270
// mike sign the escrow
294
- AggregateTransaction pendingEscrowMike = accountHttp .aggregateBondedTransactions (mike .getPublicAccount ()).timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ().get (0 );
271
+ AggregateTransaction pendingEscrowMike = accountHttp .aggregateBondedTransactions (mike .getPublicAccount ())
272
+ .timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ().get (0 );
295
273
CosignatureSignedTransaction signedCosigMike = CosignatureTransaction .create (pendingEscrowMike ).signWith (mike );
296
274
// mike announce the cosignature
297
275
logger .info ("announcing cosig mike" );
@@ -329,7 +307,7 @@ void escrowBetweenThreeParties() {
329
307
List <Mosaic > mikeMosaics = accountHttp .getAccountInfo (mike .getAddress ()).blockingFirst ().getMosaics ();
330
308
assertTrue (mikeMosaics .isEmpty ());
331
309
}
332
-
310
+
333
311
@ Test
334
312
void askforMoney () {
335
313
returnAllToSeed (alice );
@@ -338,30 +316,21 @@ void askforMoney() {
338
316
sendMosaic (seedAccount , bob .getAddress (), new Mosaic (mosaicY , BigInteger .TEN ));
339
317
logger .info ("Alice asks for money" );
340
318
// send mosaic X from alice to bob
341
- TransferTransaction aliceToBob = TransferTransaction .create (getDeadline (),
342
- bob .getAddress (),
343
- Arrays .asList (),
344
- PlainMessage .create ("send me 10 Y" ),
345
- getNetworkType ());
319
+ TransferTransaction aliceToBob = transact .transfer ().to (bob .getAddress ())
320
+ .message (PlainMessage .create ("send me 10 Y" )).build ();
346
321
// send mosaic Y from bob to alice
347
- TransferTransaction bobToAlice = TransferTransaction .create (getDeadline (),
348
- alice .getAddress (),
349
- Arrays .asList (new Mosaic (mosaicY , BigInteger .TEN )),
350
- PlainMessage .Empty ,
351
- getNetworkType ());
322
+ TransferTransaction bobToAlice = transact .transfer ().mosaics (new Mosaic (mosaicY , BigInteger .TEN ))
323
+ .to (alice .getAddress ()).build ();
352
324
// aggregate bonded with the 2 transactions - escrow
353
- AggregateTransaction escrow = AggregateTransaction . createBonded ( getDeadline (),
354
- Arrays . asList (aliceToBob .toAggregate (alice .getPublicAccount ()),
355
- bobToAlice .toAggregate (bob .getPublicAccount ())),
356
- getNetworkType () );
325
+ AggregateTransaction escrow = transact . aggregateBonded ()
326
+ . innerTransactions (aliceToBob .toAggregate (alice .getPublicAccount ()),
327
+ bobToAlice .toAggregate (bob .getPublicAccount ()))
328
+ . build ( );
357
329
// alice sign the escrow trans
358
330
SignedTransaction signedEscrow = api .sign (escrow , alice );
359
331
// lock funds for escrow
360
- LockFundsTransaction lock = LockFundsTransaction .create (getDeadline (),
361
- NetworkCurrencyMosaic .TEN ,
362
- BigInteger .valueOf (480 ),
363
- signedEscrow ,
364
- getNetworkType ());
332
+ LockFundsTransaction lock = transact .lockFunds ().mosaic (NetworkCurrencyMosaic .TEN )
333
+ .duration (BigInteger .valueOf (480 )).signedTransaction (signedEscrow ).build ();
365
334
// alice sign and announce the lock
366
335
logger .info ("announcing {}" , lock );
367
336
SignedTransaction signedLock = api .sign (lock , alice );
@@ -375,7 +344,8 @@ void askforMoney() {
375
344
// wait for escrow confirmation
376
345
listener .aggregateBondedAdded (alice .getAddress ()).timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ();
377
346
// bob sign the escrow
378
- AggregateTransaction pendingEscrow = accountHttp .aggregateBondedTransactions (bob .getPublicAccount ()).timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ().get (0 );
347
+ AggregateTransaction pendingEscrow = accountHttp .aggregateBondedTransactions (bob .getPublicAccount ())
348
+ .timeout (getTimeoutSeconds (), TimeUnit .SECONDS ).blockingFirst ().get (0 );
379
349
CosignatureSignedTransaction signedCosig = CosignatureTransaction .create (pendingEscrow ).signWith (bob );
380
350
// bob announce the cosignature
381
351
logger .info ("announcing escrow" );
0 commit comments