diff --git a/src/main/java/com/casper/sdk/model/contract/NamedKey.java b/src/main/java/com/casper/sdk/model/contract/NamedKey.java index ae9859f7..fbe0e444 100644 --- a/src/main/java/com/casper/sdk/model/contract/NamedKey.java +++ b/src/main/java/com/casper/sdk/model/contract/NamedKey.java @@ -1,5 +1,6 @@ package com.casper.sdk.model.contract; +import com.casper.sdk.model.key.Key; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; @@ -25,7 +26,7 @@ public class NamedKey { * key(String) The value of the entry: a casper `Key` type. */ @JsonProperty("key") - private String key; + private Key key; /** * name(String) The name of the entry. diff --git a/src/main/java/com/casper/sdk/model/deploy/executionresult/Success.java b/src/main/java/com/casper/sdk/model/deploy/executionresult/Success.java index 8a363d85..8af69fec 100644 --- a/src/main/java/com/casper/sdk/model/deploy/executionresult/Success.java +++ b/src/main/java/com/casper/sdk/model/deploy/executionresult/Success.java @@ -1,6 +1,7 @@ package com.casper.sdk.model.deploy.executionresult; import com.casper.sdk.model.deploy.ExecutionEffect; +import com.casper.sdk.model.key.Key; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; @@ -30,7 +31,7 @@ public class Success { private ExecutionEffect effect; /** List of Hex-encoded transfer address. */ - private List transfers; + private List transfers; /** The cost of executing the deploy. */ @JsonSerialize(using = ToStringSerializer.class) diff --git a/src/main/java/com/casper/sdk/model/entity/Account.java b/src/main/java/com/casper/sdk/model/entity/Account.java index c020188e..0dd057e7 100644 --- a/src/main/java/com/casper/sdk/model/entity/Account.java +++ b/src/main/java/com/casper/sdk/model/entity/Account.java @@ -1,6 +1,7 @@ package com.casper.sdk.model.entity; import com.casper.sdk.exception.NoSuchKeyTagException; +import com.casper.sdk.model.key.AccountHashKey; import com.casper.sdk.model.key.Key; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; @@ -20,9 +21,9 @@ public class Account implements EntityAddressKind { @JsonValue - private Key account; + private AccountHashKey account; public Account(final String accountSt) throws NoSuchKeyTagException { - this.account = Key.create(accountSt); + this.account = (AccountHashKey) Key.create(accountSt); } } diff --git a/src/main/java/com/casper/sdk/model/key/ByteCodeKey.java b/src/main/java/com/casper/sdk/model/key/ByteCodeKey.java index 3b9dc426..6a5e3de2 100644 --- a/src/main/java/com/casper/sdk/model/key/ByteCodeKey.java +++ b/src/main/java/com/casper/sdk/model/key/ByteCodeKey.java @@ -33,7 +33,8 @@ protected void fromStringCustom(final String strKey) { final byte[] key = new byte[33]; final String[] split = strKey.split("-"); key[0] = byteCodeAddr.getByteTag(); - System.arraycopy(Hex.decode(split[split.length - 1]), 0, key, 1, 32); + final byte[] decode = Hex.decode(split[split.length - 1]); + System.arraycopy(decode, 0, key, 1, decode.length); setKey(key); } diff --git a/src/main/java/com/casper/sdk/model/transaction/execution/Effect.java b/src/main/java/com/casper/sdk/model/transaction/execution/Effect.java index 057a1e42..4e2e4c1e 100644 --- a/src/main/java/com/casper/sdk/model/transaction/execution/Effect.java +++ b/src/main/java/com/casper/sdk/model/transaction/execution/Effect.java @@ -1,5 +1,6 @@ package com.casper.sdk.model.transaction.execution; +import com.casper.sdk.model.key.Key; import com.casper.sdk.model.transaction.kind.Kind; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.*; @@ -16,9 +17,8 @@ @Builder public class Effect { - // TODO convert EntityAddr @JsonProperty("key") - private String key; + private Key key; @JsonProperty("kind") private Kind kind; diff --git a/src/main/java/com/casper/sdk/model/transfer/TransferV1.java b/src/main/java/com/casper/sdk/model/transfer/TransferV1.java index af7e3c1d..abc6efc3 100644 --- a/src/main/java/com/casper/sdk/model/transfer/TransferV1.java +++ b/src/main/java/com/casper/sdk/model/transfer/TransferV1.java @@ -1,6 +1,7 @@ package com.casper.sdk.model.transfer; import com.casper.sdk.annotation.ExcludeFromJacocoGeneratedReport; +import com.casper.sdk.model.key.AccountHashKey; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.*; @@ -25,11 +26,11 @@ public class TransferV1 { /** Hex-encoded account hash. */ @JsonProperty("to") - private String to; + private AccountHashKey to; /** Hex-encoded account hash. */ @JsonProperty("from") - private String from; + private AccountHashKey from; /** Amount transferred */ @JsonIgnore diff --git a/src/test/java/com/HowTo.java b/src/test/java/com/HowTo.java index 8211ed1c..16cafd92 100644 --- a/src/test/java/com/HowTo.java +++ b/src/test/java/com/HowTo.java @@ -21,6 +21,7 @@ import com.casper.sdk.model.entity.AddressableEntity; import com.casper.sdk.model.entity.StateEntityResult; import com.casper.sdk.model.era.EraInfoData; +import com.casper.sdk.model.key.Key; import com.casper.sdk.model.key.PublicKey; import com.casper.sdk.model.reward.GetRewardResult; import com.casper.sdk.model.stateroothash.StateRootHashData; @@ -288,8 +289,8 @@ void getStateEntity() { assert stateEntityPublicKey.getEntity() != null; //By contract identifier - final String contractKey = ((AddressableEntity) stateEntityPublicKey.getEntity()).getNamedKeys().get(0).getKey(); - final StateEntityResult stateEntityContract = casperService.getStateEntity(new EntityAddrIdentifier(contractKey), null); + final Key contractKey = ((AddressableEntity) stateEntityPublicKey.getEntity()).getNamedKeys().get(0).getKey(); + final StateEntityResult stateEntityContract = casperService.getStateEntity(new EntityAddrIdentifier(contractKey.toString()), null); assert stateEntityContract.getEntity() != null; } diff --git a/src/test/java/com/casper/sdk/model/transaction/EffectTest.java b/src/test/java/com/casper/sdk/model/transaction/EffectTest.java index bdc9f989..bb16a61f 100644 --- a/src/test/java/com/casper/sdk/model/transaction/EffectTest.java +++ b/src/test/java/com/casper/sdk/model/transaction/EffectTest.java @@ -14,8 +14,7 @@ import com.casper.sdk.model.entity.contract.ByteCode; import com.casper.sdk.model.entity.contract.NamedKey; import com.casper.sdk.model.entity.contract.Package; -import com.casper.sdk.model.key.AccountHashKey; -import com.casper.sdk.model.key.PublicKey; +import com.casper.sdk.model.key.*; import com.casper.sdk.model.transaction.execution.Effect; import com.casper.sdk.model.transaction.kind.*; import com.casper.sdk.model.uref.URef; @@ -51,7 +50,8 @@ void pruneKindEffect() throws JsonProcessingException { "}"; final Effect pruneEffect = new ObjectMapper().readValue(json, Effect.class); - assertThat(pruneEffect.getKey(), is("balance-hold-01fe139a5aa36aa69c04a6b630c9993bc03d868ffde46d3f60c3fbe6e6e762016f78bec10c90010000")); + assertThat(pruneEffect.getKey(), is(instanceOf(BalanceHoldKey.class))); + assertThat(pruneEffect.getKey().toString(), is("balance-hold-01fe139a5aa36aa69c04a6b630c9993bc03d868ffde46d3f60c3fbe6e6e762016f78bec10c90010000")); assertThat(pruneEffect, is(notNullValue())); assertThat(pruneEffect.getKind(), is(instanceOf(PruneKind.class))); assertThat(((PruneKind) pruneEffect.getKind()).getPrune(), is("balance-hold-01fe139a5aa36aa69c04a6b630c9993bc03d868ffde46d3f60c3fbe6e6e762016f78bec10c90010000")); @@ -104,11 +104,11 @@ void writeKindBidKindCreditEffect() throws JsonProcessingException, NoSuchAlgori final Effect writeEffect = new ObjectMapper().readValue(json, Effect.class); assertThat(writeEffect, is(notNullValue())); assertThat(writeEffect.getKind(), is(instanceOf(WriteKind.class))); - WriteKind kind = writeEffect.getKind(); + final WriteKind kind = writeEffect.getKind(); assertThat(kind.getWrite().getValue(), is(instanceOf(BidKind.class))); assertThat(kind.getWrite().getValue(), is(instanceOf(BidKind.class))); assertThat(kind.getWrite().getValue(), is(instanceOf(ValidatorCredit.class))); - ValidatorCredit value = (ValidatorCredit) kind.getWrite().getValue(); + final ValidatorCredit value = (ValidatorCredit) kind.getWrite().getValue(); assertThat(value.getValidatorPublicKey(), is(PublicKey.fromTaggedHexString("01284a8cd097808afdea9876ccb91f28702143c04266dea057cc19b8fc382cc258"))); assertThat(value.getEraId(), is(377L)); assertThat(value.getAmount(), is(new BigInteger("10000"))); @@ -134,11 +134,11 @@ void writeKindBidKindBridgeEffect() throws JsonProcessingException, NoSuchAlgori final Effect writeEffect = new ObjectMapper().readValue(json, Effect.class); assertThat(writeEffect, is(notNullValue())); assertThat(writeEffect.getKind(), is(instanceOf(WriteKind.class))); - WriteKind kind = writeEffect.getKind(); + final WriteKind kind = writeEffect.getKind(); assertThat(kind.getWrite().getValue(), is(instanceOf(BidKind.class))); assertThat(kind.getWrite().getValue(), is(instanceOf(BidKind.class))); assertThat(kind.getWrite().getValue(), is(instanceOf(Bridge.class))); - Bridge value = (Bridge) kind.getWrite().getValue(); + final Bridge value = (Bridge) kind.getWrite().getValue(); assertThat(value.getOldValidatorPublicKey(), is(PublicKey.fromTaggedHexString("01284a8cd097808afdea9876ccb91f28702143c04266dea057cc19b8fc382cc258"))); assertThat(value.getNewValidatorPublicKey(), is(PublicKey.fromTaggedHexString("01026ca707c348ed8012ac6a1f28db031fadd6eb67203501a353b867a08c8b9a80"))); assertThat(value.getEraId(), is(378L)); @@ -207,7 +207,8 @@ void identityKindEffect() throws JsonProcessingException { "}"; final Effect identityEffect = new ObjectMapper().readValue(json, Effect.class); - assertThat(identityEffect.getKey(), is("entity-system-86c4525a60cb6532342f5f598666711219f3bdcc6a8936152ec1c670c510c75f")); + assertThat(identityEffect.getKey(), is(instanceOf(AddressableEntityKey.class))); + assertThat(identityEffect.getKey().toString(), is("entity-system-86c4525a60cb6532342f5f598666711219f3bdcc6a8936152ec1c670c510c75f")); assertThat(identityEffect, is(notNullValue())); assertThat(identityEffect.getKind(), is(instanceOf(IdentityKind.class))); } @@ -218,22 +219,22 @@ void identityKindAddUint512() throws JsonProcessingException { final String json = "{\n" + " \"key\": \"balance-1c29560834540520e147468c3bf86f09e5bd60cda2cb8380d94ee1c348a4281d\",\n" + " \"kind\": {\n" + - " \"AddUInt512\" : 2500000000\n" + - "}\n" + + " \"AddUInt512\" : 2500000000\n" + + "}\n" + "}"; final Effect identityEffect = new ObjectMapper().readValue(json, Effect.class); - assertThat(identityEffect.getKey(), is("balance-1c29560834540520e147468c3bf86f09e5bd60cda2cb8380d94ee1c348a4281d")); + assertThat(identityEffect.getKey(), is(instanceOf(Key.class))); + assertThat(identityEffect.getKey().toString(), is("balance-1c29560834540520e147468c3bf86f09e5bd60cda2cb8380d94ee1c348a4281d")); assertThat(identityEffect, is(notNullValue())); assertThat(identityEffect.getKind(), is(instanceOf(Transform.class))); - } @Test void writeKindByteCode() throws JsonProcessingException { final String json = "{\n" + - " \"key\": \"byte-code-v1-wasm-aaa0345086a4f80601ec93d78053c13f5599afeb752d3d9b88fe5878b611675\",\n" + + " \"key\": \"byte-code-v1-wasm-3beb396c91ff7ae62d08857cc8a787146cd4f0771b8a21d385b3f4ac6077854a\",\n" + " \"kind\": {\n" + " \"Write\": {\n" + " \"ByteCode\": {\n" + @@ -245,19 +246,17 @@ void writeKindByteCode() throws JsonProcessingException { "}"; final Effect writeEffect = new ObjectMapper().readValue(json, Effect.class); + assertThat(writeEffect.getKey().toString(), is("byte-code-v1-wasm-3beb396c91ff7ae62d08857cc8a787146cd4f0771b8a21d385b3f4ac6077854a")); - assertThat(writeEffect.getKey(), is("byte-code-v1-wasm-aaa0345086a4f80601ec93d78053c13f5599afeb752d3d9b88fe5878b611675")); - WriteKind kind = writeEffect.getKind(); - + final WriteKind kind = writeEffect.getKind(); assertThat(kind.getWrite(), is(instanceOf(ByteCodeKind.class))); assertThat(kind.getWrite().getValue(), is(instanceOf(ByteCode.class))); - ByteCode byteCodeKind = (ByteCode) kind.getWrite().getValue(); - + final ByteCode byteCodeKind = (ByteCode) kind.getWrite().getValue(); assertThat(byteCodeKind.getBytes(), is("0061736d01000000017f106002")); assertThat(byteCodeKind.getKind(), is(ByteCode.ByteCodes.V1CasperWasm)); - } + @Test void writeKindNamedKey() throws JsonProcessingException { @@ -285,25 +284,25 @@ void writeKindNamedKey() throws JsonProcessingException { final Effect writeEffect = new ObjectMapper().readValue(json, Effect.class); - assertThat(writeEffect.getKey(), is("named-key-entity-account-a897e2e1c25b1149e96b774bdfd758d4a44ec392bd914a19ff780d3905ff45c0-e8265cd5ef8e0275971c6d4ff28263ef787412f034631a11bbc508761ffd7119")); - WriteKind kind = writeEffect.getKind(); + assertThat(writeEffect.getKey(), is(instanceOf(NamedKeyKey.class))); + assertThat(writeEffect.getKey().toString(), is("named-key-entity-account-a897e2e1c25b1149e96b774bdfd758d4a44ec392bd914a19ff780d3905ff45c0-e8265cd5ef8e0275971c6d4ff28263ef787412f034631a11bbc508761ffd7119")); + final WriteKind kind = writeEffect.getKind(); assertThat(kind.getWrite(), is(instanceOf(NamedKeyKind.class))); assertThat(kind.getWrite().getValue(), is(instanceOf(NamedKey.class))); - NamedKey namedKeyKind = (NamedKey) kind.getWrite().getValue(); - - AbstractCLValue namedKey = namedKeyKind.getNamedKey(); + final NamedKey namedKeyKind = (NamedKey) kind.getWrite().getValue(); + final AbstractCLValue namedKey = namedKeyKind.getNamedKey(); assertThat(namedKey.getBytes(), is("028c5da3dd186f82c27dd4689dca3f838ac17f93ef10a5159fa40a30ca78f9e93207")); assertThat(namedKey.getParsed(), is("uref-8c5da3dd186f82c27dd4689dca3f838ac17f93ef10a5159fa40a30ca78f9e932-007")); assertThat(namedKey.getClType().getTypeName(), is("Key")); - AbstractCLValue name = namedKeyKind.getName(); + final AbstractCLValue name = namedKeyKind.getName(); assertThat(name.getBytes(), is("2800000063657031385f636f6e74726163745f7061636b6167655f6163636573735f41636d6520546f6b656e")); assertThat(name.getParsed(), is("cep18_contract_package_access_Acme Token")); assertThat(name.getClType().getTypeName(), is("String")); - } + @Test void writeKindEntryPoint() throws JsonProcessingException { @@ -336,16 +335,15 @@ void writeKindEntryPoint() throws JsonProcessingException { final Effect writeEffect = new ObjectMapper().readValue(json, Effect.class); + assertThat(writeEffect.getKey(), is(instanceOf(EntryPointKey.class))); + assertThat(writeEffect.getKey().toString(), is("entry-point-v1-entity-contract-3b6b4d8a3d815372508faa92f3a05dcb50c9c98de05d9a7668cb94b04f1ef9af-768c370eb010604bd19029a409dca8b5fbf9af9bc14a36c2b294a2a7a922161e")); - assertThat(writeEffect.getKey(), is("entry-point-v1-entity-contract-3b6b4d8a3d815372508faa92f3a05dcb50c9c98de05d9a7668cb94b04f1ef9af-768c370eb010604bd19029a409dca8b5fbf9af9bc14a36c2b294a2a7a922161e")); - WriteKind kind = writeEffect.getKind(); - + final WriteKind kind = writeEffect.getKind(); assertThat(kind.getWrite(), is(instanceOf(EntryPointKind.class))); assertThat(kind.getWrite().getValue(), is(instanceOf(EntryPointValue.class))); - EntryPointValue entryPointValue = (EntryPointValue) kind.getWrite().getValue(); - EntryPoint entryPoint = entryPointValue.getV1(); - + final EntryPointValue entryPointValue = (EntryPointValue) kind.getWrite().getValue(); + final EntryPoint entryPoint = entryPointValue.getV1(); assertThat(entryPoint.getName(), is("burn")); assertThat(entryPoint.getArgs().size(), is(2)); assertThat(entryPoint.getArgs().get(0).getName(), is("owner")); @@ -354,8 +352,8 @@ void writeKindEntryPoint() throws JsonProcessingException { assertThat(entryPoint.getAccess().getValue(), is(EntryPoint.EntryPointAccessEnum.PUBLIC)); assertThat(entryPoint.getType(), is(EntryPoint.EntryPointType.CALLED)); assertThat(entryPoint.getPayment(), is(EntryPoint.EntryPointPayment.CALLER)); - } + @Test void writeKindPackage() throws JsonProcessingException { @@ -400,28 +398,24 @@ void writeKindPackage() throws JsonProcessingException { final Effect writeEffect = new ObjectMapper().readValue(json, Effect.class); - assertThat(writeEffect.getKey(), is("package-ef39f3794dfde8641acc43a8f63d4c0a72a4b33bbb2e4eed29421ee6cfd0d87e")); - WriteKind kind = writeEffect.getKind(); + assertThat(writeEffect.getKey(), is(instanceOf(Key.class))); + assertThat(writeEffect.getKey().toString(), is("package-ef39f3794dfde8641acc43a8f63d4c0a72a4b33bbb2e4eed29421ee6cfd0d87e")); + final WriteKind kind = writeEffect.getKind(); assertThat(kind.getWrite(), is(instanceOf(PackageKind.class))); assertThat(kind.getWrite().getValue(), is(instanceOf(Package.class))); - Package contractPackage = (Package) kind.getWrite().getValue(); - + final Package contractPackage = (Package) kind.getWrite().getValue(); assertThat(contractPackage.getVersions().get(0).getAddressableEntityHash(), is("addressable-entity-3b6b4d8a3d815372508faa92f3a05dcb50c9c98de05d9a7668cb94b04f1ef9af")); assertThat(contractPackage.getVersions().get(0).getEntityVersionKey().getEntityVersion(), is(3)); assertThat(contractPackage.getVersions().get(0).getEntityVersionKey().getProtocolVersionMajor(), is(2)); - assertThat(contractPackage.getDisabledVersions().size(), is(2)); assertThat(contractPackage.getDisabledVersions().get(1).getAddressableEntityHash(), is("addressable-entity-aab0da01340446cee477f28410f8af5d6e0f3a88fb26c0cafb8d1625f5cc9c10")); assertThat(contractPackage.getDisabledVersions().get(1).getEntityVersionKey().getEntityVersion(), is(2)); assertThat(contractPackage.getDisabledVersions().get(1).getEntityVersionKey().getProtocolVersionMajor(), is(2)); - assertThat(contractPackage.getGroups().size(), is(3)); assertThat(contractPackage.getGroups().get(1), is("group_B")); - assertThat(contractPackage.getLockStatus(), is(Package.PackageStatus.Unlocked)); - } @Test @@ -457,15 +451,14 @@ void writeKindAddressableEntity() throws JsonProcessingException { "}"; final Effect writeEffect = new ObjectMapper().readValue(json, Effect.class); - assertThat(writeEffect.getKey(), is("entity-contract-3b6b4d8a3d815372508faa92f3a05dcb50c9c98de05d9a7668cb94b04f1ef9af")); - - WriteKind kind = writeEffect.getKind(); + assertThat(writeEffect.getKey(), is(instanceOf(AddressableEntityKey.class))); + assertThat(writeEffect.getKey().toString(), is("entity-contract-3b6b4d8a3d815372508faa92f3a05dcb50c9c98de05d9a7668cb94b04f1ef9af")); + final WriteKind kind = writeEffect.getKind(); assertThat(kind.getWrite(), is(instanceOf(AddressableEntityKind.class))); assertThat(kind.getWrite().getValue(), is(instanceOf(Entity.class))); - Entity entity = (Entity) kind.getWrite().getValue(); - + final Entity entity = (Entity) kind.getWrite().getValue(); assertThat(entity.getProtocolVersion(), is("2.0.0")); assertThat(((SmartContract) entity.getEntityAddressKind()).getSmartContract().name(), is(SmartContract.TransactionRuntime.VMCASPERV1.name())); assertThat(entity.getPackageHash(), is("package-ef39f3794dfde8641acc43a8f63d4c0a72a4b33bbb2e4eed29421ee6cfd0d87e")); @@ -478,6 +471,5 @@ void writeKindAddressableEntity() throws JsonProcessingException { assertThat(entity.getActionThresholds().getUpgradeManagement(), is(1)); assertThat(entity.getActionThresholds().getUpgradeManagement(), is(1)); assertThat(entity.getMessageTopics().size(), is(0)); - } } diff --git a/src/test/java/com/casper/sdk/service/CasperServiceTests.java b/src/test/java/com/casper/sdk/service/CasperServiceTests.java index e3d13a78..be70ef71 100644 --- a/src/test/java/com/casper/sdk/service/CasperServiceTests.java +++ b/src/test/java/com/casper/sdk/service/CasperServiceTests.java @@ -41,10 +41,7 @@ import com.casper.sdk.model.era.EraEndV2; import com.casper.sdk.model.era.EraInfoData; import com.casper.sdk.model.globalstate.GlobalStateData; -import com.casper.sdk.model.key.AccountHashKey; -import com.casper.sdk.model.key.AlgorithmTag; -import com.casper.sdk.model.key.Key; -import com.casper.sdk.model.key.PublicKey; +import com.casper.sdk.model.key.*; import com.casper.sdk.model.peer.PeerData; import com.casper.sdk.model.reward.GetRewardResult; import com.casper.sdk.model.stateroothash.StateRootHashData; @@ -235,7 +232,7 @@ void retrieveLastBlockTransfers() { } @Test - void getTransferByHeight() { + void getTransferByHeight() throws NoSuchKeyTagException { mockNode.withRcpResponseDispatcher() .withMethod("chain_get_block_transfers") @@ -248,13 +245,13 @@ void getTransferByHeight() { final TransferV1 transaction = transferData.getTransfers().get(0).getTransferV1(); assertEquals("c709e727b7eaadb3b7f76450aa5d3ac3dd28b0271b7471a6dcc828cfd29f745a", transaction.getDeployHash()); - assertEquals("account-hash-496d542527e1a29f576ab7c3f4c947bfcdc9b4145f75f6ec40e36089432d7351", transaction.getFrom()); - assertEquals("account-hash-8a35e688eac33089b13f91a78c94221b669a0b13a6ed199228b1da018ecfa9df", transaction.getTo()); + assertEquals(Key.create("account-hash-496d542527e1a29f576ab7c3f4c947bfcdc9b4145f75f6ec40e36089432d7351"), transaction.getFrom()); + assertEquals(Key.create("account-hash-8a35e688eac33089b13f91a78c94221b669a0b13a6ed199228b1da018ecfa9df"), transaction.getTo()); assertEquals(BigInteger.valueOf(445989400000L), transaction.getAmount()); } @Test - void getTransferByHash() { + void getTransferByHash() throws NoSuchKeyTagException { mockNode.withRcpResponseDispatcher() .withMethod("chain_get_block_transfers") @@ -267,8 +264,8 @@ void getTransferByHash() { final TransferV1 transaction = transferData.getTransfers().get(0).getTransferV1(); assertEquals("c709e727b7eaadb3b7f76450aa5d3ac3dd28b0271b7471a6dcc828cfd29f745a", transaction.getDeployHash()); - assertEquals("account-hash-496d542527e1a29f576ab7c3f4c947bfcdc9b4145f75f6ec40e36089432d7351", transaction.getFrom()); - assertEquals("account-hash-8a35e688eac33089b13f91a78c94221b669a0b13a6ed199228b1da018ecfa9df", transaction.getTo()); + assertEquals(Key.create("account-hash-496d542527e1a29f576ab7c3f4c947bfcdc9b4145f75f6ec40e36089432d7351"), transaction.getFrom()); + assertEquals(Key.create("account-hash-8a35e688eac33089b13f91a78c94221b669a0b13a6ed199228b1da018ecfa9df"), transaction.getTo()); assertEquals(BigInteger.valueOf(445989400000L), transaction.getAmount()); } @@ -384,7 +381,7 @@ void getStateItemContract() { assertInstanceOf(StoredValueContract.class, storedValueData.getStoredValue()); assertEquals("contract-package-d63c44078a1931b5dc4b80a7a0ec586164fd0470ce9f8b23f6d93b9e86c5944d", ((StoredValueContract) storedValueData.getStoredValue()).getValue().getPackageHash()); assertEquals("contract-wasm-08d9634a72c58df5d837740174c6e88e52b0370ce8c74960d600e54966a0a4cf", ((StoredValueContract) storedValueData.getStoredValue()).getValue().getWasmHash()); - assertEquals("uref-fe327f9815a1d016e1143db85e25a86341883949fd75ac1c1e7408a26c5b62ef-007", ((StoredValueContract) storedValueData.getStoredValue()).getValue().getNamedKeys().get(0).getKey()); + assertEquals("uref-fe327f9815a1d016e1143db85e25a86341883949fd75ac1c1e7408a26c5b62ef-007", ((StoredValueContract) storedValueData.getStoredValue()).getValue().getNamedKeys().get(0).getKey().toString()); } @Test @@ -963,8 +960,8 @@ void stateGetEntityCiontractActualCCTLReturnedData() { assertThat(entity.getEntryPoints().size(), is(15)); assertThat(entity.getNamedKeys().size(), is(11)); - - assertThat(entity.getNamedKeys().get(0).getKey(), is("uref-a18b3997bc0bafe8612973531e6782be4f1251f90f0513c0b34fea69df1a95ff-007")); + assertThat(entity.getNamedKeys().get(0).getKey(), is(instanceOf(URefKey.class))); + assertThat(entity.getNamedKeys().get(0).getKey().toString(), is("uref-a18b3997bc0bafe8612973531e6782be4f1251f90f0513c0b34fea69df1a95ff-007")); assertThat(entity.getNamedKeys().get(0).getName(), is("allowances")); assertThat(entity.getEntryPoints().get(14).getV1().getAccess(), is(EntryPoint.EntryPointAccessEnum.PUBLIC)); diff --git a/src/test/java/com/casper/sdk/service/EventServiceIntegrationTest.java b/src/test/java/com/casper/sdk/service/EventServiceIntegrationTest.java index f04154ce..589137ce 100644 --- a/src/test/java/com/casper/sdk/service/EventServiceIntegrationTest.java +++ b/src/test/java/com/casper/sdk/service/EventServiceIntegrationTest.java @@ -379,10 +379,10 @@ void stepEventV2Pojo() throws Exception { Step step = (Step) data; assertThat(step.getExecutionEffects(), hasSize(37)); - assertThat(step.getExecutionEffects().get(0).getKey(), is("entity-system-001501686b8d0a46fa1d47462b11b07f25ff80a13f0d889e7fd56cda81f4d642")); + assertThat(step.getExecutionEffects().get(0).getKey().toString(), is("entity-system-001501686b8d0a46fa1d47462b11b07f25ff80a13f0d889e7fd56cda81f4d642")); assertThat(step.getExecutionEffects().get(0).getKind(), is(instanceOf(IdentityKind.class))); - assertThat(step.getExecutionEffects().get(34).getKey(), is("uref-da840e3134fed2d355e2cc24e762649b74d46493815de375053f5f82f0e18852-000")); + assertThat(step.getExecutionEffects().get(34).getKey().toString(), is("uref-da840e3134fed2d355e2cc24e762649b74d46493815de375053f5f82f0e18852-000")); assertThat(step.getExecutionEffects().get(34).getKind(), is(instanceOf(WriteKind.class))); assertThat(((WriteKind) step.getExecutionEffects().get(34).getKind()).getWrite().getValue(), is(instanceOf(CLValueMap.class))); CLValueMap clValueMap = (CLValueMap) ((WriteKind) step.getExecutionEffects().get(34).getKind()).getWrite().getValue(); @@ -390,7 +390,7 @@ void stepEventV2Pojo() throws Exception { assertThat(clValueMap.getClType().getKeyValueTypes().getValueType().getTypeName(), is(AbstractCLType.MAP)); assertThat(clValueMap.getBytes(), is("0300000001000000000000000500000001297c041e1af9b14f2ea215641adbe231cf395364aed00d288fdeba849f34b0ac08010064a7b3b6e00d0101000000017fab55ab50c80193b142ddf9c6cbd877a0ed1c64831889620750b1c327eb99ef08010064a7b3b6e00d0131afbb18e108ea19dea4ec2142a8de1623dcaab87823ed87ec70922c8d05217b08020064a7b3b6e00d0201000000010ac86a5c07d75343ca3dfa1fbcadd0723b1e3df3863907520be8dbd5a229ccd908020064a7b3b6e00d01653b55b810f692c8d8d8c6ea2db60d25fc661578f07fc9b9be9ae26f47af8d4508040064a7b3b6e00d04010000000167cfe9c230684c4b3cbb2b410493da66de7764271730584cfb8d418b28d06d3e08040064a7b3b6e00d01c0bd8e47de46c1ae7d477eb245a235efabd0c03ff29991d1c2a766186c80e03a08030064a7b3b6e00d0301000000010b37cccaf40ed3723c0933770f0b291b01a82ddb0c9086365424ce5e0407201208030064a7b3b6e00d01e1c98abaead1998334e69c73ef0f75af74844568273bbb523295604b1af0dea608050064a7b3b6e00d050100000001676de7c258615c085a9ca7bd6d597d07ec88ba3184c653de60ab7fc6f8b4b67c08050064a7b3b6e00d02000000000000000500000001297c041e1af9b14f2ea215641adbe231cf395364aed00d288fdeba849f34b0ac08010064a7b3b6e00d0101000000017fab55ab50c80193b142ddf9c6cbd877a0ed1c64831889620750b1c327eb99ef08010064a7b3b6e00d0131afbb18e108ea19dea4ec2142a8de1623dcaab87823ed87ec70922c8d05217b08020064a7b3b6e00d0201000000010ac86a5c07d75343ca3dfa1fbcadd0723b1e3df3863907520be8dbd5a229ccd908020064a7b3b6e00d01653b55b810f692c8d8d8c6ea2db60d25fc661578f07fc9b9be9ae26f47af8d4508040064a7b3b6e00d04010000000167cfe9c230684c4b3cbb2b410493da66de7764271730584cfb8d418b28d06d3e08040064a7b3b6e00d01c0bd8e47de46c1ae7d477eb245a235efabd0c03ff29991d1c2a766186c80e03a08030064a7b3b6e00d0301000000010b37cccaf40ed3723c0933770f0b291b01a82ddb0c9086365424ce5e0407201208030064a7b3b6e00d01e1c98abaead1998334e69c73ef0f75af74844568273bbb523295604b1af0dea608050064a7b3b6e00d050100000001676de7c258615c085a9ca7bd6d597d07ec88ba3184c653de60ab7fc6f8b4b67c08050064a7b3b6e00d03000000000000000500000001297c041e1af9b14f2ea215641adbe231cf395364aed00d288fdeba849f34b0ac080290eac47bfded0d0101000000017fab55ab50c80193b142ddf9c6cbd877a0ed1c64831889620750b1c327eb99ef0801f0334d2ebaed0d0131afbb18e108ea19dea4ec2142a8de1623dcaab87823ed87ec70922c8d05217b0804804763a98ef30d0201000000010ac86a5c07d75343ca3dfa1fbcadd0723b1e3df3863907520be8dbd5a229ccd90802802a9d7cd1f20d01653b55b810f692c8d8d8c6ea2db60d25fc661578f07fc9b9be9ae26f47af8d450806802f940f78f90d04010000000167cfe9c230684c4b3cbb2b410493da66de7764271730584cfb8d418b28d06d3e080400965a9290f70d01c0bd8e47de46c1ae7d477eb245a235efabd0c03ff29991d1c2a766186c80e03a080430a13cc940ee0d0301000000010b37cccaf40ed3723c0933770f0b291b01a82ddb0c9086365424ce5e040720120803507dd5e076ed0d01e1c98abaead1998334e69c73ef0f75af74844568273bbb523295604b1af0dea6080720e87e734dff0d050100000001676de7c258615c085a9ca7bd6d597d07ec88ba3184c653de60ab7fc6f8b4b67c0806e0305eaa63fc0d")); - assertThat(step.getExecutionEffects().get(36).getKey(), is("uref-10ad3536d8be35beb06864d5589ac74d47b9440148c07c92ca1edaf1176469d0-000")); + assertThat(step.getExecutionEffects().get(36).getKey().toString(), is("uref-10ad3536d8be35beb06864d5589ac74d47b9440148c07c92ca1edaf1176469d0-000")); assertThat(step.getExecutionEffects().get(36).getKind(), is(instanceOf(WriteKind.class))); assertThat(((WriteKind) step.getExecutionEffects().get(36).getKind()).getWrite().getValue(), is(instanceOf(CLValueU64.class))); CLValueU64 clValueU64 = (CLValueU64) ((WriteKind) step.getExecutionEffects().get(36).getKind()).getWrite().getValue();