diff --git a/sdk/tests/types/api/core.rs b/sdk/tests/types/api/core.rs new file mode 100644 index 0000000000..cdbbcb8327 --- /dev/null +++ b/sdk/tests/types/api/core.rs @@ -0,0 +1,103 @@ +// Copyright 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use iota_sdk::types::{ + api::core::{ + BlockMetadataResponse, BlockWithMetadataResponse, CommitteeResponse, CongestionResponse, InfoResponse, + IssuanceBlockHeaderResponse, ManaRewardsResponse, OutputResponse, RoutesResponse, SubmitBlockResponse, + TransactionMetadataResponse, UtxoChangesFullResponse, UtxoChangesResponse, ValidatorResponse, + ValidatorsResponse, + }, + block::{ + output::{OutputMetadata, OutputWithMetadata}, + slot::SlotCommitment, + BlockDto, + }, +}; +use packable::{ + error::{UnexpectedEOF, UnpackError}, + unpacker::SliceUnpacker, + Packable, PackableExt, +}; +// use pretty_assertions::assert_eq; +use serde::{Deserialize, Serialize}; + +fn json_response(path: &str) -> Result +where + for<'a> T: Serialize + Deserialize<'a>, +{ + let file = std::fs::read_to_string(&format!("./tests/types/api/fixtures/{path}")).unwrap(); + let value_des = serde_json::from_str::(&file)?; + let t = serde_json::from_value::(value_des.clone())?; + // let value_ser = serde_json::to_value(&t)?; + + // TODO https://github.com/iotaledger/iota-sdk/issues/1883 + // assert_eq!(value_des, value_ser); + + Ok(t) +} + +fn binary_response( + path: &str, + visitor: &T::UnpackVisitor, +) -> Result::UnpackError, UnexpectedEOF>> { + let file = std::fs::read_to_string(&format!("./tests/types/api/fixtures/{path}")).unwrap(); + let bytes = hex::decode(file).unwrap(); + let mut unpacker = SliceUnpacker::new(bytes.as_slice()); + let res = T::unpack::<_, true>(&mut unpacker, visitor); + + assert!(u8::unpack::<_, true>(&mut unpacker, &()).is_err()); + + res +} + +#[test] +fn responses() { + // GET /api/routes + json_response::("get-routes-response-example.json").unwrap(); + // GET /api/core/v3/info + json_response::("get-info-response-example.json").unwrap(); + // GET /api/core/v3/accounts/{bech32Address}/congestion + json_response::("get-congestion-estimate-response-example.json").unwrap(); + // GET /api/core/v3/rewards/{outputId} + json_response::("get-mana-rewards-example.json").unwrap(); + // GET /api/core/v3/validators + json_response::("get-validators-example.json").unwrap(); + // GET /api/core/v3/validators/{bech32Address} + json_response::("get-validator-example.json").unwrap(); + // GET /api/core/v3/committee + json_response::("get-committee-example.json").unwrap(); + // GET /api/core/v3/blocks/issuance + json_response::("get-buildingBlock-response-example.json").unwrap(); + // POST /api/core/v3/blocks + json_response::("post-blocks-response-example.json").unwrap(); + // GET /api/core/v3/blocks/{blockId} + json_response::("get-block-by-id-empty-response-example.json").unwrap(); + json_response::("tagged-data-block-example.json").unwrap(); + json_response::("transaction-block-example.json").unwrap(); + json_response::("get-block-by-id-validation-response-example.json").unwrap(); + // GET /api/core/v3/blocks/{blockId}/metadata + json_response::("get-block-by-id-response-example-new-transaction.json").unwrap(); + json_response::("get-block-by-id-response-example-new.json").unwrap(); + json_response::("get-block-by-id-response-example-confirmed-transaction.json").unwrap(); + json_response::("get-block-by-id-response-example-confirmed.json").unwrap(); + json_response::("get-block-by-id-response-example-conflicting-transaction.json").unwrap(); + // GET /api/core/v3/blocks/{blockId}/full + json_response::("get-full-block-by-id-tagged-data-response-example.json").unwrap(); + // GET /api/core/v3/outputs/{outputId} + json_response::("get-outputs-by-id-response-example.json").unwrap(); + // GET /api/core/v3/outputs/{outputId}/metadata + json_response::("get-output-metadata-by-id-response-unspent-example.json").unwrap(); + json_response::("get-output-metadata-by-id-response-spent-example.json").unwrap(); + // GET /api/core/v3/outputs/{outputId}/full + json_response::("get-full-output-metadata-example.json").unwrap(); + // GET /api/core/v3/transactions/{transactionId}/metadata + json_response::("get-transaction-metadata-by-id-response-example.json").unwrap(); + // GET /api/core/v3/commitments/{commitmentId} + json_response::("get-commitment-response-example.json").unwrap(); + binary_response::("get-commitment-response-binary-example", &()).unwrap(); + // GET /api/core/v3/commitments/{commitmentId}/utxo-changes + json_response::("get-utxo-changes-response-example.json").unwrap(); + // GET /api/core/v3/commitments/{commitmentId}/utxo-changes/full + json_response::("get-utxo-changes-full-response-example.json").unwrap(); +} diff --git a/sdk/tests/types/api/fixtures/get-block-by-id-empty-response-example.json b/sdk/tests/types/api/fixtures/get-block-by-id-empty-response-example.json new file mode 100644 index 0000000000..a16bc2b065 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-block-by-id-empty-response-example.json @@ -0,0 +1,27 @@ +{ + "header": { + "protocolVersion": 3, + "networkId": "8342982141227064571", + "issuingTime": "1695275852000000000", + "slotCommitmentId": "0x3a1e3b617060146e0362361a4b752833186108395f3b2b3d3e6c655e287d70767ea58d2a", + "latestFinalizedSlot": 500, + "issuerId": "0x17432c5a7a672503480241125e3952414a7a320441080c624c264b004e09614a" + }, + "body": { + "type": 0, + "strongParents": [ + "0x27e0461873f37040c9e59c35ad8a106fa1b94f5ec9ef89499b31904f9a3de59be58dd44a", + "0x714821f8f257e0a502b71ac7ee57530bb9dc29fe12ff3936f925b835a297680400b76948", + "0x9951e512546cd9c9fbdab348b6cba91a601a29b50854e55a6e14f6803ca1d81ac7eff5ce", + "0xaaa7bacf26f1aa4754d42edeab45d6169ea723b7fdf0f6ff3b6ebe90d09dbff6bc553936", + "0xba75a143de4ac932986fbe7b1d78f639bc6ee8aee10d510d41572851530be884778052aa", + "0xea5315941f4337752905599710b55e64018c71f4d8f299d0636d50484d05e6ac5667b503" + ], + "maxBurnedMana": "864" + }, + "signature": { + "type": 0, + "publicKey": "0x2daefbcbadd044da470acd2f7fcf6fcb04b873cc801e7ee408018e1dfa0257ac", + "signature": "0x74e57aa62358bb91ee931c05337a3af2e624fa9b20b04fcb4e15da0a9a4b4281a50ef6384ab7977179d16bd326cebb714c4653e1711447f18cefe1066aa1610d" + } +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-block-by-id-response-example-confirmed-transaction.json b/sdk/tests/types/api/fixtures/get-block-by-id-response-example-confirmed-transaction.json new file mode 100644 index 0000000000..c997aa439c --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-block-by-id-response-example-confirmed-transaction.json @@ -0,0 +1,8 @@ +{ + "blockId": "0xf7ac0552041789a3931ae76eafa47df063632cddd3f8b11bd0bfffba1bc8c46800000000", + "blockState": "confirmed", + "transactionMetadata": { + "transactionId": "0x72f0dfa9ad116ade8bdac8ef291ed2fb8065c6c75d5d3666e8b2053696c94a9e00001000", + "transactionState": "confirmed" + } +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-block-by-id-response-example-confirmed.json b/sdk/tests/types/api/fixtures/get-block-by-id-response-example-confirmed.json new file mode 100644 index 0000000000..b85fc2bf65 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-block-by-id-response-example-confirmed.json @@ -0,0 +1,4 @@ +{ + "blockId": "0x3848a6d17070830206e5032fbce2ae3939e60eec0816546e074316b1f66977d04d010000", + "blockState": "confirmed" +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-block-by-id-response-example-conflicting-transaction.json b/sdk/tests/types/api/fixtures/get-block-by-id-response-example-conflicting-transaction.json new file mode 100644 index 0000000000..366ef2fc87 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-block-by-id-response-example-conflicting-transaction.json @@ -0,0 +1,9 @@ +{ + "blockId": "0x3848a6d17070830206e5032fbce2ae3939e60eec0816546e074316b1f66977d04d010000", + "blockState": "confirmed", + "transactionMetadata": { + "transactionId": "0x72f0dfa9ad116ade8bdac8ef291ed2fb8065c6c75d5d3666e8b2053696c94a9e00001000", + "transactionState": "failed", + "transactionFailureReason": 2 + } +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-block-by-id-response-example-new-transaction.json b/sdk/tests/types/api/fixtures/get-block-by-id-response-example-new-transaction.json new file mode 100644 index 0000000000..5d87ad7244 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-block-by-id-response-example-new-transaction.json @@ -0,0 +1,8 @@ +{ + "blockId": "0x0482f0eba39a23c9a13072c93d828b55543132c47f5f57514d9e55535e9d4f4f35000000", + "blockState": "pending", + "transactionMetadata": { + "transactionId": "0x72f0dfa9ad116ade8bdac8ef291ed2fb8065c6c75d5d3666e8b2053696c94a9e00001000", + "transactionState": "pending" + } +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-block-by-id-response-example-new.json b/sdk/tests/types/api/fixtures/get-block-by-id-response-example-new.json new file mode 100644 index 0000000000..44fc4e478d --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-block-by-id-response-example-new.json @@ -0,0 +1,4 @@ +{ + "blockId": "0x0482f0eba39a23c9a13072c93d828b55543132c47f5f57514d9e55535e9d4f4f35000000", + "blockState": "pending" +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-block-by-id-validation-response-example.json b/sdk/tests/types/api/fixtures/get-block-by-id-validation-response-example.json new file mode 100644 index 0000000000..df4837589c --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-block-by-id-validation-response-example.json @@ -0,0 +1,28 @@ +{ + "header": { + "protocolVersion": 3, + "networkId": "8342982141227064571", + "issuingTime": "1695275852000000000", + "slotCommitmentId": "0x3a1e3b617060146e0362361a4b752833186108395f3b2b3d3e6c655e287d70767ea58d2a", + "latestFinalizedSlot": 500, + "issuerId": "0x17432c5a7a672503480241125e3952414a7a320441080c624c264b004e09614a" + }, + "body": { + "type": 1, + "strongParents": [ + "0x27e0461873f37040c9e59c35ad8a106fa1b94f5ec9ef89499b31904f9a3de59be58dd44a", + "0x714821f8f257e0a502b71ac7ee57530bb9dc29fe12ff3936f925b835a297680400b76948", + "0x9951e512546cd9c9fbdab348b6cba91a601a29b50854e55a6e14f6803ca1d81ac7eff5ce", + "0xaaa7bacf26f1aa4754d42edeab45d6169ea723b7fdf0f6ff3b6ebe90d09dbff6bc553936", + "0xba75a143de4ac932986fbe7b1d78f639bc6ee8aee10d510d41572851530be884778052aa", + "0xea5315941f4337752905599710b55e64018c71f4d8f299d0636d50484d05e6ac5667b503" + ], + "highestSupportedVersion": 3, + "protocolParametersHash": "0x0c0a5be47669365426b3e34ecd68f8fe6c70656a54139a1e1cd6fd779bfb476f" + }, + "signature": { + "type": 0, + "publicKey": "0x2daefbcbadd044da470acd2f7fcf6fcb04b873cc801e7ee408018e1dfa0257ac", + "signature": "0x3b6185bb5757d5e7fd576eeedf0c765c44cbcfe148261b8558a942867528f2cfe5a39a6ecd7bf7e82e134867a75df05385624be8c4102b3b77b397163459460b" + } +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-buildingBlock-response-example.json b/sdk/tests/types/api/fixtures/get-buildingBlock-response-example.json new file mode 100644 index 0000000000..51c5c29f40 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-buildingBlock-response-example.json @@ -0,0 +1,24 @@ +{ + "strongParents": [ + "0x0482f0eba39a23c9a13072c93d828b55543132c47f5f57514d9e55535e9d4f4f35000000", + "0xae7c4f55a6db8bf4841e4a38f06d32ab9bd88b927a6ba0bc19bcb19c625ff8b63c000000" + ], + "weakParents": [ + "0x67e57f7446b5a6f152afabb17c6077c26512278a275310a7ff2fa513f4e0b7383d000000", + "0x2e65c319e9a2c4a6ff7195f9a1ed896c43d0dded1b906979316d502b158965c23d000000" + ], + "shallowLikeParents": [ + "0xe5fe5231630afaaba609af76787ff1ec9c6088dd17e9cf922152b3facd7bd5883e000000", + "0xed4b771b5413f5118dd80021ca07fb727e4c54eec9d28d6566c28cc81e7d267c3f000000" + ], + "latestParentBlockIssuingTime": "1690879505000000000", + "latestFinalizedSlot": 1422, + "latestCommitment": { + "protocolVersion": 3, + "slot": 1432, + "previousCommitmentId": "0xc0300d55fe2cdc93191e52685da009f53d40883ae111291e550eed4e7eb7752746010000", + "rootsId": "0x6a8f424929e1f08d87a204efc8a60499b789465aaa28178b77debe75cc2915d3", + "cumulativeWeight": "45678", + "referenceManaCost": "12345" + } +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-commitment-response-binary-example b/sdk/tests/types/api/fixtures/get-commitment-response-binary-example new file mode 100644 index 0000000000..23453fa61e --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-commitment-response-binary-example @@ -0,0 +1 @@ +0312000000075b05e0a8fd4b9c7e7bc165b62c48945292f7d76d23f76525f886c416dc0e364089b57c32ddb8c614ed1d2c844401d2a5325b4d153c7f94464bbda3a8d14289b203f96759000000000000009000000000000000 \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-commitment-response-example.json b/sdk/tests/types/api/fixtures/get-commitment-response-example.json new file mode 100644 index 0000000000..e9c6ad0837 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-commitment-response-example.json @@ -0,0 +1,8 @@ +{ + "protocolVersion": 3, + "slot": 986, + "previousCommitmentId": "0xd91549dbf441da4c7e50063b58c05d5b2bfb1d33b346a2f9a18220ce6207f7a289010000", + "rootsId": "0x6a8f424929e1f08d87a204efc8a60499b789465aaa28178b77debe75cc2915d3", + "cumulativeWeight": "78901", + "referenceManaCost": "600" +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-committee-example.json b/sdk/tests/types/api/fixtures/get-committee-example.json new file mode 100644 index 0000000000..f7f0ee3581 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-committee-example.json @@ -0,0 +1,19 @@ +{ + "epoch": 10, + "totalStake": "900000000", + "totalValidatorStake": "60000000", + "committee": [ + { + "address": "rms1pqm4xk8e9ny5w5rxjkvtp249tfhlwvcshyr3pc0665jvp7g3hc875k538hl", + "poolStake": "200000", + "validatorStake": "100000", + "fixedCost": "50000" + }, + { + "address": "rms1pp4wuuz0y42caz48vv876qfpmffswsvg40zz8v79sy8cp0jfxm4kunflcgt", + "poolStake": "205000", + "validatorStake": "90000", + "fixedCost": "52000" + } + ] +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-congestion-estimate-response-example.json b/sdk/tests/types/api/fixtures/get-congestion-estimate-response-example.json new file mode 100644 index 0000000000..0e1761603c --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-congestion-estimate-response-example.json @@ -0,0 +1,6 @@ +{ + "slot": 20, + "ready": true, + "referenceManaCost": "50000", + "blockIssuanceCredits": "10000000" +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-full-block-by-id-tagged-data-response-example.json b/sdk/tests/types/api/fixtures/get-full-block-by-id-tagged-data-response-example.json new file mode 100644 index 0000000000..155cbceb74 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-full-block-by-id-tagged-data-response-example.json @@ -0,0 +1,38 @@ +{ + "block": { + "header": { + "protocolVersion": 3, + "networkId": "8342982141227064571", + "issuingTime": "1695275852000000000", + "slotCommitmentId": "0x3a1e3b617060146e0362361a4b752833186108395f3b2b3d3e6c655e287d70767ea58d2a", + "latestFinalizedSlot": 500, + "issuerId": "0x17432c5a7a672503480241125e3952414a7a320441080c624c264b004e09614a" + }, + "body": { + "type": 0, + "strongParents": [ + "0x27e0461873f37040c9e59c35ad8a106fa1b94f5ec9ef89499b31904f9a3de59be58dd44a", + "0x714821f8f257e0a502b71ac7ee57530bb9dc29fe12ff3936f925b835a297680400b76948", + "0x9951e512546cd9c9fbdab348b6cba91a601a29b50854e55a6e14f6803ca1d81ac7eff5ce", + "0xaaa7bacf26f1aa4754d42edeab45d6169ea723b7fdf0f6ff3b6ebe90d09dbff6bc553936", + "0xba75a143de4ac932986fbe7b1d78f639bc6ee8aee10d510d41572851530be884778052aa", + "0xea5315941f4337752905599710b55e64018c71f4d8f299d0636d50484d05e6ac5667b503" + ], + "payload": { + "type": 0, + "tag": "0x746167", + "data": "0x6c754128356c071e5549764a48427b" + }, + "maxBurnedMana": "864" + }, + "signature": { + "type": 0, + "publicKey": "0x2daefbcbadd044da470acd2f7fcf6fcb04b873cc801e7ee408018e1dfa0257ac", + "signature": "0xc2982c2476379db0c8d39a204801163fc05dc1c7aa7df537e6041f91491943ab1de29a2dfe6076588c53b8d2ccf5eabe49f2cb64198303682859fd0c58348b0d" + } + }, + "metadata": { + "blockId": "0x1d5f495c0f4b883cf2c79cafd382c73484c65651099329e3b0b4c969c35d620004000000", + "blockState": "confirmed" + } + } \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-full-output-metadata-example.json b/sdk/tests/types/api/fixtures/get-full-output-metadata-example.json new file mode 100644 index 0000000000..19da5991de --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-full-output-metadata-example.json @@ -0,0 +1,40 @@ +{ + "output": { + "type": 0, + "amount": "1000", + "unlockConditions": [ + { + "type": 0, + "address": { + "type": 0, + "pubKeyHash": "0x8eaf87ac1f52eb05f2c7c0c15502df990a228838dc37bd18de9503d69afd257d" + } + } + ], + "mana": "2000" + }, + "outputIdProof": { + "slot": 1893592032, + "outputIndex": 0, + "transactionCommitment": "0xa0687905318860e64db6932d8423bf7a4418627baee62be8089d5f48aaa1af3a", + "outputCommitmentProof": { + "type": 2, + "hash": "0x7f9289b104a55e6fb93d60d70f6e85c9706c761b05ccc034f76b465837ca6070" + } + }, + "metadata": { + "outputId": "0x3130f21c723fa597805763739f3a2a40b674af6b4071ef0494331b644a7e4d52000000001300", + "blockId": "0x19e589687082d8f535779df3244908ad6a7b380906fb7ae24efb5fad8a5cfb92a8f8d9a3", + "included": { + "slot": 5, + "transactionId": "0x3e766157614a3a0e13dbb937b5fb1ef5d1555479c19df80445d03a6710f39d75668bd326", + "commitmentId": "0x7387ebe23a3ac1732fcdb6cef77fc003e1fa6e2dad89dd664df249d6aa2dbdc157dec2c6" + }, + "spent": { + "slot": 8, + "transactionId": "0x3896f1ede7cbdacbbb4b17f13e953ad45ce0969ea34cc766b5dafe2a15b3e46f998ef4e5", + "commitmentId": "0x26fa9fcbddcf944ced3fd16a73d9c8b2b49dc54dba7629b02da69f7e01249063e7398b2c" + }, + "latestCommitmentId": "0x42a88617c2c4ba2b58f82c8b85524720cdbe3642401e7c613f215658d617c569d1219909" + } +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-info-response-example.json b/sdk/tests/types/api/fixtures/get-info-response-example.json new file mode 100644 index 0000000000..2c84f7cc7e --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-info-response-example.json @@ -0,0 +1,111 @@ +{ + "name": "test", + "version": "2.0.0", + "status": { + "isHealthy": false, + "acceptedTangleTime": "1690879505000000000", + "relativeAcceptedTangleTime": "1690879505000000000", + "confirmedTangleTime": "1690879505000000000", + "relativeConfirmedTangleTime": "1690879505000000000", + "latestCommitmentId": "0xf35c9c906190e9fb02b7969ea69567e5a4bbfdbcc389f93e2b5d0c105e03979aed5b248e", + "latestFinalizedSlot": 1, + "latestAcceptedBlockSlot": 2, + "latestConfirmedBlockSlot": 3, + "pruningEpoch": 4 + }, + "metrics": { + "blocksPerSecond": "1.1", + "confirmedBlocksPerSecond": "2.2", + "confirmationRate": "3.3" + }, + "protocolParameters": [ + { + "startEpoch": 0, + "parameters": { + "type": 0, + "version": 3, + "networkName": "TestJungle", + "bech32Hrp": "tgl", + "storageScoreParameters": { + "storageCost": "0", + "factorData": 0, + "offsetOutputOverhead": "0", + "offsetEd25519BlockIssuerKey": "0", + "offsetStakingFeature": "0", + "offsetDelegation": "0" + }, + "workScoreParameters": { + "dataByte": 0, + "block": 1, + "input": 0, + "contextInput": 0, + "output": 0, + "nativeToken": 0, + "staking": 0, + "blockIssuer": 0, + "allotment": 0, + "signatureEd25519": 0 + }, + "manaParameters": { + "bitsCount": 63, + "generationRate": 1, + "generationRateExponent": 17, + "decayFactors": [ + 10, + 20 + ], + "decayFactorsExponent": 32, + "decayFactorEpochsSum": 2420916375, + "decayFactorEpochsSumExponent": 21, + "annualDecayFactorPercentage": 50 + }, + "tokenSupply": "2779530283277761", + "genesisSlot": 0, + "genesisUnixTimestamp": "1695275822", + "slotDurationInSeconds": 10, + "slotsPerEpochExponent": 13, + "stakingUnbondingPeriod": 10, + "validationBlocksPerSlot": 10, + "punishmentEpochs": 10, + "livenessThresholdLowerBound": 15, + "livenessThresholdUpperBound": 30, + "minCommittableAge": 10, + "maxCommittableAge": 20, + "epochNearingThreshold": 24, + "congestionControlParameters": { + "minReferenceManaCost": "1", + "increase": "0", + "decrease": "0", + "increaseThreshold": 800000, + "decreaseThreshold": 500000, + "schedulerRate": 100000, + "maxBufferSize": 1000, + "maxValidationBufferSize": 100 + }, + "versionSignalingParameters": { + "windowSize": 7, + "windowTargetRatio": 5, + "activationOffset": 7 + }, + "rewardsParameters": { + "profitMarginExponent": 8, + "bootstrappingDuration": 1154, + "manaShareCoefficient": "2", + "decayBalancingConstantExponent": 8, + "decayBalancingConstant": "1", + "poolCoefficientExponent": 11, + "retentionPeriod": 684 + }, + "targetCommitteeSize": 32, + "chainSwitchingThreshold": 2 + } + } + ], + "baseToken": { + "name": "Shimmer", + "tickerSymbol": "SMR", + "unit": "SMR", + "subunit": "glow", + "decimals": 6 + } +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-mana-rewards-example.json b/sdk/tests/types/api/fixtures/get-mana-rewards-example.json new file mode 100644 index 0000000000..247fdd0744 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-mana-rewards-example.json @@ -0,0 +1,6 @@ +{ + "startEpoch": 60, + "endEpoch": 80, + "rewards": "800000", + "latestCommittedEpochPoolRewards": "0" +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-output-metadata-by-id-response-spent-example.json b/sdk/tests/types/api/fixtures/get-output-metadata-by-id-response-spent-example.json new file mode 100644 index 0000000000..963167465b --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-output-metadata-by-id-response-spent-example.json @@ -0,0 +1,15 @@ +{ + "outputId": "0x3130f21c723fa597805763739f3a2a40b674af6b4071ef0494331b644a7e4d52000000001300", + "blockId": "0x19e589687082d8f535779df3244908ad6a7b380906fb7ae24efb5fad8a5cfb92a8f8d9a3", + "included": { + "slot": 5, + "transactionId": "0x3e766157614a3a0e13dbb937b5fb1ef5d1555479c19df80445d03a6710f39d75668bd326", + "commitmentId": "0x7387ebe23a3ac1732fcdb6cef77fc003e1fa6e2dad89dd664df249d6aa2dbdc157dec2c6" + }, + "spent": { + "slot": 8, + "transactionId": "0x3896f1ede7cbdacbbb4b17f13e953ad45ce0969ea34cc766b5dafe2a15b3e46f998ef4e5", + "commitmentId": "0x26fa9fcbddcf944ced3fd16a73d9c8b2b49dc54dba7629b02da69f7e01249063e7398b2c" + }, + "latestCommitmentId": "0x42a88617c2c4ba2b58f82c8b85524720cdbe3642401e7c613f215658d617c569d1219909" +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-output-metadata-by-id-response-unspent-example.json b/sdk/tests/types/api/fixtures/get-output-metadata-by-id-response-unspent-example.json new file mode 100644 index 0000000000..def68cb4a8 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-output-metadata-by-id-response-unspent-example.json @@ -0,0 +1,10 @@ +{ + "outputId": "0x3477de28a45c565eed3603ab9e90ce0f0d38e8860a3c5ff64ccc70252aab7c9d000000004600", + "blockId": "0x1aaaa9ad9c15c6cd601a5aa5bd61b85428263978a26343949dad9ff89635e7104f1f271b", + "included": { + "slot": 5, + "transactionId": "0xfdd9e96bac5e4f029b3261c00cd3c74fb4c389184a2018c979d4f31fc1ef53c99add5c74", + "commitmentId": "0xd20959ac38938fddee472bbfd47644da3087a39499cd04e86c9c70fa9c8c0516a81b8aea" + }, + "latestCommitmentId": "0xba4456279dce23cfca37938685c039ea7c72001c1cd8becf72b195a8727cdfd07949d697" +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-outputs-by-id-response-example.json b/sdk/tests/types/api/fixtures/get-outputs-by-id-response-example.json new file mode 100644 index 0000000000..b5efeef2a3 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-outputs-by-id-response-example.json @@ -0,0 +1,46 @@ +{ + "output": { + "type": 0, + "amount": "1000", + "unlockConditions": [ + { + "type": 0, + "address": { + "type": 0, + "pubKeyHash": "0x8eaf87ac1f52eb05f2c7c0c15502df990a228838dc37bd18de9503d69afd257d" + } + } + ], + "mana": "2000" + }, + "outputIdProof": { + "slot": 429632486, + "outputIndex": 2, + "transactionCommitment": "0x46934d8c62df21e94553f6686a7f9368d9ab4159bcb96f598a94883a866467da", + "outputCommitmentProof": { + "type": 0, + "l": { + "type": 0, + "l": { + "type": 1, + "hash": "0x193a27f187c46a386f0e2a25a884351692b7378aae5e7dd78433f2be85106219" + }, + "r": { + "type": 0, + "l": { + "type": 2, + "hash": "0x19e4cdd6b17223a935883ddbb80ee6d239a48ea214c29b8b593cc7b3152d15aa" + }, + "r": { + "type": 1, + "hash": "0xf1faa521d1b1e85393efd63a6ed1f33bb851bfc90a681e011989d9c6056948cc" + } + } + }, + "r": { + "type": 1, + "hash": "0xe9cef2152da49d2a78a490bb7e42c6bcd1c96b41ebe156ba90a5b22cb78e3229" + } + } + } +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-routes-response-example.json b/sdk/tests/types/api/fixtures/get-routes-response-example.json new file mode 100644 index 0000000000..3d5b2bec66 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-routes-response-example.json @@ -0,0 +1,7 @@ +{ + "routes": [ + "core/v3", + "dashboard-metrics/v2", + "debug/v2" + ] +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-transaction-metadata-by-id-response-example.json b/sdk/tests/types/api/fixtures/get-transaction-metadata-by-id-response-example.json new file mode 100644 index 0000000000..5b119ccef8 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-transaction-metadata-by-id-response-example.json @@ -0,0 +1,4 @@ +{ + "transactionId": "0x72f0dfa9ad116ade8bdac8ef291ed2fb8065c6c75d5d3666e8b2053696c94a9e00001000", + "transactionState": "confirmed" + } \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-utxo-changes-full-response-example.json b/sdk/tests/types/api/fixtures/get-utxo-changes-full-response-example.json new file mode 100644 index 0000000000..ac2e61c3a5 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-utxo-changes-full-response-example.json @@ -0,0 +1,25 @@ +{ + "commitmentId":"0x7387ebe23a3ac1732fcdb6cef77fc003e1fa6e2dad89dd664df249d6aa2dbdc157dec2c6", + "createdOutputs":[ + { + "outputId":"0x3130f21c723fa597805763739f3a2a40b674af6b4071ef0494331b644a7e4d52000000001300", + "output":{ + "type":0, + "amount":"1000", + "unlockConditions":[ + { + "type":0, + "address":{ + "type":0, + "pubKeyHash":"0x8eaf87ac1f52eb05f2c7c0c15502df990a228838dc37bd18de9503d69afd257d" + } + } + ], + "mana":"2000" + } + } + ], + "consumedOutputs":[ + + ] +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-utxo-changes-response-example.json b/sdk/tests/types/api/fixtures/get-utxo-changes-response-example.json new file mode 100644 index 0000000000..d0d83cbec8 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-utxo-changes-response-example.json @@ -0,0 +1,11 @@ +{ + "commitmentId": "0x3b264c038283c30094e0cb5d22eaa52c9959bfda084ace3980b30d4be588fa0012000000", + "createdOutputs": [ + "0x2628fd7c1ad5dd635fa76c6f4c2272fbdb658cc3437dbed07f9984580b227b63f0a3e4d40000", + "0xfa3d71ea93849b317c2b29c928b726b6d3bd2131c7ad560c9e28952f117fd50c35d6e0890000" + ], + "consumedOutputs": [ + "0xfa3d71ea93849b317c2b29c928b726b6d3bd2131c7ad560c9e28952f117fd50c35d6e0890100", + "0x9c40a07de878863fbda03caeb68875254c49199e6b55740f78a4bab3686f89957b1249130000" + ] +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-validator-example.json b/sdk/tests/types/api/fixtures/get-validator-example.json new file mode 100644 index 0000000000..e8efd88e20 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-validator-example.json @@ -0,0 +1,10 @@ +{ + "address": "rms1pqm4xk8e9ny5w5rxjkvtp249tfhlwvcshyr3pc0665jvp7g3hc875k538hl", + "stakingEndEpoch": 100, + "poolStake": "205000", + "validatorStake": "90000", + "fixedCost": "52000", + "active": true, + "latestSupportedProtocolVersion": 3, + "latestSupportedProtocolHash": "0x0c00425134785bf2dbe42e4ec7e288009ebdc38ced797beaa45d5213092021cb" +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/get-validators-example.json b/sdk/tests/types/api/fixtures/get-validators-example.json new file mode 100644 index 0000000000..542562af81 --- /dev/null +++ b/sdk/tests/types/api/fixtures/get-validators-example.json @@ -0,0 +1,25 @@ +{ + "stakers": [ + { + "address": "rms1pp4wuuz0y42caz48vv876qfpmffswsvg40zz8v79sy8cp0jfxm4kunflcgt", + "stakingEndEpoch": 100, + "poolStake": "200000", + "validatorStake": "100000", + "fixedCost": "50000", + "active": false, + "latestSupportedProtocolVersion": 3, + "latestSupportedProtocolHash": "0x0c00425134785bf2dbe42e4ec7e288009ebdc38ced797beaa45d5213092021cb" + }, + { + "address": "rms1pqm4xk8e9ny5w5rxjkvtp249tfhlwvcshyr3pc0665jvp7g3hc875k538hl", + "stakingEndEpoch": 10, + "poolStake": "205000", + "validatorStake": "90000", + "fixedCost": "52000", + "active": true, + "latestSupportedProtocolVersion": 3, + "latestSupportedProtocolHash": "0x0c00425134785bf2dbe42e4ec7e288009ebdc38ced797beaa45d5213092021cb" + } + ], + "pageSize": 50 +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/post-blocks-response-example.json b/sdk/tests/types/api/fixtures/post-blocks-response-example.json new file mode 100644 index 0000000000..702c1874c0 --- /dev/null +++ b/sdk/tests/types/api/fixtures/post-blocks-response-example.json @@ -0,0 +1,3 @@ +{ + "blockId":"0x0482f0eba39a23c9a13072c93d828b55543132c47f5f57514d9e55535e9d4f4f35000000" +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/tagged-data-block-example.json b/sdk/tests/types/api/fixtures/tagged-data-block-example.json new file mode 100644 index 0000000000..781a561e20 --- /dev/null +++ b/sdk/tests/types/api/fixtures/tagged-data-block-example.json @@ -0,0 +1,32 @@ +{ + "header": { + "protocolVersion": 3, + "networkId": "8342982141227064571", + "issuingTime": "1695275852000000000", + "slotCommitmentId": "0x3a1e3b617060146e0362361a4b752833186108395f3b2b3d3e6c655e287d70767ea58d2a", + "latestFinalizedSlot": 500, + "issuerId": "0x17432c5a7a672503480241125e3952414a7a320441080c624c264b004e09614a" + }, + "body": { + "type": 0, + "strongParents": [ + "0x27e0461873f37040c9e59c35ad8a106fa1b94f5ec9ef89499b31904f9a3de59be58dd44a", + "0x714821f8f257e0a502b71ac7ee57530bb9dc29fe12ff3936f925b835a297680400b76948", + "0x9951e512546cd9c9fbdab348b6cba91a601a29b50854e55a6e14f6803ca1d81ac7eff5ce", + "0xaaa7bacf26f1aa4754d42edeab45d6169ea723b7fdf0f6ff3b6ebe90d09dbff6bc553936", + "0xba75a143de4ac932986fbe7b1d78f639bc6ee8aee10d510d41572851530be884778052aa", + "0xea5315941f4337752905599710b55e64018c71f4d8f299d0636d50484d05e6ac5667b503" + ], + "payload": { + "type": 0, + "tag": "0x746167", + "data": "0x6c754128356c071e5549764a48427b" + }, + "maxBurnedMana": "864" + }, + "signature": { + "type": 0, + "publicKey": "0x2daefbcbadd044da470acd2f7fcf6fcb04b873cc801e7ee408018e1dfa0257ac", + "signature": "0xc2982c2476379db0c8d39a204801163fc05dc1c7aa7df537e6041f91491943ab1de29a2dfe6076588c53b8d2ccf5eabe49f2cb64198303682859fd0c58348b0d" + } +} \ No newline at end of file diff --git a/sdk/tests/types/api/fixtures/transaction-block-example.json b/sdk/tests/types/api/fixtures/transaction-block-example.json new file mode 100644 index 0000000000..dfa7cdd10f --- /dev/null +++ b/sdk/tests/types/api/fixtures/transaction-block-example.json @@ -0,0 +1,153 @@ +{ + "header":{ + "protocolVersion":3, + "networkId":"8342982141227064571", + "issuingTime":"1695275942000000000", + "slotCommitmentId":"0x3a1e3b617060146e0362361a4b752833186108395f3b2b3d3e6c655e287d707601000000", + "latestFinalizedSlot":0, + "issuerId":"0x17432c5a7a672503480241125e3952414a7a320441080c624c264b004e09614a" + }, + "body":{ + "type":0, + "strongParents":[ + "0x27e0461873f37040c9e59c35ad8a106fa1b94f5ec9ef89499b31904f9a3de59be58dd44a", + "0x714821f8f257e0a502b71ac7ee57530bb9dc29fe12ff3936f925b835a297680400b76948", + "0x9951e512546cd9c9fbdab348b6cba91a601a29b50854e55a6e14f6803ca1d81ac7eff5ce", + "0xaaa7bacf26f1aa4754d42edeab45d6169ea723b7fdf0f6ff3b6ebe90d09dbff6bc553936", + "0xba75a143de4ac932986fbe7b1d78f639bc6ee8aee10d510d41572851530be884778052aa", + "0xea5315941f4337752905599710b55e64018c71f4d8f299d0636d50484d05e6ac5667b503" + ], + "payload":{ + "type":1, + "transaction":{ + "networkId":"8342982141227064571", + "creationSlot":11, + "contextInputs":[ + { + "type":0, + "commitmentId":"0x3a1e3b617060146e0362361a4b752833186108395f3b2b3d3e6c655e287d707601000000" + }, + { + "type":1, + "accountId":"0x17432c5a7a672503480241125e3952414a7a320441080c624c264b004e09614a" + }, + { + "type":2, + "index":0 + } + ], + "inputs":[ + { + "type":0, + "transactionId":"0xf09d3cd648a7246c7c1b2ba2f9182465ae5742b78c592392b4b455ab8ed7195200000000", + "transactionOutputIndex":0 + }, + { + "type":0, + "transactionId":"0xd2c5ccba12b6fad51652131289867492799c9fc5710244418aa6e955f8fa826100000000", + "transactionOutputIndex":0 + } + ], + "allotments":[ + { + "accountId":"0x476820096e7038107d071a4e473f1e295f346e2d0824263e5e3e7d004f6b6915", + "mana":"2189" + }, + { + "accountId":"0x7e0d0a5848362b23120f55115b096774036d7610137a631413221f5573344507", + "mana":"2285" + } + ], + "capabilities":"0x01", + "outputs":[ + { + "type":0, + "amount":"100000", + "mana":"0", + "unlockConditions":[ + { + "type":0, + "address":{ + "type":0, + "pubKeyHash":"0xed1484f4d1f7d8c037087fed661dd92faccae1eed3c01182d6fdd6828cea144a" + } + } + ], + "features":[ + { + "type":5, + "id":"0x086372557616532f714f104e5f44297b7a286d077956291a6d4f59081f484463712a64300c00", + "amount":"0x14be8149371263f4" + } + ] + }, + { + "type":1, + "amount":"100000", + "mana":"5000", + "accountId":"0x0000000000000000000000000000000000000000000000000000000000000000", + "foundryCounter":0, + "unlockConditions":[ + { + "type":0, + "address":{ + "type":0, + "pubKeyHash":"0xed1484f4d1f7d8c037087fed661dd92faccae1eed3c01182d6fdd6828cea144a" + } + } + ], + "features":[ + { + "type":2, + "entries":{ + "hello":"0x776f726c64" + } + }, + { + "type":6, + "expirySlot":4294967295, + "blockIssuerKeys":[ + { + "type":0, + "publicKey":"0x9e05a32eafedefd40298e24ad4f8c334580187f7e9afbd9da13b5ba4007dd1b5" + }, + { + "type":0, + "publicKey":"0xa504844f7a0df2c5101d31696593b309040f8660d41035aba508f24c00668b21" + } + ] + }, + { + "type":7, + "stakedAmount":"10000", + "fixedCost":"400", + "startEpoch":0, + "endEpoch":4294967295 + } + ] + } + ] + }, + "unlocks":[ + { + "type":0, + "signature":{ + "type":0, + "publicKey":"0x2daefbcbadd044da470acd2f7fcf6fcb04b873cc801e7ee408018e1dfa0257ac", + "signature":"0x9178a608cc0c6c703a41f5bad71e9e80bf9e580f26587df36379d12416c65a85974fafcd22b14d4a7853cc3d15b414e8bf37003dc77725d1d2c9b40d42a13501" + } + }, + { + "type":1, + "reference":0 + } + ] + }, + "maxBurnedMana":"864" + }, + "signature":{ + "type":0, + "publicKey":"0x2daefbcbadd044da470acd2f7fcf6fcb04b873cc801e7ee408018e1dfa0257ac", + "signature":"0x14718f345117d3f29d8e917ca4f8f758159914f45ef5c0d2cfd46c375edcab125ab4c08c59eb8b6d8e8ef2b7a4de92805bae45612277048bdb101ceed96b880c" + } +} \ No newline at end of file diff --git a/sdk/tests/types/api/mod.rs b/sdk/tests/types/api/mod.rs index 33ac8943a3..ddbc2094b8 100644 --- a/sdk/tests/types/api/mod.rs +++ b/sdk/tests/types/api/mod.rs @@ -1,4 +1,5 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +mod core; mod participation;