14
14
import com .casper .sdk .model .entity .contract .ByteCode ;
15
15
import com .casper .sdk .model .entity .contract .NamedKey ;
16
16
import com .casper .sdk .model .entity .contract .Package ;
17
- import com .casper .sdk .model .key .AccountHashKey ;
18
- import com .casper .sdk .model .key .PublicKey ;
17
+ import com .casper .sdk .model .key .*;
19
18
import com .casper .sdk .model .transaction .execution .Effect ;
20
19
import com .casper .sdk .model .transaction .kind .*;
21
20
import com .casper .sdk .model .uref .URef ;
@@ -51,7 +50,8 @@ void pruneKindEffect() throws JsonProcessingException {
51
50
"}" ;
52
51
53
52
final Effect pruneEffect = new ObjectMapper ().readValue (json , Effect .class );
54
- assertThat (pruneEffect .getKey (), is ("balance-hold-01fe139a5aa36aa69c04a6b630c9993bc03d868ffde46d3f60c3fbe6e6e762016f78bec10c90010000" ));
53
+ assertThat (pruneEffect .getKey (), is (instanceOf (BalanceHoldKey .class )));
54
+ assertThat (pruneEffect .getKey ().toString (), is ("balance-hold-01fe139a5aa36aa69c04a6b630c9993bc03d868ffde46d3f60c3fbe6e6e762016f78bec10c90010000" ));
55
55
assertThat (pruneEffect , is (notNullValue ()));
56
56
assertThat (pruneEffect .getKind (), is (instanceOf (PruneKind .class )));
57
57
assertThat (((PruneKind ) pruneEffect .getKind ()).getPrune (), is ("balance-hold-01fe139a5aa36aa69c04a6b630c9993bc03d868ffde46d3f60c3fbe6e6e762016f78bec10c90010000" ));
@@ -104,11 +104,11 @@ void writeKindBidKindCreditEffect() throws JsonProcessingException, NoSuchAlgori
104
104
final Effect writeEffect = new ObjectMapper ().readValue (json , Effect .class );
105
105
assertThat (writeEffect , is (notNullValue ()));
106
106
assertThat (writeEffect .getKind (), is (instanceOf (WriteKind .class )));
107
- WriteKind <?> kind = writeEffect .getKind ();
107
+ final WriteKind <?> kind = writeEffect .getKind ();
108
108
assertThat (kind .getWrite ().getValue (), is (instanceOf (BidKind .class )));
109
109
assertThat (kind .getWrite ().getValue (), is (instanceOf (BidKind .class )));
110
110
assertThat (kind .getWrite ().getValue (), is (instanceOf (ValidatorCredit .class )));
111
- ValidatorCredit value = (ValidatorCredit ) kind .getWrite ().getValue ();
111
+ final ValidatorCredit value = (ValidatorCredit ) kind .getWrite ().getValue ();
112
112
assertThat (value .getValidatorPublicKey (), is (PublicKey .fromTaggedHexString ("01284a8cd097808afdea9876ccb91f28702143c04266dea057cc19b8fc382cc258" )));
113
113
assertThat (value .getEraId (), is (377L ));
114
114
assertThat (value .getAmount (), is (new BigInteger ("10000" )));
@@ -134,11 +134,11 @@ void writeKindBidKindBridgeEffect() throws JsonProcessingException, NoSuchAlgori
134
134
final Effect writeEffect = new ObjectMapper ().readValue (json , Effect .class );
135
135
assertThat (writeEffect , is (notNullValue ()));
136
136
assertThat (writeEffect .getKind (), is (instanceOf (WriteKind .class )));
137
- WriteKind <?> kind = writeEffect .getKind ();
137
+ final WriteKind <?> kind = writeEffect .getKind ();
138
138
assertThat (kind .getWrite ().getValue (), is (instanceOf (BidKind .class )));
139
139
assertThat (kind .getWrite ().getValue (), is (instanceOf (BidKind .class )));
140
140
assertThat (kind .getWrite ().getValue (), is (instanceOf (Bridge .class )));
141
- Bridge value = (Bridge ) kind .getWrite ().getValue ();
141
+ final Bridge value = (Bridge ) kind .getWrite ().getValue ();
142
142
assertThat (value .getOldValidatorPublicKey (), is (PublicKey .fromTaggedHexString ("01284a8cd097808afdea9876ccb91f28702143c04266dea057cc19b8fc382cc258" )));
143
143
assertThat (value .getNewValidatorPublicKey (), is (PublicKey .fromTaggedHexString ("01026ca707c348ed8012ac6a1f28db031fadd6eb67203501a353b867a08c8b9a80" )));
144
144
assertThat (value .getEraId (), is (378L ));
@@ -207,7 +207,8 @@ void identityKindEffect() throws JsonProcessingException {
207
207
"}" ;
208
208
209
209
final Effect identityEffect = new ObjectMapper ().readValue (json , Effect .class );
210
- assertThat (identityEffect .getKey (), is ("entity-system-86c4525a60cb6532342f5f598666711219f3bdcc6a8936152ec1c670c510c75f" ));
210
+ assertThat (identityEffect .getKey (), is (instanceOf (AddressableEntityKey .class )));
211
+ assertThat (identityEffect .getKey ().toString (), is ("entity-system-86c4525a60cb6532342f5f598666711219f3bdcc6a8936152ec1c670c510c75f" ));
211
212
assertThat (identityEffect , is (notNullValue ()));
212
213
assertThat (identityEffect .getKind (), is (instanceOf (IdentityKind .class )));
213
214
}
@@ -218,22 +219,22 @@ void identityKindAddUint512() throws JsonProcessingException {
218
219
final String json = "{\n " +
219
220
" \" key\" : \" balance-1c29560834540520e147468c3bf86f09e5bd60cda2cb8380d94ee1c348a4281d\" ,\n " +
220
221
" \" kind\" : {\n " +
221
- " \" AddUInt512\" : 2500000000\n " +
222
- "}\n " +
222
+ " \" AddUInt512\" : 2500000000\n " +
223
+ "}\n " +
223
224
"}" ;
224
225
225
226
final Effect identityEffect = new ObjectMapper ().readValue (json , Effect .class );
226
- assertThat (identityEffect .getKey (), is ("balance-1c29560834540520e147468c3bf86f09e5bd60cda2cb8380d94ee1c348a4281d" ));
227
+ assertThat (identityEffect .getKey (), is (instanceOf (Key .class )));
228
+ assertThat (identityEffect .getKey ().toString (), is ("balance-1c29560834540520e147468c3bf86f09e5bd60cda2cb8380d94ee1c348a4281d" ));
227
229
assertThat (identityEffect , is (notNullValue ()));
228
230
assertThat (identityEffect .getKind (), is (instanceOf (Transform .class )));
229
-
230
231
}
231
232
232
233
@ Test
233
234
void writeKindByteCode () throws JsonProcessingException {
234
235
235
236
final String json = "{\n " +
236
- " \" key\" : \" byte-code-v1-wasm-aaa0345086a4f80601ec93d78053c13f5599afeb752d3d9b88fe5878b611675 \" ,\n " +
237
+ " \" key\" : \" byte-code-v1-wasm-3beb396c91ff7ae62d08857cc8a787146cd4f0771b8a21d385b3f4ac6077854a \" ,\n " +
237
238
" \" kind\" : {\n " +
238
239
" \" Write\" : {\n " +
239
240
" \" ByteCode\" : {\n " +
@@ -245,19 +246,17 @@ void writeKindByteCode() throws JsonProcessingException {
245
246
"}" ;
246
247
247
248
final Effect writeEffect = new ObjectMapper ().readValue (json , Effect .class );
249
+ assertThat (writeEffect .getKey ().toString (), is ("byte-code-v1-wasm-3beb396c91ff7ae62d08857cc8a787146cd4f0771b8a21d385b3f4ac6077854a" ));
248
250
249
- assertThat (writeEffect .getKey (), is ("byte-code-v1-wasm-aaa0345086a4f80601ec93d78053c13f5599afeb752d3d9b88fe5878b611675" ));
250
- WriteKind <?> kind = writeEffect .getKind ();
251
-
251
+ final WriteKind <?> kind = writeEffect .getKind ();
252
252
assertThat (kind .getWrite (), is (instanceOf (ByteCodeKind .class )));
253
253
assertThat (kind .getWrite ().getValue (), is (instanceOf (ByteCode .class )));
254
254
255
- ByteCode byteCodeKind = (ByteCode ) kind .getWrite ().getValue ();
256
-
255
+ final ByteCode byteCodeKind = (ByteCode ) kind .getWrite ().getValue ();
257
256
assertThat (byteCodeKind .getBytes (), is ("0061736d01000000017f106002" ));
258
257
assertThat (byteCodeKind .getKind (), is (ByteCode .ByteCodes .V1CasperWasm ));
259
-
260
258
}
259
+
261
260
@ Test
262
261
void writeKindNamedKey () throws JsonProcessingException {
263
262
@@ -285,25 +284,25 @@ void writeKindNamedKey() throws JsonProcessingException {
285
284
286
285
final Effect writeEffect = new ObjectMapper ().readValue (json , Effect .class );
287
286
288
- assertThat (writeEffect .getKey (), is ("named-key-entity-account-a897e2e1c25b1149e96b774bdfd758d4a44ec392bd914a19ff780d3905ff45c0-e8265cd5ef8e0275971c6d4ff28263ef787412f034631a11bbc508761ffd7119" ));
289
- WriteKind <?> kind = writeEffect .getKind ( );
287
+ assertThat (writeEffect .getKey (), is (instanceOf ( NamedKeyKey . class ) ));
288
+ assertThat ( writeEffect .getKey (). toString (), is ( "named-key-entity-account-a897e2e1c25b1149e96b774bdfd758d4a44ec392bd914a19ff780d3905ff45c0-e8265cd5ef8e0275971c6d4ff28263ef787412f034631a11bbc508761ffd7119" ) );
290
289
290
+ final WriteKind <?> kind = writeEffect .getKind ();
291
291
assertThat (kind .getWrite (), is (instanceOf (NamedKeyKind .class )));
292
292
assertThat (kind .getWrite ().getValue (), is (instanceOf (NamedKey .class )));
293
293
294
- NamedKey namedKeyKind = (NamedKey ) kind .getWrite ().getValue ();
295
-
296
- AbstractCLValue <?,?> namedKey = namedKeyKind .getNamedKey ();
294
+ final NamedKey namedKeyKind = (NamedKey ) kind .getWrite ().getValue ();
295
+ final AbstractCLValue <?, ?> namedKey = namedKeyKind .getNamedKey ();
297
296
assertThat (namedKey .getBytes (), is ("028c5da3dd186f82c27dd4689dca3f838ac17f93ef10a5159fa40a30ca78f9e93207" ));
298
297
assertThat (namedKey .getParsed (), is ("uref-8c5da3dd186f82c27dd4689dca3f838ac17f93ef10a5159fa40a30ca78f9e932-007" ));
299
298
assertThat (namedKey .getClType ().getTypeName (), is ("Key" ));
300
299
301
- AbstractCLValue <?,?> name = namedKeyKind .getName ();
300
+ final AbstractCLValue <?, ?> name = namedKeyKind .getName ();
302
301
assertThat (name .getBytes (), is ("2800000063657031385f636f6e74726163745f7061636b6167655f6163636573735f41636d6520546f6b656e" ));
303
302
assertThat (name .getParsed (), is ("cep18_contract_package_access_Acme Token" ));
304
303
assertThat (name .getClType ().getTypeName (), is ("String" ));
305
-
306
304
}
305
+
307
306
@ Test
308
307
void writeKindEntryPoint () throws JsonProcessingException {
309
308
@@ -336,16 +335,15 @@ void writeKindEntryPoint() throws JsonProcessingException {
336
335
337
336
338
337
final Effect writeEffect = new ObjectMapper ().readValue (json , Effect .class );
338
+ assertThat (writeEffect .getKey (), is (instanceOf (EntryPointKey .class )));
339
+ assertThat (writeEffect .getKey ().toString (), is ("entry-point-v1-entity-contract-3b6b4d8a3d815372508faa92f3a05dcb50c9c98de05d9a7668cb94b04f1ef9af-768c370eb010604bd19029a409dca8b5fbf9af9bc14a36c2b294a2a7a922161e" ));
339
340
340
- assertThat (writeEffect .getKey (), is ("entry-point-v1-entity-contract-3b6b4d8a3d815372508faa92f3a05dcb50c9c98de05d9a7668cb94b04f1ef9af-768c370eb010604bd19029a409dca8b5fbf9af9bc14a36c2b294a2a7a922161e" ));
341
- WriteKind <?> kind = writeEffect .getKind ();
342
-
341
+ final WriteKind <?> kind = writeEffect .getKind ();
343
342
assertThat (kind .getWrite (), is (instanceOf (EntryPointKind .class )));
344
343
assertThat (kind .getWrite ().getValue (), is (instanceOf (EntryPointValue .class )));
345
344
346
- EntryPointValue entryPointValue = (EntryPointValue ) kind .getWrite ().getValue ();
347
- EntryPoint entryPoint = entryPointValue .getV1 ();
348
-
345
+ final EntryPointValue entryPointValue = (EntryPointValue ) kind .getWrite ().getValue ();
346
+ final EntryPoint entryPoint = entryPointValue .getV1 ();
349
347
assertThat (entryPoint .getName (), is ("burn" ));
350
348
assertThat (entryPoint .getArgs ().size (), is (2 ));
351
349
assertThat (entryPoint .getArgs ().get (0 ).getName (), is ("owner" ));
@@ -354,8 +352,8 @@ void writeKindEntryPoint() throws JsonProcessingException {
354
352
assertThat (entryPoint .getAccess ().getValue (), is (EntryPoint .EntryPointAccessEnum .PUBLIC ));
355
353
assertThat (entryPoint .getType (), is (EntryPoint .EntryPointType .CALLED ));
356
354
assertThat (entryPoint .getPayment (), is (EntryPoint .EntryPointPayment .CALLER ));
357
-
358
355
}
356
+
359
357
@ Test
360
358
void writeKindPackage () throws JsonProcessingException {
361
359
@@ -400,28 +398,24 @@ void writeKindPackage() throws JsonProcessingException {
400
398
401
399
final Effect writeEffect = new ObjectMapper ().readValue (json , Effect .class );
402
400
403
- assertThat (writeEffect .getKey (), is ("package-ef39f3794dfde8641acc43a8f63d4c0a72a4b33bbb2e4eed29421ee6cfd0d87e" ));
404
- WriteKind <?> kind = writeEffect .getKind ( );
401
+ assertThat (writeEffect .getKey (), is (instanceOf ( Key . class ) ));
402
+ assertThat ( writeEffect .getKey (). toString (), is ( "package-ef39f3794dfde8641acc43a8f63d4c0a72a4b33bbb2e4eed29421ee6cfd0d87e" ) );
405
403
404
+ final WriteKind <?> kind = writeEffect .getKind ();
406
405
assertThat (kind .getWrite (), is (instanceOf (PackageKind .class )));
407
406
assertThat (kind .getWrite ().getValue (), is (instanceOf (Package .class )));
408
407
409
- Package contractPackage = (Package ) kind .getWrite ().getValue ();
410
-
408
+ final Package contractPackage = (Package ) kind .getWrite ().getValue ();
411
409
assertThat (contractPackage .getVersions ().get (0 ).getAddressableEntityHash (), is ("addressable-entity-3b6b4d8a3d815372508faa92f3a05dcb50c9c98de05d9a7668cb94b04f1ef9af" ));
412
410
assertThat (contractPackage .getVersions ().get (0 ).getEntityVersionKey ().getEntityVersion (), is (3 ));
413
411
assertThat (contractPackage .getVersions ().get (0 ).getEntityVersionKey ().getProtocolVersionMajor (), is (2 ));
414
-
415
412
assertThat (contractPackage .getDisabledVersions ().size (), is (2 ));
416
413
assertThat (contractPackage .getDisabledVersions ().get (1 ).getAddressableEntityHash (), is ("addressable-entity-aab0da01340446cee477f28410f8af5d6e0f3a88fb26c0cafb8d1625f5cc9c10" ));
417
414
assertThat (contractPackage .getDisabledVersions ().get (1 ).getEntityVersionKey ().getEntityVersion (), is (2 ));
418
415
assertThat (contractPackage .getDisabledVersions ().get (1 ).getEntityVersionKey ().getProtocolVersionMajor (), is (2 ));
419
-
420
416
assertThat (contractPackage .getGroups ().size (), is (3 ));
421
417
assertThat (contractPackage .getGroups ().get (1 ), is ("group_B" ));
422
-
423
418
assertThat (contractPackage .getLockStatus (), is (Package .PackageStatus .Unlocked ));
424
-
425
419
}
426
420
427
421
@ Test
@@ -457,15 +451,14 @@ void writeKindAddressableEntity() throws JsonProcessingException {
457
451
"}" ;
458
452
459
453
final Effect writeEffect = new ObjectMapper ().readValue (json , Effect .class );
460
- assertThat (writeEffect .getKey (), is ("entity-contract-3b6b4d8a3d815372508faa92f3a05dcb50c9c98de05d9a7668cb94b04f1ef9af" ));
461
-
462
- WriteKind <?> kind = writeEffect .getKind ();
454
+ assertThat (writeEffect .getKey (), is (instanceOf (AddressableEntityKey .class )));
455
+ assertThat (writeEffect .getKey ().toString (), is ("entity-contract-3b6b4d8a3d815372508faa92f3a05dcb50c9c98de05d9a7668cb94b04f1ef9af" ));
463
456
457
+ final WriteKind <?> kind = writeEffect .getKind ();
464
458
assertThat (kind .getWrite (), is (instanceOf (AddressableEntityKind .class )));
465
459
assertThat (kind .getWrite ().getValue (), is (instanceOf (Entity .class )));
466
460
467
- Entity entity = (Entity ) kind .getWrite ().getValue ();
468
-
461
+ final Entity entity = (Entity ) kind .getWrite ().getValue ();
469
462
assertThat (entity .getProtocolVersion (), is ("2.0.0" ));
470
463
assertThat (((SmartContract ) entity .getEntityAddressKind ()).getSmartContract ().name (), is (SmartContract .TransactionRuntime .VMCASPERV1 .name ()));
471
464
assertThat (entity .getPackageHash (), is ("package-ef39f3794dfde8641acc43a8f63d4c0a72a4b33bbb2e4eed29421ee6cfd0d87e" ));
@@ -478,6 +471,5 @@ void writeKindAddressableEntity() throws JsonProcessingException {
478
471
assertThat (entity .getActionThresholds ().getUpgradeManagement (), is (1 ));
479
472
assertThat (entity .getActionThresholds ().getUpgradeManagement (), is (1 ));
480
473
assertThat (entity .getMessageTopics ().size (), is (0 ));
481
-
482
474
}
483
475
}
0 commit comments