From dd9106396fc5df986c323b01e7d6cb7f14d255aa Mon Sep 17 00:00:00 2001 From: straumat Date: Thu, 9 Nov 2023 17:42:43 +0100 Subject: [PATCH] Explore core migrated #322 --- .../core/dto/asset/AssetStateDTO.java | 7 +- .../provider/tapd/DecodedProofResponse.java | 53 +++++++++++ .../util/converter/StringListConverter.java | 2 +- .../core/util/mapper/AssetStateMapper.java | 17 +++- .../changelog/0.1.0/data/data-asset_state.xml | 4 +- .../0.1.0/table/table-asset_state.xml | 2 +- .../core/service/AssetGroupServiceTest.java | 12 +-- .../test/core/service/AssetServiceTest.java | 4 +- .../core/service/AssetStateServiceTest.java | 7 +- .../integration/database/PostgreSQLTest.java | 2 +- .../core/test/util/TestWithMockServers.java | 91 +++++++++++++++---- .../db/test/test-data-asset_state.xml | 40 ++++++++ .../test/graphql/AssetDataFetcherTest.java | 4 +- .../graphql/AssetGroupDataFetcherTest.java | 4 +- .../graphql/AssetStateDataFetcherTest.java | 8 +- .../core/proof/RoylloNFTIntegrationTest.java | 4 +- .../proof/SetOfRoylloNFTIntegrationTest.java | 14 +-- .../TrickyRoylloCoinIntegrationTest.java | 16 ++-- .../UnknownRoylloCoinIntegrationTest.java | 4 +- .../UnlimitedRoylloCoinIntegrationTest.java | 6 +- .../asset/DisplayRoylloCoinTest.java | 2 +- .../asset/DisplayRoylloNFTTest.java | 2 +- .../asset/DisplaySetRoylloNFT1Test.java | 2 +- .../asset/DisplaySetRoylloNFT2Test.java | 2 +- .../asset/DisplaySetRoylloNFT3Test.java | 2 +- .../asset/DisplayTrickyRoylloCoinTest.java | 10 +- .../DisplayUnlimitedRoylloCoin1Test.java | 2 +- .../DisplayUnlimitedRoylloCoin2Test.java | 2 +- .../main/java/org/royllo/test/TapdData.java | 2 +- .../royllo/test/tapd/asset/AssetValue.java | 2 +- .../tapd/asset/DecodedProofValueResponse.java | 17 ++++ .../java/org/royllo/test/TapdDataTest.java | 13 ++- 32 files changed, 275 insertions(+), 84 deletions(-) diff --git a/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/dto/asset/AssetStateDTO.java b/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/dto/asset/AssetStateDTO.java index aeb0f9d25..06bbbf091 100644 --- a/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/dto/asset/AssetStateDTO.java +++ b/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/dto/asset/AssetStateDTO.java @@ -11,7 +11,6 @@ import org.royllo.explorer.core.dto.user.UserDTO; import java.math.BigInteger; -import java.util.ArrayList; import java.util.List; import static lombok.AccessLevel.PRIVATE; @@ -84,7 +83,7 @@ public class AssetStateDTO { String leaseOwner; /** If the asset has been leased, this is the expiry of the lease as a Unix timestamp in seconds. */ - long leaseExpiry; + Long leaseExpiry; /** The merkle proof for AnchorTx used to prove its inclusion within BlockHeader. */ String txMerkleProof; @@ -93,13 +92,13 @@ public class AssetStateDTO { String inclusionProof; /** The set of TaprootProofs proving the exclusion of the resulting asset from all other Taproot outputs within AnchorTx. */ - List exclusionProofs = new ArrayList<>(); + List exclusionProofs; /** An optional TaprootProof needed if this asset is the result of a split. SplitRootProof proves inclusion of the root asset of the split. */ String splitRootProof; /** ChallengeWitness is an optional virtual transaction witness that serves as an ownership proof for the asset. */ - List challengeWitness = new ArrayList<>(); + List challengeWitness; /** The asset state ID that uniquely identifies the asset state (calculated by Royllo). */ @Setter diff --git a/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/provider/tapd/DecodedProofResponse.java b/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/provider/tapd/DecodedProofResponse.java index a7b68b5f5..174b84c1f 100644 --- a/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/provider/tapd/DecodedProofResponse.java +++ b/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/provider/tapd/DecodedProofResponse.java @@ -64,6 +64,22 @@ public static class DecodedProof { @JsonProperty("exclusion_proofs") List exclusionProofs; + /** An optional TaprootProof needed if this asset is the result of a split. SplitRootProof proves inclusion of the root asset of the split. */ + @JsonProperty("split_root_proof") + String splitRootProof; + + /** The number of additional nested full proofs for any inputs found within the resulting asset. */ + @JsonProperty("num_additional_inputs") + long numberOfAdditionalInputs; + + /** ChallengeWitness is an optional virtual transaction witness that serves as an ownership proof for the asset. */ + @JsonProperty("challenge_witness") + List challengeWitness; + + /** Indicates whether the state transition this proof represents is a burn, meaning that the assets were provably destroyed and can no longer be spent. */ + @JsonProperty("is_burn") + Boolean isBurn; + @Getter @Setter @NoArgsConstructor @@ -115,6 +131,39 @@ public static class Asset { @JsonProperty("prev_witnesses") List prevWitnesses; + /** Indicates whether the asset has been spent. */ + @JsonProperty("is_spent") + Boolean isSpent; + + /** If the asset has been leased, this is the owner (application ID) of the lease. */ + @JsonProperty("lease_owner") + String leaseOwner; + + /** If the asset has been leased, this is the expiry of the lease as a Unix timestamp in seconds. */ + @JsonProperty("lease_expiry") + String leaseExpiry; + + /** Indicates whether this transfer was an asset burn. If true, the number of assets in this output are destroyed and can no longer be spent. */ + @JsonProperty("is_burn") + Boolean isBurn; + + /** + * If the asset has been leased, this is the expiry of the lease as a Unix timestamp in seconds. + * + * @return lease expiry timestamp + */ + public final Long getLeaseExpiryTimestamp() { + if (leaseExpiry == null) { + return 0L; + } else { + try { + return Long.parseLong(leaseExpiry); + } catch (NumberFormatException e) { + return 0L; + } + } + } + @Getter @Setter @NoArgsConstructor @@ -204,6 +253,10 @@ public static class ChainAnchor { @JsonProperty("tapscript_sibling") String tapscriptSibling; + /** Block height. */ + @JsonProperty("block_height") + long blockHeight; + } } diff --git a/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/util/converter/StringListConverter.java b/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/util/converter/StringListConverter.java index 09a088586..32ee596e0 100644 --- a/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/util/converter/StringListConverter.java +++ b/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/util/converter/StringListConverter.java @@ -25,7 +25,7 @@ public String convertToDatabaseColumn(final List stringList) { @Override public List convertToEntityAttribute(final String string) { - if (string != null) { + if (string != null && !string.isEmpty()) { return Arrays.asList(string.split(SPLIT_CHAR)); } else { return emptyList(); diff --git a/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/util/mapper/AssetStateMapper.java b/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/util/mapper/AssetStateMapper.java index ab5c3c9de..bc3e35df6 100644 --- a/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/util/mapper/AssetStateMapper.java +++ b/backend/explorer-core/autoconfigure/src/main/java/org/royllo/explorer/core/util/mapper/AssetStateMapper.java @@ -30,14 +30,29 @@ public interface AssetStateMapper { @Mapping(target = "creator", ignore = true) @Mapping(target = "assetStateId", ignore = true) @Mapping(source = ".", target = "asset") + @Mapping(source = "asset.chainAnchor.anchorTx", target = "anchorTx") @Mapping(source = "asset.chainAnchor.anchorBlockHash", target = "anchorBlockHash") @Mapping(source = "asset.chainAnchor.anchorOutpoint", target = "anchorOutpoint") - @Mapping(source = "asset.chainAnchor.anchorTx", target = "anchorTx") @Mapping(source = "asset.chainAnchor.internalKey", target = "internalKey") @Mapping(source = "asset.chainAnchor.merkleRoot", target = "merkleRoot") @Mapping(source = "asset.chainAnchor.tapscriptSibling", target = "tapscriptSibling") + + @Mapping(source = "asset.version", target = "version") + @Mapping(source = "asset.amount", target = "amount") + @Mapping(source = "asset.lockTime", target = "lockTime") + @Mapping(source = "asset.relativeLockTime", target = "relativeLockTime") + @Mapping(source = "asset.scriptVersion", target = "scriptVersion") @Mapping(source = "asset.scriptKey", target = "scriptKey") + + @Mapping(source = "asset.leaseOwner", target = "leaseOwner") + @Mapping(source = "asset.leaseExpiryTimestamp", target = "leaseExpiry") + + @Mapping(source = "txMerkleProof", target = "txMerkleProof") + @Mapping(source = "inclusionProof", target = "inclusionProof") + @Mapping(source = "exclusionProofs", target = "exclusionProofs") + @Mapping(source = "splitRootProof", target = "splitRootProof") + @Mapping(source = "challengeWitness", target = "challengeWitness") AssetStateDTO mapToAssetStateDTO(DecodedProofResponse.DecodedProof source); } diff --git a/backend/explorer-core/autoconfigure/src/main/resources/db/changelog/0.1.0/data/data-asset_state.xml b/backend/explorer-core/autoconfigure/src/main/resources/db/changelog/0.1.0/data/data-asset_state.xml index 7ffada6bb..5f794206d 100644 --- a/backend/explorer-core/autoconfigure/src/main/resources/db/changelog/0.1.0/data/data-asset_state.xml +++ b/backend/explorer-core/autoconfigure/src/main/resources/db/changelog/0.1.0/data/data-asset_state.xml @@ -34,9 +34,9 @@ - + - diff --git a/backend/explorer-core/autoconfigure/src/main/resources/db/changelog/0.1.0/table/table-asset_state.xml b/backend/explorer-core/autoconfigure/src/main/resources/db/changelog/0.1.0/table/table-asset_state.xml index a5dc951f9..85bc86a0f 100644 --- a/backend/explorer-core/autoconfigure/src/main/resources/db/changelog/0.1.0/table/table-asset_state.xml +++ b/backend/explorer-core/autoconfigure/src/main/resources/db/changelog/0.1.0/table/table-asset_state.xml @@ -53,7 +53,7 @@ remarks="If the asset has been leased, this is the owner (application ID) of the lease"/> - diff --git a/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetGroupServiceTest.java b/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetGroupServiceTest.java index 34ae60764..11db70560 100644 --- a/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetGroupServiceTest.java +++ b/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetGroupServiceTest.java @@ -50,7 +50,7 @@ public void addAssetGroup() { // ============================================================================================================= // Constraint test - Asset group key already registered. e = assertThrows(AssertionError.class, () -> assetGroupService.addAssetGroup(AssetGroupDTO.builder() - .assetGroupId(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getTweakedGroupKey()) + .assetGroupId(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getTweakedGroupKey()) .tweakedGroupKey("TWEAKED_GROUP_KEY_10000").build())); assertEquals("Asset group id already registered", e.getMessage()); @@ -80,13 +80,13 @@ public void getAssetGroupByAssetGroupId() { // ============================================================================================================= // Existing asset group on testnet and in our database initialization script. - assetGroup = assetGroupService.getAssetGroupByAssetGroupId(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getTweakedGroupKey()); + assetGroup = assetGroupService.getAssetGroupByAssetGroupId(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getTweakedGroupKey()); assertTrue(assetGroup.isPresent()); assertNotNull(assetGroup.get().getId()); - assertEquals(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getTweakedGroupKey(), assetGroup.get().getAssetGroupId()); - assertEquals(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getRawGroupKey(), assetGroup.get().getRawGroupKey()); - assertEquals(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getTweakedGroupKey(), assetGroup.get().getTweakedGroupKey()); - assertEquals(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getAssetWitness(), assetGroup.get().getAssetWitness()); + assertEquals(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getTweakedGroupKey(), assetGroup.get().getAssetGroupId()); + assertEquals(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getRawGroupKey(), assetGroup.get().getRawGroupKey()); + assertEquals(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getTweakedGroupKey(), assetGroup.get().getTweakedGroupKey()); + assertEquals(UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getAssetWitness(), assetGroup.get().getAssetWitness()); } } diff --git a/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetServiceTest.java b/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetServiceTest.java index bc309110b..58013c2d2 100644 --- a/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetServiceTest.java +++ b/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetServiceTest.java @@ -60,7 +60,7 @@ public void queryAssets() { assertEquals(0, results.getTotalPages()); // Searching for an asset with its group asset id - results = assetService.queryAssets(SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getTweakedGroupKey(), 1, 5); + results = assetService.queryAssets(SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getTweakedGroupKey(), 1, 5); assertEquals(3, results.getTotalElements()); assertEquals(1, results.getTotalPages()); assertEquals(SET_OF_ROYLLO_NFT_1_ASSET_ID, results.getContent().get(0).getAssetId()); @@ -369,7 +369,7 @@ public void getAssetsByAssetGroupId() { assertEquals(0, assetService.getAssetsByAssetGroupId("NON_EXISTING_ASSET_GROUP_ID").size()); // Test with an asset group with three assets. - final String tweakedGroupKey = SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getTweakedGroupKey(); + final String tweakedGroupKey = SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getTweakedGroupKey(); assertEquals(3, assetService.getAssetsByAssetGroupId(tweakedGroupKey).size()); } diff --git a/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetStateServiceTest.java b/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetStateServiceTest.java index 523f559fb..b79691841 100644 --- a/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetStateServiceTest.java +++ b/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/core/service/AssetStateServiceTest.java @@ -25,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.royllo.explorer.core.util.constants.UserConstants.ANONYMOUS_ID; import static org.royllo.explorer.core.util.constants.UserConstants.ANONYMOUS_USER_DTO; import static org.royllo.explorer.core.util.constants.UserConstants.ANONYMOUS_USER_ID; import static org.royllo.test.MempoolData.ROYLLO_COIN_ANCHOR_1_TXID; @@ -226,13 +227,13 @@ public void getAssetStateByAssetStateId() { // ============================================================================================================= // Existing asset state on testnet and in our database initialization script ("roylloCoin"). - assetState = assetStateService.getAssetStateByAssetStateId(ROYLLO_COIN_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId()); + assetState = assetStateService.getAssetStateByAssetStateId(ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId()); assertTrue(assetState.isPresent()); assertEquals(1, assetState.get().getId()); - assertEquals(ROYLLO_COIN_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId(), assetState.get().getAssetStateId()); + assertEquals(ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId(), assetState.get().getAssetStateId()); // User. assertNotNull(assetState.get().getCreator()); - assertEquals(ANONYMOUS_USER_DTO.getId(), assetState.get().getCreator().getId()); + assertEquals(ANONYMOUS_ID, assetState.get().getCreator().getId()); // Asset & asset group. verifyAsset(assetState.get().getAsset(), ROYLLO_COIN_ASSET_ID); // Asset state data. diff --git a/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/integration/database/PostgreSQLTest.java b/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/integration/database/PostgreSQLTest.java index de0c7846a..d19bdbad9 100644 --- a/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/integration/database/PostgreSQLTest.java +++ b/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/integration/database/PostgreSQLTest.java @@ -41,7 +41,7 @@ SELECT count(*) as USER_COUNT @Test @DisplayName("LTree found in pg_extension") - public void treeFoundInPGExtension() throws SQLException { + public void lTreeFoundInPGExtension() throws SQLException { try (Connection connection = dataSource.getConnection()) { final ResultSet results = connection.createStatement() .executeQuery(""" diff --git a/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/util/TestWithMockServers.java b/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/util/TestWithMockServers.java index b826ab60d..a20bf424c 100644 --- a/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/util/TestWithMockServers.java +++ b/backend/explorer-core/autoconfigure/src/test/java/org/royllo/explorer/core/test/util/TestWithMockServers.java @@ -114,7 +114,7 @@ public void verifyTransaction(final BitcoinTransactionOutputDTO bitcoinTransacti public void verifyAssetGroup(final AssetGroupDTO assetGroupDTO, final String assetId) { // Finding asset group of the first decoded proof. - final DecodedProofValueResponse.DecodedProof.Asset assetFromTest = TapdData.findAssetValueByAssetId(assetId).getDecodedProof(0).getAsset(); + final DecodedProofValueResponse.DecodedProof.Asset assetFromTest = TapdData.findAssetValueByAssetId(assetId).getDecodedProofResponse(0).getAsset(); if (assetFromTest.getAssetGroup() != null) { assertEquals(assetGroupDTO.getRawGroupKey(), assetFromTest.getAssetGroup().getRawGroupKey(), @@ -200,42 +200,102 @@ public void verifyAsset(final AssetDTO assetDTO, public void verifyAssetState(final AssetStateDTO assetStateDTO, final String assetStateId) { // We find the asset state. - final Optional assetState = TapdData.findAssetStateByAssetStateId(assetStateId); - assertTrue(assetState.isPresent(), + final Optional assetFromTest = TapdData.findAssetStateByAssetStateId(assetStateId); + assertTrue(assetFromTest.isPresent(), "Asset state not found"); + assertEquals(assetStateDTO.getAnchorTx(), + assetFromTest.get().getAsset().getChainAnchor().getAnchorTx(), + "Anchor tx are not equals"); + // We compare each field. assertEquals(assetStateDTO.getAnchorBlockHash(), - assetState.get().getAsset().getChainAnchor().getAnchorBlockHash(), + assetFromTest.get().getAsset().getChainAnchor().getAnchorBlockHash(), "Anchor block hash are not equals"); assertEquals(assetStateDTO.getAnchorOutpoint().getTxId(), - assetState.get().getAsset().getChainAnchor().getAnchorTxId(), + assetFromTest.get().getAsset().getChainAnchor().getAnchorTxId(), "Anchor outpoint tx id are not equals"); - assertEquals(assetStateDTO.getAnchorTx(), - assetState.get().getAsset().getChainAnchor().getAnchorTx(), - "Anchor tx are not equals"); assertEquals(assetStateDTO.getInternalKey(), - assetState.get().getAsset().getChainAnchor().getInternalKey(), + assetFromTest.get().getAsset().getChainAnchor().getInternalKey(), "Internal key are not equals"); assertEquals(assetStateDTO.getMerkleRoot(), - assetState.get().getAsset().getChainAnchor().getMerkleRoot(), + assetFromTest.get().getAsset().getChainAnchor().getMerkleRoot(), "Merkle root are not equals"); assertEquals(assetStateDTO.getTapscriptSibling(), - assetState.get().getAsset().getChainAnchor().getTapscriptSibling(), + assetFromTest.get().getAsset().getChainAnchor().getTapscriptSibling(), "Tapscript sibling are not equals"); + assertEquals(assetStateDTO.getVersion(), + assetFromTest.get().getAsset().getVersion(), + "Version are not equals"); + + assertEquals(assetStateDTO.getAmount(), + assetFromTest.get().getAsset().getAmount(), + "Amount are not equals"); + + assertEquals(assetStateDTO.getLockTime(), + assetFromTest.get().getAsset().getLockTime(), + "Lock time are not equals"); + + assertEquals(assetStateDTO.getRelativeLockTime(), + assetFromTest.get().getAsset().getRelativeLockTime(), + "Relative lock time are not equals"); + assertEquals(assetStateDTO.getScriptVersion(), - assetState.get().getAsset().getScriptVersion(), + assetFromTest.get().getAsset().getScriptVersion(), "Script version are not equals"); assertEquals(assetStateDTO.getScriptKey(), - assetState.get().getAsset().getScriptKey(), + assetFromTest.get().getAsset().getScriptKey(), "Script key are not equals"); + + assertEquals(assetStateDTO.getLeaseOwner(), + assetFromTest.get().getAsset().getLeaseOwner(), + "Lease owner are not equals"); + + assertEquals(assetStateDTO.getLeaseExpiry(), + assetFromTest.get().getAsset().getLeaseExpiryTimestamp(), + "Lease expiry are not equals"); + + assertEquals(assetStateDTO.getTxMerkleProof(), + assetFromTest.get().getTxMerkleProof(), + "Tx merkle proof are not equals"); + + assertEquals(assetStateDTO.getInclusionProof(), + assetFromTest.get().getInclusionProof(), + "Inclusion proof are not equals"); + + assertEquals(assetStateDTO.getExclusionProofs().size(), + assetFromTest.get().getExclusionProofs().size(), + "Exclusion proofs size are not equals"); + + // Check that assetStateDTO.getExclusionProofs() and assetState.get().getExclusionProofs() have the same content. + for (int i = 0; i < assetStateDTO.getExclusionProofs().size(); i++) { + assertEquals(assetStateDTO.getExclusionProofs().get(i), + assetFromTest.get().getExclusionProofs().get(i), + "Exclusion proof are not equals"); + } + + assertEquals(assetStateDTO.getSplitRootProof(), + assetFromTest.get().getSplitRootProof(), + "Split root proof are not equals"); + + assertEquals(assetStateDTO.getChallengeWitness().size(), + assetFromTest.get().getChallengeWitness().size(), + "Challenge witness are not equals"); + + // Check that assetStateDTO.getChallengeWitness() and assetState.get().getChallengeWitness() have the same content. + for (int i = 0; i < assetStateDTO.getChallengeWitness().size(); i++) { + assertEquals(assetStateDTO.getChallengeWitness().get(i), + assetFromTest.get().getChallengeWitness().get(i), + "Challenge witness are not equals"); + } + } /** @@ -256,16 +316,13 @@ public void verifyAssetState(final AssetStateDTO assetStateDTO, String uniqueValue = assetId + "_" + outpointTxId + ":" + outpointVout + "_" + scriptKey; - String assetStateId = ""; try { MessageDigest md = MessageDigest.getInstance("SHA-256"); byte[] digest = md.digest(uniqueValue.getBytes(UTF_8)); - assetStateId = DatatypeConverter.printHexBinary(digest).toLowerCase(); + verifyAssetState(assetStateDTO, DatatypeConverter.printHexBinary(digest).toLowerCase()); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("SHA-256 is not available: " + e.getMessage()); } - - verifyAssetState(assetStateDTO, assetStateId); } } \ No newline at end of file diff --git a/backend/explorer-core/autoconfigure/src/test/resources/db/test/test-data-asset_state.xml b/backend/explorer-core/autoconfigure/src/test/resources/db/test/test-data-asset_state.xml index 8ce008112..b53d14289 100644 --- a/backend/explorer-core/autoconfigure/src/test/resources/db/test/test-data-asset_state.xml +++ b/backend/explorer-core/autoconfigure/src/test/resources/db/test/test-data-asset_state.xml @@ -20,6 +20,10 @@ + + + + @@ -41,6 +45,10 @@ + + + + @@ -58,6 +66,10 @@ + + + + @@ -75,6 +87,10 @@ + + + + @@ -96,6 +112,10 @@ + + + + @@ -113,6 +133,10 @@ + + + + @@ -130,6 +154,10 @@ + + + + @@ -147,6 +175,10 @@ + + + + @@ -168,6 +200,10 @@ + + + + @@ -185,6 +221,10 @@ + + + + diff --git a/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetDataFetcherTest.java b/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetDataFetcherTest.java index 5ab9fe1ce..7341662fd 100644 --- a/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetDataFetcherTest.java +++ b/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetDataFetcherTest.java @@ -72,7 +72,7 @@ public void queryAssets() { assertEquals(UNLIMITED_ROYLLO_COIN_2_ASSET_ID, assetPage.getContent().get(3).getAssetId()); // Query assets with an asset group id. - final String assetGroupId = SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getTweakedGroupKey(); + final String assetGroupId = SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getTweakedGroupKey(); assetPage = dgsQueryExecutor.executeAndExtractJsonPathAsObject( new GraphQLQueryRequest( QueryAssetsGraphQLQuery.newRequest().query(assetGroupId).page(1).build(), @@ -264,7 +264,7 @@ public void assetByAssetId() { // Testing results. assertNotNull(asset); - final DecodedProofValueResponse.DecodedProof assetFromTestData = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0); + final DecodedProofValueResponse.DecodedProof assetFromTestData = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0); // Asset. assertEquals(ANONYMOUS_USER_ID, asset.getCreator().getUserId()); diff --git a/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetGroupDataFetcherTest.java b/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetGroupDataFetcherTest.java index cb8b53bb8..bdc730194 100644 --- a/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetGroupDataFetcherTest.java +++ b/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetGroupDataFetcherTest.java @@ -29,7 +29,7 @@ public class AssetGroupDataFetcherTest { @Test @DisplayName("getAssetGroupByAssetGroupId()") public void getAssetGroupByAssetGroupId() { - final String assetGroupId = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getTweakedGroupKey(); + final String assetGroupId = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getTweakedGroupKey(); AssetGroup asset = dgsQueryExecutor.executeAndExtractJsonPathAsObject( new GraphQLQueryRequest( @@ -46,7 +46,7 @@ public void getAssetGroupByAssetGroupId() { }); assertNotNull(asset); - final DecodedProofValueResponse.DecodedProof.Asset.AssetGroup assetGroupFromTest = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup(); + final DecodedProofValueResponse.DecodedProof.Asset.AssetGroup assetGroupFromTest = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup(); assertEquals(ANONYMOUS_USER_ID, asset.getCreator().getUserId()); assertEquals(ANONYMOUS_USER_USERNAME, asset.getCreator().getUsername()); assertEquals(assetGroupFromTest.getTweakedGroupKey(), asset.getAssetGroupId()); diff --git a/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetStateDataFetcherTest.java b/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetStateDataFetcherTest.java index 89c716a3a..d021e07cd 100644 --- a/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetStateDataFetcherTest.java +++ b/backend/servers/explorer-api/src/test/java/org/royllo/explorer/api/test/graphql/AssetStateDataFetcherTest.java @@ -25,10 +25,10 @@ @DisplayName("AssetStateDataFetcher tests") public class AssetStateDataFetcherTest { - private static final String TRICKY_ROYLLO_COIN_ASSET_STATE_ID_1 = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId(); - private static final String TRICKY_ROYLLO_COIN_ASSET_STATE_ID_2 = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(1).getAsset().getAssetStateId(); - private static final String TRICKY_ROYLLO_COIN_ASSET_STATE_ID_3 = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(3).getAsset().getAssetStateId(); - private static final String TRICKY_ROYLLO_COIN_ASSET_STATE_ID_4 = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(4).getAsset().getAssetStateId(); + private static final String TRICKY_ROYLLO_COIN_ASSET_STATE_ID_1 = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId(); + private static final String TRICKY_ROYLLO_COIN_ASSET_STATE_ID_2 = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(1).getAsset().getAssetStateId(); + private static final String TRICKY_ROYLLO_COIN_ASSET_STATE_ID_3 = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(3).getAsset().getAssetStateId(); + private static final String TRICKY_ROYLLO_COIN_ASSET_STATE_ID_4 = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(4).getAsset().getAssetStateId(); @Autowired DgsQueryExecutor dgsQueryExecutor; diff --git a/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/RoylloNFTIntegrationTest.java b/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/RoylloNFTIntegrationTest.java index c25bc9fa8..06c940fd1 100644 --- a/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/RoylloNFTIntegrationTest.java +++ b/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/RoylloNFTIntegrationTest.java @@ -82,7 +82,7 @@ public void processProof() { // roylloNFT is not in our database - We add it (No asset group). final String ROYLLO_NFT_RAW_PROOF = ROYLLO_NFT_FROM_TEST.getDecodedProofRequest(0).getRawProof(); final String ROYLLO_NFT_PROOF_ID = sha256(ROYLLO_NFT_RAW_PROOF); - final String ROYLLO_NFT_ASSET_STATE_ID = ROYLLO_NFT_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId(); + final String ROYLLO_NFT_ASSET_STATE_ID = ROYLLO_NFT_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId(); // ============================================================================================================= // We check that the asset doesn't already exist. @@ -139,7 +139,7 @@ public void processProof() { ROYLLO_NFT_ASSET_ID, ROYLLO_NFT_ANCHOR_1_TXID, ROYLLO_NFT_ANCHOR_1_VOUT, - ROYLLO_NFT_FROM_TEST.getDecodedProof(0).getAsset().getScriptKey()); + ROYLLO_NFT_FROM_TEST.getDecodedProofResponse(0).getAsset().getScriptKey()); } } diff --git a/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/SetOfRoylloNFTIntegrationTest.java b/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/SetOfRoylloNFTIntegrationTest.java index b58ccc664..c82b73634 100644 --- a/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/SetOfRoylloNFTIntegrationTest.java +++ b/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/SetOfRoylloNFTIntegrationTest.java @@ -87,22 +87,22 @@ public void processProof() { // ============================================================================================================= // We retrieve the data. - final String SET_OF_ROYLLO_NFT_TWEAKED_GROUP_KEY = SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getTweakedGroupKey(); + final String SET_OF_ROYLLO_NFT_TWEAKED_GROUP_KEY = SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getTweakedGroupKey(); // NFT1. final String SET_OF_ROYLLO_NFT_1_RAW_PROOF = SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProofRequest(0).getRawProof(); final String SET_OF_ROYLLO_NFT_1_PROOF_ID = sha256(SET_OF_ROYLLO_NFT_1_RAW_PROOF); - final String SET_OF_ROYLLO_NFT_1_ASSET_STATE_ID = SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId(); + final String SET_OF_ROYLLO_NFT_1_ASSET_STATE_ID = SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId(); // NFT2. final String SET_OF_ROYLLO_NFT_2_RAW_PROOF = SET_OF_ROYLLO_NFT_2_FROM_TEST.getDecodedProofRequest(0).getRawProof(); final String SET_OF_ROYLLO_NFT_2_PROOF_ID = sha256(SET_OF_ROYLLO_NFT_2_RAW_PROOF); - final String SET_OF_ROYLLO_NFT_2_ASSET_STATE_ID = SET_OF_ROYLLO_NFT_2_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId(); + final String SET_OF_ROYLLO_NFT_2_ASSET_STATE_ID = SET_OF_ROYLLO_NFT_2_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId(); // NFT3. final String SET_OF_ROYLLO_NFT_3_RAW_PROOF = SET_OF_ROYLLO_NFT_3_FROM_TEST.getDecodedProofRequest(0).getRawProof(); final String SET_OF_ROYLLO_NFT_3_PROOF_ID = sha256(SET_OF_ROYLLO_NFT_3_RAW_PROOF); - final String SET_OF_ROYLLO_NFT_3_ASSET_STATE_ID = SET_OF_ROYLLO_NFT_3_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId(); + final String SET_OF_ROYLLO_NFT_3_ASSET_STATE_ID = SET_OF_ROYLLO_NFT_3_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId(); // ============================================================================================================= // We check that the asset doesn't already exist. @@ -207,7 +207,7 @@ public void processProof() { SET_OF_ROYLLO_NFT_1_ASSET_ID, SET_OF_ROYLLO_NFT_ANCHOR_1_TXID, SET_OF_ROYLLO_NFT_ANCHOR_1_VOUT, - SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProof(0).getAsset().getScriptKey()); + SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getScriptKey()); // NTF2. verifyTransaction(bitcoinService.getBitcoinTransactionOutput(SET_OF_ROYLLO_NFT_ANCHOR_2_TXID, SET_OF_ROYLLO_NFT_ANCHOR_2_VOUT).get(), @@ -217,7 +217,7 @@ public void processProof() { SET_OF_ROYLLO_NFT_2_ASSET_ID, SET_OF_ROYLLO_NFT_ANCHOR_2_TXID, SET_OF_ROYLLO_NFT_ANCHOR_2_VOUT, - SET_OF_ROYLLO_NFT_2_FROM_TEST.getDecodedProof(0).getAsset().getScriptKey()); + SET_OF_ROYLLO_NFT_2_FROM_TEST.getDecodedProofResponse(0).getAsset().getScriptKey()); // NTF1. verifyTransaction(bitcoinService.getBitcoinTransactionOutput(SET_OF_ROYLLO_NFT_ANCHOR_3_TXID, SET_OF_ROYLLO_NFT_ANCHOR_3_VOUT).get(), @@ -227,7 +227,7 @@ public void processProof() { SET_OF_ROYLLO_NFT_3_ASSET_ID, SET_OF_ROYLLO_NFT_ANCHOR_3_TXID, SET_OF_ROYLLO_NFT_ANCHOR_3_VOUT, - SET_OF_ROYLLO_NFT_3_FROM_TEST.getDecodedProof(0).getAsset().getScriptKey()); + SET_OF_ROYLLO_NFT_3_FROM_TEST.getDecodedProofResponse(0).getAsset().getScriptKey()); } } diff --git a/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/TrickyRoylloCoinIntegrationTest.java b/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/TrickyRoylloCoinIntegrationTest.java index fbdc71ae5..d2694b311 100644 --- a/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/TrickyRoylloCoinIntegrationTest.java +++ b/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/TrickyRoylloCoinIntegrationTest.java @@ -142,10 +142,10 @@ public void processProofs() { final String TRICKY_ROYLLO_COIN_3_PROOF_ID = sha256(TRICKY_ROYLLO_COIN_3_RAW_PROOF); // Asset states. - final String TRICKY_ROYLLO_COIN_1_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId(); - final String TRICKY_ROYLLO_COIN_2_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(1).getAsset().getAssetStateId(); - final String TRICKY_ROYLLO_COIN_3_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(3).getAsset().getAssetStateId(); - final String TRICKY_ROYLLO_COIN_4_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(4).getAsset().getAssetStateId(); + final String TRICKY_ROYLLO_COIN_1_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId(); + final String TRICKY_ROYLLO_COIN_2_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(1).getAsset().getAssetStateId(); + final String TRICKY_ROYLLO_COIN_3_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(3).getAsset().getAssetStateId(); + final String TRICKY_ROYLLO_COIN_4_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(4).getAsset().getAssetStateId(); // ============================================================================================================= // We check that the asset doesn't already exist. @@ -251,10 +251,10 @@ public void processProofsStartingFromTheLastOne() { final String TRICKY_ROYLLO_COIN_3_PROOF_ID = sha256(TRICKY_ROYLLO_COIN_3_RAW_PROOF); // Asset states. - final String TRICKY_ROYLLO_COIN_1_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId(); - final String TRICKY_ROYLLO_COIN_2_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(1).getAsset().getAssetStateId(); - final String TRICKY_ROYLLO_COIN_3_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(3).getAsset().getAssetStateId(); - final String TRICKY_ROYLLO_COIN_4_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(4).getAsset().getAssetStateId(); + final String TRICKY_ROYLLO_COIN_1_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId(); + final String TRICKY_ROYLLO_COIN_2_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(1).getAsset().getAssetStateId(); + final String TRICKY_ROYLLO_COIN_3_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(3).getAsset().getAssetStateId(); + final String TRICKY_ROYLLO_COIN_4_ASSET_STATE_ID = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(4).getAsset().getAssetStateId(); // ============================================================================================================= // We check that the asset doesn't already exist. diff --git a/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/UnknownRoylloCoinIntegrationTest.java b/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/UnknownRoylloCoinIntegrationTest.java index 50e158884..8e2752430 100644 --- a/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/UnknownRoylloCoinIntegrationTest.java +++ b/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/UnknownRoylloCoinIntegrationTest.java @@ -82,7 +82,7 @@ public void processProof() { // unknownRoylloCoin is not in our database - We add it (No asset group). final String UNKNOWN_ROYLLO_COIN_RAW_PROOF = UNKNOWN_ROYLLO_COIN_FROM_TEST.getDecodedProofRequest(0).getRawProof(); final String UNKNOWN_ROYLLO_COIN_PROOF_ID = sha256(UNKNOWN_ROYLLO_COIN_RAW_PROOF); - final String UNKNOWN_ROYLLO_COIN_STATE_ID = UNKNOWN_ROYLLO_COIN_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId(); + final String UNKNOWN_ROYLLO_COIN_STATE_ID = UNKNOWN_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId(); // ============================================================================================================= // We check that the asset doesn't already exist. @@ -137,7 +137,7 @@ public void processProof() { UNKNOWN_ROYLLO_COIN_ASSET_ID, UNKNOWN_ROYLLO_COIN_ANCHOR_1_TXID, UNKNOWN_ROYLLO_COIN_ANCHOR_1_VOUT, - UNKNOWN_ROYLLO_COIN_FROM_TEST.getDecodedProof(0).getAsset().getScriptKey()); + UNKNOWN_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(0).getAsset().getScriptKey()); } } diff --git a/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/UnlimitedRoylloCoinIntegrationTest.java b/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/UnlimitedRoylloCoinIntegrationTest.java index 11cd5c4dd..dc4a5fff6 100644 --- a/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/UnlimitedRoylloCoinIntegrationTest.java +++ b/backend/servers/explorer-batch/src/test/java/org/royllo/explorer/batch/test/core/proof/UnlimitedRoylloCoinIntegrationTest.java @@ -84,17 +84,17 @@ public class UnlimitedRoylloCoinIntegrationTest extends TestWithMockServers { @DisplayName("Process proof") public void processProof() { // unlimitedRoylloCoin. You will have an asset group and two emissions. - final String UNLIMITED_ROYLLO_COIN_TWEAKED_GROUP_KEY = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetGroup().getTweakedGroupKey(); + final String UNLIMITED_ROYLLO_COIN_TWEAKED_GROUP_KEY = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetGroup().getTweakedGroupKey(); // First emission. final String UNLIMITED_ROYLLO_COIN_1_RAW_PROOF = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofRequest(0).getRawProof(); final String UNLIMITED_ROYLLO_COIN_1_PROOF_ID = sha256(UNLIMITED_ROYLLO_COIN_1_RAW_PROOF); - final String UNLIMITED_ROYLLO_COIN_1_ASSET_STATE_ID = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId(); + final String UNLIMITED_ROYLLO_COIN_1_ASSET_STATE_ID = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId(); // Second emission. final String UNLIMITED_ROYLLO_COIN_2_RAW_PROOF = UNLIMITED_ROYLLO_COIN_2_FROM_TEST.getDecodedProofRequest(0).getRawProof(); final String UNLIMITED_ROYLLO_COIN_2_PROOF_ID = sha256(UNLIMITED_ROYLLO_COIN_2_RAW_PROOF); - final String UNLIMITED_ROYLLO_COIN_2_ASSET_STATE_ID = UNLIMITED_ROYLLO_COIN_2_FROM_TEST.getDecodedProof(0).getAsset().getAssetStateId(); + final String UNLIMITED_ROYLLO_COIN_2_ASSET_STATE_ID = UNLIMITED_ROYLLO_COIN_2_FROM_TEST.getDecodedProofResponse(0).getAsset().getAssetStateId(); // ============================================================================================================= // We check that the asset doesn't already exist. diff --git a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayRoylloCoinTest.java b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayRoylloCoinTest.java index 168807994..d3ef52778 100644 --- a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayRoylloCoinTest.java +++ b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayRoylloCoinTest.java @@ -43,7 +43,7 @@ public class DisplayRoylloCoinTest extends BaseTest { @MethodSource("headers") @DisplayName("Check roylloCoin asset page") void assetPage(final HttpHeaders headers) throws Exception { - final DecodedProofValueResponse.DecodedProof assetFromTest = ROYLLO_COIN_FROM_TEST.getDecodedProof(0); + final DecodedProofValueResponse.DecodedProof assetFromTest = ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(0); mockMvc.perform(get("/asset/" + ROYLLO_COIN_ASSET_ID).headers(headers)) .andExpect(status().isOk()) diff --git a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayRoylloNFTTest.java b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayRoylloNFTTest.java index 03365a2b1..67ff8927c 100644 --- a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayRoylloNFTTest.java +++ b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayRoylloNFTTest.java @@ -43,7 +43,7 @@ public class DisplayRoylloNFTTest extends BaseTest { @MethodSource("headers") @DisplayName("Check roylloNFT asset page") void assetPage(final HttpHeaders headers) throws Exception { - final DecodedProofValueResponse.DecodedProof assetFromTest = ROYLLO_NFT_FROM_TEST.getDecodedProof(0); + final DecodedProofValueResponse.DecodedProof assetFromTest = ROYLLO_NFT_FROM_TEST.getDecodedProofResponse(0); mockMvc.perform(get("/asset/" + ROYLLO_NFT_ASSET_ID).headers(headers)) .andExpect(status().isOk()) diff --git a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT1Test.java b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT1Test.java index 174da9068..dfe2681ca 100644 --- a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT1Test.java +++ b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT1Test.java @@ -43,7 +43,7 @@ public class DisplaySetRoylloNFT1Test extends BaseTest { @MethodSource("headers") @DisplayName("Check setRoylloNFT1 asset page") void assetPage(final HttpHeaders headers) throws Exception { - final DecodedProofValueResponse.DecodedProof assetFromTest = SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProof(0); + final DecodedProofValueResponse.DecodedProof assetFromTest = SET_OF_ROYLLO_NFT_1_FROM_TEST.getDecodedProofResponse(0); mockMvc.perform(get("/asset/" + SET_OF_ROYLLO_NFT_1_ASSET_ID).headers(headers)) .andExpect(status().isOk()) diff --git a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT2Test.java b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT2Test.java index a5819d87b..5d338bf5d 100644 --- a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT2Test.java +++ b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT2Test.java @@ -43,7 +43,7 @@ public class DisplaySetRoylloNFT2Test extends BaseTest { @MethodSource("headers") @DisplayName("Check setRoylloNFT2 asset page") void assetPage(final HttpHeaders headers) throws Exception { - final DecodedProofValueResponse.DecodedProof assetFromTest = SET_OF_ROYLLO_NFT_2_FROM_TEST.getDecodedProof(0); + final DecodedProofValueResponse.DecodedProof assetFromTest = SET_OF_ROYLLO_NFT_2_FROM_TEST.getDecodedProofResponse(0); mockMvc.perform(get("/asset/" + SET_OF_ROYLLO_NFT_2_ASSET_ID).headers(headers)) .andExpect(status().isOk()) diff --git a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT3Test.java b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT3Test.java index 0497e3592..b8b6eea55 100644 --- a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT3Test.java +++ b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplaySetRoylloNFT3Test.java @@ -43,7 +43,7 @@ public class DisplaySetRoylloNFT3Test extends BaseTest { @MethodSource("headers") @DisplayName("Check setRoylloNFT3 asset page") void assetPage(final HttpHeaders headers) throws Exception { - final DecodedProofValueResponse.DecodedProof assetFromTest = SET_OF_ROYLLO_NFT_3_FROM_TEST.getDecodedProof(0); + final DecodedProofValueResponse.DecodedProof assetFromTest = SET_OF_ROYLLO_NFT_3_FROM_TEST.getDecodedProofResponse(0); mockMvc.perform(get("/asset/" + SET_OF_ROYLLO_NFT_3_ASSET_ID).headers(headers)) .andExpect(status().isOk()) diff --git a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayTrickyRoylloCoinTest.java b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayTrickyRoylloCoinTest.java index 5433ed8a2..0590a8333 100644 --- a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayTrickyRoylloCoinTest.java +++ b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayTrickyRoylloCoinTest.java @@ -44,11 +44,11 @@ public class DisplayTrickyRoylloCoinTest extends BaseTest { @DisplayName("Check trickyRoylloCoin asset page") void assetPage(final HttpHeaders headers) throws Exception { // Test data. - final DecodedProofValueResponse.DecodedProof assetFromTest = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(0); - final DecodedProofValueResponse.DecodedProof.Asset TRICKY_ROYLLO_COIN_1_ASSET_STATE = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(0).getAsset(); - final DecodedProofValueResponse.DecodedProof.Asset TRICKY_ROYLLO_COIN_2_ASSET_STATE = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(1).getAsset(); - final DecodedProofValueResponse.DecodedProof.Asset TRICKY_ROYLLO_COIN_3_ASSET_STATE = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(3).getAsset(); - final DecodedProofValueResponse.DecodedProof.Asset TRICKY_ROYLLO_COIN_4_ASSET_STATE = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProof(4).getAsset(); + final DecodedProofValueResponse.DecodedProof assetFromTest = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(0); + final DecodedProofValueResponse.DecodedProof.Asset TRICKY_ROYLLO_COIN_1_ASSET_STATE = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(0).getAsset(); + final DecodedProofValueResponse.DecodedProof.Asset TRICKY_ROYLLO_COIN_2_ASSET_STATE = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(1).getAsset(); + final DecodedProofValueResponse.DecodedProof.Asset TRICKY_ROYLLO_COIN_3_ASSET_STATE = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(3).getAsset(); + final DecodedProofValueResponse.DecodedProof.Asset TRICKY_ROYLLO_COIN_4_ASSET_STATE = TRICKY_ROYLLO_COIN_FROM_TEST.getDecodedProofResponse(4).getAsset(); mockMvc.perform(get("/asset/" + TRICKY_ROYLLO_COIN_ASSET_ID).headers(headers)) .andExpect(status().isOk()) diff --git a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayUnlimitedRoylloCoin1Test.java b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayUnlimitedRoylloCoin1Test.java index 184274b40..b5c67ff42 100644 --- a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayUnlimitedRoylloCoin1Test.java +++ b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayUnlimitedRoylloCoin1Test.java @@ -43,7 +43,7 @@ public class DisplayUnlimitedRoylloCoin1Test extends BaseTest { @MethodSource("headers") @DisplayName("Check unlimitedRoylloCoin1 asset page") void assetPage(final HttpHeaders headers) throws Exception { - final DecodedProofValueResponse.DecodedProof assetFromTest = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProof(0); + final DecodedProofValueResponse.DecodedProof assetFromTest = UNLIMITED_ROYLLO_COIN_1_FROM_TEST.getDecodedProofResponse(0); mockMvc.perform(get("/asset/" + UNLIMITED_ROYLLO_COIN_1_ASSET_ID).headers(headers)) .andExpect(status().isOk()) diff --git a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayUnlimitedRoylloCoin2Test.java b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayUnlimitedRoylloCoin2Test.java index 37b6ff05a..7dfbeabaa 100644 --- a/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayUnlimitedRoylloCoin2Test.java +++ b/backend/servers/explorer-web/src/test/java/org/royllo/explorer/web/test/controllers/asset/DisplayUnlimitedRoylloCoin2Test.java @@ -43,7 +43,7 @@ public class DisplayUnlimitedRoylloCoin2Test extends BaseTest { @MethodSource("headers") @DisplayName("Check unlimitedRoylloCoin2 asset page") void assetPage(final HttpHeaders headers) throws Exception { - final DecodedProofValueResponse.DecodedProof assetFromTest = UNLIMITED_ROYLLO_COIN_2_FROM_TEST.getDecodedProof(0); + final DecodedProofValueResponse.DecodedProof assetFromTest = UNLIMITED_ROYLLO_COIN_2_FROM_TEST.getDecodedProofResponse(0); mockMvc.perform(get("/asset/" + UNLIMITED_ROYLLO_COIN_2_ASSET_ID).headers(headers)) .andExpect(status().isOk()) diff --git a/util/test/common-test/src/main/java/org/royllo/test/TapdData.java b/util/test/common-test/src/main/java/org/royllo/test/TapdData.java index ef1c2ad32..ee045aa39 100644 --- a/util/test/common-test/src/main/java/org/royllo/test/TapdData.java +++ b/util/test/common-test/src/main/java/org/royllo/test/TapdData.java @@ -165,7 +165,7 @@ public static AssetValue findAssetValueByAssetId(final String assetId) { * @return first decoded proof */ public static DecodedProofValueResponse.DecodedProof findFirstDecodedProof(final String assetId) { - return ASSETS.get(assetId).getDecodedProof(1); + return ASSETS.get(assetId).getDecodedProofResponse(1); } /** diff --git a/util/test/common-test/src/main/java/org/royllo/test/tapd/asset/AssetValue.java b/util/test/common-test/src/main/java/org/royllo/test/tapd/asset/AssetValue.java index c09085c38..c0720136f 100644 --- a/util/test/common-test/src/main/java/org/royllo/test/tapd/asset/AssetValue.java +++ b/util/test/common-test/src/main/java/org/royllo/test/tapd/asset/AssetValue.java @@ -46,7 +46,7 @@ public DecodedProofValueRequest getDecodedProofRequest(final int i) { * @param i index * @return decoded proof */ - public DecodedProofValueResponse.DecodedProof getDecodedProof(final int i) { + public DecodedProofValueResponse.DecodedProof getDecodedProofResponse(final int i) { return decodedProofValues.get(i).getResponse().getDecodedProof(); } diff --git a/util/test/common-test/src/main/java/org/royllo/test/tapd/asset/DecodedProofValueResponse.java b/util/test/common-test/src/main/java/org/royllo/test/tapd/asset/DecodedProofValueResponse.java index def6042b5..1b79f3e01 100644 --- a/util/test/common-test/src/main/java/org/royllo/test/tapd/asset/DecodedProofValueResponse.java +++ b/util/test/common-test/src/main/java/org/royllo/test/tapd/asset/DecodedProofValueResponse.java @@ -151,6 +151,23 @@ public static class Asset { @JsonProperty("is_burn") Boolean isBurn; + /** + * If the asset has been leased, this is the expiry of the lease as a Unix timestamp in seconds. + * + * @return lease expiry timestamp + */ + public final Long getLeaseExpiryTimestamp() { + if (leaseExpiry == null) { + return 0L; + } else { + try { + return Long.parseLong(leaseExpiry); + } catch (NumberFormatException e) { + return 0L; + } + } + } + /** * Returns the calculated state id. * diff --git a/util/test/common-test/src/test/java/org/royllo/test/TapdDataTest.java b/util/test/common-test/src/test/java/org/royllo/test/TapdDataTest.java index 8b6243789..21365b84f 100644 --- a/util/test/common-test/src/test/java/org/royllo/test/TapdDataTest.java +++ b/util/test/common-test/src/test/java/org/royllo/test/TapdDataTest.java @@ -55,7 +55,7 @@ public void roylloCoinValue() { assertNotNull(roylloCoin); // Decoded proof 1. - final DecodedProofValueResponse.DecodedProof roylloCoinProof = roylloCoin.getDecodedProof(0); + final DecodedProofValueResponse.DecodedProof roylloCoinProof = roylloCoin.getDecodedProofResponse(0); // Decoded proof. assertEquals(0, roylloCoinProof.getProofAtDepth()); assertEquals(1, roylloCoinProof.getNumberOfProofs()); @@ -106,7 +106,7 @@ public void roylloCoinValue() { final AssetValue unlimitedRoylloCoin1 = TapdData.findAssetValueByAssetId(UNLIMITED_ROYLLO_COIN_1_ASSET_ID); assertNotNull(unlimitedRoylloCoin1); // Decoded proof 1. - final DecodedProofValueResponse.DecodedProof unlimitedRoylloCoin1Proof = unlimitedRoylloCoin1.getDecodedProof(0); + final DecodedProofValueResponse.DecodedProof unlimitedRoylloCoin1Proof = unlimitedRoylloCoin1.getDecodedProofResponse(0); // Test for "asset_group". assertNotNull(unlimitedRoylloCoin1Proof.getAsset().getAssetGroup()); assertEquals("", unlimitedRoylloCoin1Proof.getAsset().getAssetGroup().getRawGroupKey()); @@ -114,4 +114,13 @@ public void roylloCoinValue() { assertEquals("", unlimitedRoylloCoin1Proof.getAsset().getAssetGroup().getAssetWitness()); } + @Test + @DisplayName("Tricky coin value") + public void trickyCoinValue() { + // We test some fields that are not in royllo coin decoded proof. + // We are using trickyRoylloCoin/decodeProof-proofFile3-proofAtDepth0-response.json + final DecodedProofValueResponse.DecodedProof roylloCoinProof3 = TapdData.findAssetValueByAssetId(TRICKY_ROYLLO_COIN_ASSET_ID).getDecodedProofResponse(3); + assertEquals("000400000000022102bfca44f6bdfd7d54ce75e775049026015f7745ddef61610d4a6488c42f06f0a8037401490001000220e16029acc4d2cf0505857265442344efb5547f2047a3fc1c4822683f7c57820e04220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff022700010002220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", roylloCoinProof3.getSplitRootProof()); + } + }