diff --git a/bindings/python/iota_sdk/types/output_id_proof.py b/bindings/python/iota_sdk/types/output_id_proof.py index ceaca65834..d4ee905f56 100644 --- a/bindings/python/iota_sdk/types/output_id_proof.py +++ b/bindings/python/iota_sdk/types/output_id_proof.py @@ -15,7 +15,7 @@ class OutputCommitmentProofType(IntEnum): Attributes: HashableNode (0): Denotes a HashableNode. LeafHash (1): Denotes a LeafHash. - Valuehash (2): Denotes a Valuehash. + ValueHash (2): Denotes a ValueHash. """ HashableNode = 0 LeafHash = 1 @@ -88,7 +88,9 @@ class OutputIdProof: slot: SlotIndex output_index: int transaction_commitment: HexStr - output_commitment_proof: OutputCommitmentProof + output_commitment_proof: OutputCommitmentProof = field(metadata=config( + decoder=deserialize_proof + )) OutputCommitmentProof: TypeAlias = Union[HashableNode, LeafHash, ValueHash] diff --git a/bindings/python/tests/test_api_responses.py b/bindings/python/tests/test_api_responses.py index 8860685aa9..2fc3a21c02 100644 --- a/bindings/python/tests/test_api_responses.py +++ b/bindings/python/tests/test_api_responses.py @@ -3,7 +3,7 @@ from typing import Generic, TypeVar from json import load, loads, dumps -from iota_sdk import RoutesResponse, CongestionResponse, ManaRewardsResponse, ValidatorResponse, CommitteeResponse, IssuanceBlockHeaderResponse, Block, BlockMetadataResponse, BlockWithMetadataResponse, OutputMetadata, OutputResponse, TransactionMetadataResponse, SlotCommitment, UtxoChangesResponse, UtxoChangesFullResponse +from iota_sdk import RoutesResponse, CongestionResponse, OutputWithMetadataResponse, ManaRewardsResponse, ValidatorsResponse, ValidatorResponse, InfoResponse, CommitteeResponse, IssuanceBlockHeaderResponse, Block, BlockMetadataResponse, BlockWithMetadataResponse, OutputMetadata, OutputResponse, TransactionMetadataResponse, SlotCommitment, UtxoChangesResponse, UtxoChangesFullResponse base_path = '../../sdk/tests/types/api/fixtures/' @@ -27,16 +27,14 @@ def test_api_response(cls_type: Generic[T], path: str): # GET /api/routes test_api_response(RoutesResponse, "get-routes-response-example.json") # GET /api/core/v3/info - # TODO: enable when the fixture is updated https://github.com/iotaledger/iota-sdk/issues/2015 - # test_api_response(InfoResponse, "get-info-response-example.json") + test_api_response(InfoResponse, "get-info-response-example.json") # GET /api/core/v3/accounts/{bech32Address}/congestion test_api_response(CongestionResponse, "get-congestion-estimate-response-example.json") # GET /api/core/v3/rewards/{outputId} test_api_response(ManaRewardsResponse, "get-mana-rewards-example.json") # GET /api/core/v3/validators - # TODO: enable when TIP is updated - # test_api_response(ValidatorsResponse, "get-validators-example.json") + test_api_response(ValidatorsResponse, "get-validators-example.json") # GET /api/core/v3/validators/{bech32Address} test_api_response(ValidatorResponse, "get-validator-example.json") # GET /api/core/v3/committee @@ -73,9 +71,8 @@ def test_api_response(cls_type: Generic[T], path: str): test_api_response( OutputMetadata, "get-output-metadata-by-id-response-spent-example.json") # GET /api/core/v3/outputs/{outputId}/full - # TODO: enable when OutputWithMetadata is updated with OutputIdProof https://github.com/iotaledger/iota-sdk/issues/2021 - # test_api_response(OutputWithMetadata, - # "get-full-output-metadata-example.json") + test_api_response(OutputWithMetadataResponse, + "get-full-output-metadata-example.json") # GET /api/core/v3/transactions/{transactionId}/metadata test_api_response(TransactionMetadataResponse, "get-transaction-metadata-by-id-response-example.json") diff --git a/sdk/src/types/block/core/block.rs b/sdk/src/types/block/core/block.rs index 0cf0502033..ef0b02acfe 100644 --- a/sdk/src/types/block/core/block.rs +++ b/sdk/src/types/block/core/block.rs @@ -305,7 +305,7 @@ impl Packable for Block { }; if block_len > Self::LENGTH_MAX { - return Err(UnpackError::Packable(BlockError::InvalidBlockLength(block_len).into())); + return Err(UnpackError::Packable(BlockError::InvalidBlockLength(block_len))); } } diff --git a/sdk/src/types/block/output/delegation.rs b/sdk/src/types/block/output/delegation.rs index d32696c99d..0312fdd928 100644 --- a/sdk/src/types/block/output/delegation.rs +++ b/sdk/src/types/block/output/delegation.rs @@ -255,7 +255,7 @@ pub struct DelegationOutput { delegation_id: DelegationId, /// Account address of the validator to which this output is delegating. #[packable(verify_with = verify_validator_address_packable)] - #[packable(unpack_error_with = |err| OutputError::ValidatorAddress(err))] + #[packable(unpack_error_with = OutputError::ValidatorAddress)] validator_address: Address, /// Index of the first epoch for which this output delegates. start_epoch: EpochIndex, diff --git a/sdk/src/wallet/operations/syncing/foundries.rs b/sdk/src/wallet/operations/syncing/foundries.rs index ce72321869..db05db09b8 100644 --- a/sdk/src/wallet/operations/syncing/foundries.rs +++ b/sdk/src/wallet/operations/syncing/foundries.rs @@ -30,7 +30,7 @@ where match client.foundry_output_id(foundry_id).await { Ok(output_id) => Ok(Some(client.get_output(&output_id).await?)), Err(crate::client::Error::NoOutput(_)) => Ok(None), - Err(e) => Err(crate::wallet::Error::Client(e.into())), + Err(e) => Err(crate::wallet::Error::Client(e)), } }) .await? diff --git a/sdk/src/wallet/operations/syncing/outputs.rs b/sdk/src/wallet/operations/syncing/outputs.rs index 37b9e9ceb5..b7e1e89af7 100644 --- a/sdk/src/wallet/operations/syncing/outputs.rs +++ b/sdk/src/wallet/operations/syncing/outputs.rs @@ -167,7 +167,7 @@ where Err(crate::client::Error::Node(crate::client::node_api::error::Error::NotFound(_))) => { Ok((transaction_id, None)) } - Err(e) => Err(crate::wallet::Error::Client(e.into())), + Err(e) => Err(crate::wallet::Error::Client(e)), } })) .await diff --git a/sdk/tests/client/mod.rs b/sdk/tests/client/mod.rs index ee47dc0575..87346a8f3a 100644 --- a/sdk/tests/client/mod.rs +++ b/sdk/tests/client/mod.rs @@ -39,7 +39,6 @@ use iota_sdk::{ slot::{SlotCommitmentHash, SlotCommitmentId, SlotIndex}, }, }; -use pretty_assertions::assert_ne; const ACCOUNT_ID_0: &str = "0x0000000000000000000000000000000000000000000000000000000000000000"; const ACCOUNT_ID_1: &str = "0x1111111111111111111111111111111111111111111111111111111111111111"; @@ -56,7 +55,7 @@ const BECH32_ADDRESS_ED25519_0: &str = "rms1qr2xsmt3v3eyp2ja80wd2sq8xx0fslefmxgu const BECH32_ADDRESS_ED25519_1: &str = "rms1qqhvvur9xfj6yhgsxfa4f8xst7vz9zxeu3vcxds8mh4a6jlpteq9xrajhtf"; const BECH32_ADDRESS_ED25519_2: &str = "rms1qr47gz3xxjqpjrwd0yu5glhqrth6w0t08npney8000ust2lcw2r92j5a8rt"; const BECH32_ADDRESS_ACCOUNT_1: &str = "rms1pqg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zws5524"; // Corresponds to ACCOUNT_ID_1 -const BECH32_ADDRESS_ACCOUNT_2: &str = "rms1pq3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zymxrh9z"; // Corresponds to ACCOUNT_ID_2 +const _BECH32_ADDRESS_ACCOUNT_2: &str = "rms1pq3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zymxrh9z"; // Corresponds to ACCOUNT_ID_2 const BECH32_ADDRESS_NFT_1: &str = "rms1zqg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zxddmy7"; // Corresponds to NFT_ID_1 const _BECH32_ADDRESS_NFT_2: &str = "rms1zq3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zynm6ctf"; // Corresponds to NFT_ID_2 const SLOT_INDEX: SlotIndex = SlotIndex(10); diff --git a/sdk/tests/types/api/core.rs b/sdk/tests/types/api/core.rs index 42db3dff49..8b55420336 100644 --- a/sdk/tests/types/api/core.rs +++ b/sdk/tests/types/api/core.rs @@ -52,14 +52,13 @@ 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(); + 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 - // TODO reenable when TIP is updated - // json_response::("get-validators-example.json").unwrap(); + 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 diff --git a/sdk/tests/types/api/fixtures/get-info-response-example.json b/sdk/tests/types/api/fixtures/get-info-response-example.json index 2c84f7cc7e..683af6d394 100644 --- a/sdk/tests/types/api/fixtures/get-info-response-example.json +++ b/sdk/tests/types/api/fixtures/get-info-response-example.json @@ -24,27 +24,27 @@ "parameters": { "type": 0, "version": 3, - "networkName": "TestJungle", - "bech32Hrp": "tgl", + "networkName": "testnet", + "bech32Hrp": "rms", "storageScoreParameters": { - "storageCost": "0", - "factorData": 0, - "offsetOutputOverhead": "0", - "offsetEd25519BlockIssuerKey": "0", - "offsetStakingFeature": "0", - "offsetDelegation": "0" + "storageCost": "100", + "factorData": 1, + "offsetOutputOverhead": "10", + "offsetEd25519BlockIssuerKey": "100", + "offsetStakingFeature": "100", + "offsetDelegation": "100" }, "workScoreParameters": { - "dataByte": 0, - "block": 1, - "input": 0, - "contextInput": 0, - "output": 0, - "nativeToken": 0, - "staking": 0, - "blockIssuer": 0, - "allotment": 0, - "signatureEd25519": 0 + "dataByte": 1, + "block": 2, + "input": 3, + "contextInput": 4, + "output": 5, + "nativeToken": 6, + "staking": 7, + "blockIssuer": 8, + "allotment": 9, + "signatureEd25519": 10 }, "manaParameters": { "bitsCount": 63, @@ -55,11 +55,11 @@ 20 ], "decayFactorsExponent": 32, - "decayFactorEpochsSum": 2420916375, + "decayFactorEpochsSum": 2262417561, "decayFactorEpochsSumExponent": 21, - "annualDecayFactorPercentage": 50 + "annualDecayFactorPercentage": 70 }, - "tokenSupply": "2779530283277761", + "tokenSupply": "1813620509061365", "genesisSlot": 0, "genesisUnixTimestamp": "1695275822", "slotDurationInSeconds": 10, @@ -71,7 +71,7 @@ "livenessThresholdUpperBound": 30, "minCommittableAge": 10, "maxCommittableAge": 20, - "epochNearingThreshold": 24, + "epochNearingThreshold": 60, "congestionControlParameters": { "minReferenceManaCost": "1", "increase": "0", @@ -89,15 +89,15 @@ }, "rewardsParameters": { "profitMarginExponent": 8, - "bootstrappingDuration": 1154, - "manaShareCoefficient": "2", - "decayBalancingConstantExponent": 8, - "decayBalancingConstant": "1", + "bootstrappingDuration": 1079, + "rewardToGenerationRatio": 5, + "initialTargetRewardsRate": "10", + "finalTargetRewardsRate": "20", "poolCoefficientExponent": 11, - "retentionPeriod": 684 + "retentionPeriod": 384 }, "targetCommitteeSize": 32, - "chainSwitchingThreshold": 2 + "chainSwitchingThreshold": 3 } } ], diff --git a/sdk/tests/types/api/fixtures/get-validators-example.json b/sdk/tests/types/api/fixtures/get-validators-example.json index 542562af81..c1d8dca89e 100644 --- a/sdk/tests/types/api/fixtures/get-validators-example.json +++ b/sdk/tests/types/api/fixtures/get-validators-example.json @@ -1,5 +1,5 @@ { - "stakers": [ + "validators": [ { "address": "rms1pp4wuuz0y42caz48vv876qfpmffswsvg40zz8v79sy8cp0jfxm4kunflcgt", "stakingEndEpoch": 100, diff --git a/sdk/tests/types/block_id.rs b/sdk/tests/types/block_id.rs index 8d497e428b..13d53c95c4 100644 --- a/sdk/tests/types/block_id.rs +++ b/sdk/tests/types/block_id.rs @@ -77,53 +77,53 @@ fn protocol_parameters() -> ProtocolParameters { serde_json::from_value::(params_json.clone()).unwrap() } -// #[test] -// fn basic_block_tagged_data_payload_id() { -// // Test vector from https://github.com/iotaledger/tips/blob/tip46/tips/TIP-0046/tip-0046.md#basic-block-id-tagged-data-payload -// let protocol_parameters = protocol_parameters(); -// let file = std::fs::read_to_string("./tests/types/fixtures/basic_block_tagged_data_payload.json").unwrap(); -// let json = serde_json::from_str::(&file).unwrap(); -// let block_json = &json["block"]; -// let block_dto = serde_json::from_value::(block_json.clone()).unwrap(); -// let block = Block::try_from_dto(block_dto).unwrap(); -// let block_bytes = block.pack_to_vec(); -// let block_work_score = block.as_basic().work_score(protocol_parameters.work_score_parameters()); - -// assert_eq!(prefix_hex::encode(&block_bytes), json["bytes"]); -// assert_eq!(block, Block::unpack_unverified(block_bytes).unwrap()); -// assert_eq!(block.id(&protocol_parameters).to_string(), json["id"]); -// assert_eq!(block_work_score, json["workScore"]); -// } - -// #[test] -// fn basic_block_transaction_payload_id() { -// // Test vector from https://github.com/iotaledger/tips/blob/tip46/tips/TIP-0046/tip-0046.md#basic-block-id-transaction-payload -// let protocol_parameters = protocol_parameters(); -// let file = std::fs::read_to_string("./tests/types/fixtures/basic_block_transaction_payload.json").unwrap(); -// let json = serde_json::from_str::(&file).unwrap(); -// let block_json = &json["block"]; -// let block_dto = serde_json::from_value::(block_json.clone()).unwrap(); -// let block = Block::try_from_dto(block_dto).unwrap(); -// let block_bytes = block.pack_to_vec(); -// let block_work_score = block.as_basic().work_score(protocol_parameters.work_score_parameters()); - -// assert_eq!(prefix_hex::encode(&block_bytes), json["bytes"]); -// assert_eq!(block, Block::unpack_unverified(block_bytes).unwrap()); -// assert_eq!(block.id(&protocol_parameters).to_string(), json["id"]); -// assert_eq!(block_work_score, json["workScore"]); -// } - -// #[test] -// fn validation_block_id() { -// // Test vector from https://github.com/iotaledger/tips/blob/tip46/tips/TIP-0046/tip-0046.md#validation-block-id -// let file = std::fs::read_to_string("./tests/types/fixtures/validation_block.json").unwrap(); -// let json = serde_json::from_str::(&file).unwrap(); -// let block_json = &json["block"]; -// let block_dto = serde_json::from_value::(block_json.clone()).unwrap(); -// let block = Block::try_from_dto(block_dto).unwrap(); -// let block_bytes = block.pack_to_vec(); - -// assert_eq!(prefix_hex::encode(&block_bytes), json["bytes"]); -// assert_eq!(block, Block::unpack_unverified(block_bytes).unwrap()); -// assert_eq!(block.id(&protocol_parameters()).to_string(), json["id"]); -// } +#[test] +fn basic_block_tagged_data_payload_id() { + // Test vector from https://github.com/iotaledger/tips/blob/tip46/tips/TIP-0046/tip-0046.md#basic-block-id-tagged-data-payload + let protocol_parameters = protocol_parameters(); + let file = std::fs::read_to_string("./tests/types/fixtures/basic_block_tagged_data_payload.json").unwrap(); + let json = serde_json::from_str::(&file).unwrap(); + let block_json = &json["block"]; + let block_dto = serde_json::from_value::(block_json.clone()).unwrap(); + let block = Block::try_from_dto(block_dto).unwrap(); + let block_bytes = block.pack_to_vec(); + let block_work_score = block.as_basic().work_score(protocol_parameters.work_score_parameters()); + + assert_eq!(prefix_hex::encode(&block_bytes), json["bytes"]); + assert_eq!(block, Block::unpack_bytes_unverified(block_bytes).unwrap()); + assert_eq!(block.id(&protocol_parameters).to_string(), json["id"]); + assert_eq!(block_work_score, json["workScore"]); +} + +#[test] +fn basic_block_transaction_payload_id() { + // Test vector from https://github.com/iotaledger/tips/blob/tip46/tips/TIP-0046/tip-0046.md#basic-block-id-transaction-payload + let protocol_parameters = protocol_parameters(); + let file = std::fs::read_to_string("./tests/types/fixtures/basic_block_transaction_payload.json").unwrap(); + let json = serde_json::from_str::(&file).unwrap(); + let block_json = &json["block"]; + let block_dto = serde_json::from_value::(block_json.clone()).unwrap(); + let block = Block::try_from_dto(block_dto).unwrap(); + let block_bytes = block.pack_to_vec(); + let block_work_score = block.as_basic().work_score(protocol_parameters.work_score_parameters()); + + assert_eq!(prefix_hex::encode(&block_bytes), json["bytes"]); + assert_eq!(block, Block::unpack_bytes_unverified(block_bytes).unwrap()); + assert_eq!(block.id(&protocol_parameters).to_string(), json["id"]); + assert_eq!(block_work_score, json["workScore"]); +} + +#[test] +fn validation_block_id() { + // Test vector from https://github.com/iotaledger/tips/blob/tip46/tips/TIP-0046/tip-0046.md#validation-block-id + let file = std::fs::read_to_string("./tests/types/fixtures/validation_block.json").unwrap(); + let json = serde_json::from_str::(&file).unwrap(); + let block_json = &json["block"]; + let block_dto = serde_json::from_value::(block_json.clone()).unwrap(); + let block = Block::try_from_dto(block_dto).unwrap(); + let block_bytes = block.pack_to_vec(); + + assert_eq!(prefix_hex::encode(&block_bytes), json["bytes"]); + assert_eq!(block, Block::unpack_bytes_unverified(block_bytes).unwrap()); + assert_eq!(block.id(&protocol_parameters()).to_string(), json["id"]); +}