diff --git a/bindings/nodejs/tests/client/infoMethods.spec.ts b/bindings/nodejs/tests/client/infoMethods.spec.ts index e106076481..395e43af5d 100644 --- a/bindings/nodejs/tests/client/infoMethods.spec.ts +++ b/bindings/nodejs/tests/client/infoMethods.spec.ts @@ -82,15 +82,14 @@ describe.skip('Client info methods', () => { }); }); -// TODO: enable after ProtocolParameters fixture is updated https://github.com/iotaledger/iota-sdk/issues/2040 -// describe('Offline client info methods', () => { - // it('provided protocol parameters', async () => { - // const protocolParameters = protocolParametersFixture.params; - // const client = await Client.create({ - // protocolParameters - // }); - // const networkInfo = await client.getNetworkInfo(); - - // expect(networkInfo.protocolParameters).toStrictEqual(protocolParameters); - // }); -// }) +describe('Offline client info methods', () => { + it('provided protocol parameters', async () => { + const protocolParameters = protocolParametersFixture.params; + const client = await Client.create({ + protocolParameters + }); + const networkInfo = await client.getNetworkInfo(); + + expect(networkInfo.protocolParameters).toStrictEqual(protocolParameters); + }); +}) diff --git a/bindings/python/tests/test_protocol_parameters.py b/bindings/python/tests/test_protocol_parameters.py index b18e6f2e67..2450b86cf5 100644 --- a/bindings/python/tests/test_protocol_parameters.py +++ b/bindings/python/tests/test_protocol_parameters.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 import json -# from iota_sdk import ProtocolParameters, Utils +from iota_sdk import ProtocolParameters, Utils protocol_params_json = {} @@ -10,10 +10,10 @@ protocol_params_json = json.load(json_file) -# def test_protocol_parameters(): -# protocol_params_dict = protocol_params_json['params'] -# protocol_params = ProtocolParameters.from_dict(protocol_params_dict) -# assert protocol_params.to_dict() == protocol_params_dict +def test_protocol_parameters(): + protocol_params_dict = protocol_params_json['params'] + protocol_params = ProtocolParameters.from_dict(protocol_params_dict) + assert protocol_params.to_dict() == protocol_params_dict -# expected_hash = protocol_params_json['hash'] -# assert Utils.protocol_parameters_hash(protocol_params) == expected_hash + expected_hash = protocol_params_json['hash'] + assert Utils.protocol_parameters_hash(protocol_params) == expected_hash diff --git a/sdk/tests/types/fixtures/protocol_parameters.json b/sdk/tests/types/fixtures/protocol_parameters.json index bbbf63a0c7..35e57b20bd 100644 --- a/sdk/tests/types/fixtures/protocol_parameters.json +++ b/sdk/tests/types/fixtures/protocol_parameters.json @@ -1,144 +1,464 @@ { - "params": { - "type": 0, - "version": 3, - "networkName": "testnet", - "bech32Hrp": "rms", - "storageScoreParameters": { - "storageCost": "100", - "factorData": 1, - "offsetOutputOverhead": "10", - "offsetEd25519BlockIssuerKey": "100", - "offsetStakingFeature": "100", - "offsetDelegation": "100" - }, - "workScoreParameters": { - "dataByte": 1, - "block": 2, - "input": 3, - "contextInput": 4, - "output": 5, - "nativeToken": 6, - "staking": 7, - "blockIssuer": 8, - "allotment": 9, - "signatureEd25519": 10 - }, - "manaParameters": { - "bitsCount": 63, - "generationRate": 1, - "generationRateExponent": 17, - "decayFactors": [ - 4290989755, 4287015898, 4283045721, 4279079221, 4275116394, 4271157237, - 4267201747, 4263249920, 4259301752, 4255357241, 4251416383, 4247479175, - 4243545613, 4239615693, 4235689414, 4231766770, 4227847759, 4223932377, - 4220020622, 4216112489, 4212207975, 4208307077, 4204409792, 4200516116, - 4196626046, 4192739579, 4188856710, 4184977438, 4181101758, 4177229668, - 4173361163, 4169496241, 4165634898, 4161777132, 4157922938, 4154072313, - 4150225254, 4146381758, 4142541822, 4138705441, 4134872614, 4131043336, - 4127217604, 4123395415, 4119576766, 4115761654, 4111950074, 4108142024, - 4104337501, 4100536502, 4096739022, 4092945060, 4089154610, 4085367672, - 4081584240, 4077804312, 4074027884, 4070254954, 4066485518, 4062719573, - 4058957115, 4055198142, 4051442650, 4047690636, 4043942097, 4040197029, - 4036455429, 4032717295, 4028982622, 4025251408, 4021523650, 4017799344, - 4014078486, 4010361075, 4006647106, 4002936577, 3999229484, 3995525824, - 3991825594, 3988128791, 3984435412, 3980745453, 3977058911, 3973375783, - 3969696066, 3966019757, 3962346853, 3958677350, 3955011245, 3951348535, - 3947689218, 3944033289, 3940380746, 3936731586, 3933085805, 3929443400, - 3925804369, 3922168708, 3918536413, 3914907483, 3911281913, 3907659701, - 3904040843, 3900425337, 3896813179, 3893204366, 3889598896, 3885996764, - 3882397968, 3878802505, 3875210372, 3871621566, 3868036083, 3864453920, - 3860875075, 3857299544, 3853727325, 3850158414, 3846592808, 3843030504, - 3839471499, 3835915790, 3832363374, 3828814248, 3825268408, 3821725853, - 3818186578, 3814650580, 3811117858, 3807588407, 3804062225, 3800539308, - 3797019654, 3793503259, 3789990121, 3786480237, 3782973602, 3779470216, - 3775970074, 3772473173, 3768979511, 3765489084, 3762001889, 3758517924, - 3755037186, 3751559671, 3748085377, 3744614300, 3741146437, 3737681787, - 3734220344, 3730762108, 3727307074, 3723855240, 3720406602, 3716961158, - 3713518905, 3710079840, 3706643960, 3703211262, 3699781742, 3696355399, - 3692932229, 3689512229, 3686095396, 3682681728, 3679271221, 3675863872, - 3672459679, 3669058639, 3665660748, 3662266004, 3658874404, 3655485944, - 3652100623, 3648718437, 3645339383, 3641963459, 3638590661, 3635220986, - 3631854432, 3628490996, 3625130675, 3621773465, 3618419365, 3615068371, - 3611720480, 3608375690, 3605033997, 3601695399, 3598359893, 3595027476, - 3591698145, 3588371897, 3585048730, 3581728640, 3578411625, 3575097682, - 3571786808, 3568479000, 3565174255, 3561872571, 3558573944, 3555278373, - 3551985853, 3548696383, 3545409959, 3542126578, 3538846238, 3535568936, - 3532294669, 3529023435, 3525755230, 3522490051, 3519227897, 3515968763, - 3512712648, 3509459548, 3506209461, 3502962384, 3499718314, 3496477248, - 3493239183, 3490004118, 3486772048, 3483542972, 3480316886, 3477093788, - 3473873674, 3470656543, 3467442391, 3464231216, 3461023014, 3457817784, - 3454615522, 3451416225, 3448219892, 3445026518, 3441836102, 3438648641, - 3435464131, 3432282571, 3429103957, 3425928286, 3422755557, 3419585766, - 3416418910, 3413254987, 3410093995, 3406935929, 3403780789, 3400628570, - 3397479270, 3394332887, 3391189418, 3388048860, 3384911211, 3381776467, - 3378644627, 3375515686, 3372389644, 3369266496, 3366146241, 3363028875, - 3359914396, 3356802802, 3353694089, 3350588256, 3347485298, 3344385214, - 3341288001, 3338193657, 3335102178, 3332013562, 3328927806, 3325844909, - 3322764866, 3319687675, 3316613335, 3313541841, 3310473192, 3307407385, - 3304344417, 3301284286, 3298226988, 3295172522, 3292120885, 3289072074, - 3286026086, 3282982919, 3279942570, 3276905037, 3273870317, 3270838408, - 3267809306, 3264783010, 3261759516, 3258738822, 3255720926, 3252705824, - 3249693515, 3246683996, 3243677263, 3240673315, 3237672149, 3234673763, - 3231678153, 3228685317, 3225695253, 3222707958, 3219723430, 3216741666, - 3213762662, 3210786418, 3207812930, 3204842196, 3201874213, 3198908979, - 3195946490, 3192986746, 3190029742, 3187075477, 3184123947, 3181175151, - 3178229086, 3175285749, 3172345138, 3169407251, 3166472084, 3163539635, - 3160609902, 3157682882, 3154758573, 3151836972, 3148918077, 3146001885, - 3143088393, 3140177600, 3137269503, 3134364098, 3131461384, 3128561359, - 3125664019, 3122769362, 3119877387, 3116988089, 3114101467, 3111217518, - 3108336240, 3105457631, 3102581687, 3099708407, 3096837788, 3093969827, - 3091104522, 3088241871, 3085381870, 3082524519, 3079669813, 3076817752, - 3073968331, 3071121550, 3068277404, 3065435893, 3062597013, 3059760763, - 3056927139, 3054096139, 3051267761, 3048442002, 3045618860, 3042798333, - 3039980417, 3037165112, 3034352413, 3031542320, 3028734829, 3025929938, - 3023127644, 3020327946, 3017530840, 3014736325, 3011944398, 3009155056 - ], - "decayFactorsExponent": 32, - "decayFactorEpochsSum": 2262417561, - "decayFactorEpochsSumExponent": 21, - "annualDecayFactorPercentage": 70 - }, - "tokenSupply": "1813620509061365", - "genesisSlot": 0, - "genesisUnixTimestamp": "1695275822", - "slotDurationInSeconds": 10, - "slotsPerEpochExponent": 13, - "stakingUnbondingPeriod": 10, - "validationBlocksPerSlot": 10, - "punishmentEpochs": 10, - "livenessThresholdLowerBound": 15, - "livenessThresholdUpperBound": 30, - "minCommittableAge": 10, - "maxCommittableAge": 20, - "epochNearingThreshold": 60, - "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": 1079, - "manaShareCoefficient": "2", - "decayBalancingConstantExponent": 8, - "decayBalancingConstant": "1", - "poolCoefficientExponent": 11, - "retentionPeriod": 384 - }, - "targetCommitteeSize": 32, - "chainSwitchingThreshold": 3 + "params":{ + "type":0, + "version":3, + "networkName":"testnet", + "bech32Hrp":"rms", + "storageScoreParameters":{ + "storageCost":"100", + "factorData":1, + "offsetOutputOverhead":"10", + "offsetEd25519BlockIssuerKey":"100", + "offsetStakingFeature":"100", + "offsetDelegation":"100" + }, + "workScoreParameters":{ + "dataByte":1, + "block":2, + "input":3, + "contextInput":4, + "output":5, + "nativeToken":6, + "staking":7, + "blockIssuer":8, + "allotment":9, + "signatureEd25519":10 + }, + "manaParameters":{ + "bitsCount":63, + "generationRate":1, + "generationRateExponent":17, + "decayFactors":[ + 4290989755, + 4287015898, + 4283045721, + 4279079221, + 4275116394, + 4271157237, + 4267201747, + 4263249920, + 4259301752, + 4255357241, + 4251416383, + 4247479175, + 4243545613, + 4239615693, + 4235689414, + 4231766770, + 4227847759, + 4223932377, + 4220020622, + 4216112489, + 4212207975, + 4208307077, + 4204409792, + 4200516116, + 4196626046, + 4192739579, + 4188856710, + 4184977438, + 4181101758, + 4177229668, + 4173361163, + 4169496241, + 4165634898, + 4161777132, + 4157922938, + 4154072313, + 4150225254, + 4146381758, + 4142541822, + 4138705441, + 4134872614, + 4131043336, + 4127217604, + 4123395415, + 4119576766, + 4115761654, + 4111950074, + 4108142024, + 4104337501, + 4100536502, + 4096739022, + 4092945060, + 4089154610, + 4085367672, + 4081584240, + 4077804312, + 4074027884, + 4070254954, + 4066485518, + 4062719573, + 4058957115, + 4055198142, + 4051442650, + 4047690636, + 4043942097, + 4040197029, + 4036455429, + 4032717295, + 4028982622, + 4025251408, + 4021523650, + 4017799344, + 4014078486, + 4010361075, + 4006647106, + 4002936577, + 3999229484, + 3995525824, + 3991825594, + 3988128791, + 3984435412, + 3980745453, + 3977058911, + 3973375783, + 3969696066, + 3966019757, + 3962346853, + 3958677350, + 3955011245, + 3951348535, + 3947689218, + 3944033289, + 3940380746, + 3936731586, + 3933085805, + 3929443400, + 3925804369, + 3922168708, + 3918536413, + 3914907483, + 3911281913, + 3907659701, + 3904040843, + 3900425337, + 3896813179, + 3893204366, + 3889598896, + 3885996764, + 3882397968, + 3878802505, + 3875210372, + 3871621566, + 3868036083, + 3864453920, + 3860875075, + 3857299544, + 3853727325, + 3850158414, + 3846592808, + 3843030504, + 3839471499, + 3835915790, + 3832363374, + 3828814248, + 3825268408, + 3821725853, + 3818186578, + 3814650580, + 3811117858, + 3807588407, + 3804062225, + 3800539308, + 3797019654, + 3793503259, + 3789990121, + 3786480237, + 3782973602, + 3779470216, + 3775970074, + 3772473173, + 3768979511, + 3765489084, + 3762001889, + 3758517924, + 3755037186, + 3751559671, + 3748085377, + 3744614300, + 3741146437, + 3737681787, + 3734220344, + 3730762108, + 3727307074, + 3723855240, + 3720406602, + 3716961158, + 3713518905, + 3710079840, + 3706643960, + 3703211262, + 3699781742, + 3696355399, + 3692932229, + 3689512229, + 3686095396, + 3682681728, + 3679271221, + 3675863872, + 3672459679, + 3669058639, + 3665660748, + 3662266004, + 3658874404, + 3655485944, + 3652100623, + 3648718437, + 3645339383, + 3641963459, + 3638590661, + 3635220986, + 3631854432, + 3628490996, + 3625130675, + 3621773465, + 3618419365, + 3615068371, + 3611720480, + 3608375690, + 3605033997, + 3601695399, + 3598359893, + 3595027476, + 3591698145, + 3588371897, + 3585048730, + 3581728640, + 3578411625, + 3575097682, + 3571786808, + 3568479000, + 3565174255, + 3561872571, + 3558573944, + 3555278373, + 3551985853, + 3548696383, + 3545409959, + 3542126578, + 3538846238, + 3535568936, + 3532294669, + 3529023435, + 3525755230, + 3522490051, + 3519227897, + 3515968763, + 3512712648, + 3509459548, + 3506209461, + 3502962384, + 3499718314, + 3496477248, + 3493239183, + 3490004118, + 3486772048, + 3483542972, + 3480316886, + 3477093788, + 3473873674, + 3470656543, + 3467442391, + 3464231216, + 3461023014, + 3457817784, + 3454615522, + 3451416225, + 3448219892, + 3445026518, + 3441836102, + 3438648641, + 3435464131, + 3432282571, + 3429103957, + 3425928286, + 3422755557, + 3419585766, + 3416418910, + 3413254987, + 3410093995, + 3406935929, + 3403780789, + 3400628570, + 3397479270, + 3394332887, + 3391189418, + 3388048860, + 3384911211, + 3381776467, + 3378644627, + 3375515686, + 3372389644, + 3369266496, + 3366146241, + 3363028875, + 3359914396, + 3356802802, + 3353694089, + 3350588256, + 3347485298, + 3344385214, + 3341288001, + 3338193657, + 3335102178, + 3332013562, + 3328927806, + 3325844909, + 3322764866, + 3319687675, + 3316613335, + 3313541841, + 3310473192, + 3307407385, + 3304344417, + 3301284286, + 3298226988, + 3295172522, + 3292120885, + 3289072074, + 3286026086, + 3282982919, + 3279942570, + 3276905037, + 3273870317, + 3270838408, + 3267809306, + 3264783010, + 3261759516, + 3258738822, + 3255720926, + 3252705824, + 3249693515, + 3246683996, + 3243677263, + 3240673315, + 3237672149, + 3234673763, + 3231678153, + 3228685317, + 3225695253, + 3222707958, + 3219723430, + 3216741666, + 3213762662, + 3210786418, + 3207812930, + 3204842196, + 3201874213, + 3198908979, + 3195946490, + 3192986746, + 3190029742, + 3187075477, + 3184123947, + 3181175151, + 3178229086, + 3175285749, + 3172345138, + 3169407251, + 3166472084, + 3163539635, + 3160609902, + 3157682882, + 3154758573, + 3151836972, + 3148918077, + 3146001885, + 3143088393, + 3140177600, + 3137269503, + 3134364098, + 3131461384, + 3128561359, + 3125664019, + 3122769362, + 3119877387, + 3116988089, + 3114101467, + 3111217518, + 3108336240, + 3105457631, + 3102581687, + 3099708407, + 3096837788, + 3093969827, + 3091104522, + 3088241871, + 3085381870, + 3082524519, + 3079669813, + 3076817752, + 3073968331, + 3071121550, + 3068277404, + 3065435893, + 3062597013, + 3059760763, + 3056927139, + 3054096139, + 3051267761, + 3048442002, + 3045618860, + 3042798333, + 3039980417, + 3037165112, + 3034352413, + 3031542320, + 3028734829, + 3025929938, + 3023127644, + 3020327946, + 3017530840, + 3014736325, + 3011944398, + 3009155056 + ], + "decayFactorsExponent":32, + "decayFactorEpochsSum":2262417561, + "decayFactorEpochsSumExponent":21, + "annualDecayFactorPercentage":70 + }, + "tokenSupply":"1813620509061365", + "genesisSlot":0, + "genesisUnixTimestamp":"1695275822", + "slotDurationInSeconds":10, + "slotsPerEpochExponent":13, + "stakingUnbondingPeriod":10, + "validationBlocksPerSlot":10, + "punishmentEpochs":10, + "livenessThresholdLowerBound":15, + "livenessThresholdUpperBound":30, + "minCommittableAge":10, + "maxCommittableAge":20, + "epochNearingThreshold":60, + "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":1079, + "rewardToGenerationRatio":2, + "initialTargetRewardsRate":"8", + "finalTargetRewardsRate":"1", + "poolCoefficientExponent":11, + "retentionPeriod":384 + }, + "targetCommitteeSize":32, + "chainSwitchingThreshold":3 }, - "bytes": "0x000307746573746e657403726d736400000000000000010a000000000000006400000000000000640000000000000064000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000003f01118001bb4ec3ffdaab86ff59174aff35910dff6a19d1fef5af94fed35458fe00081cfe78c9dffd3999a3fd3f7767fd87632bfd0d5eeffccd66b3fcc67d77fcf2a23bfc4fd6fffbd917c4fb8e6788fb69c54cfb673111fb85abd5fac0339afa14ca5efa7e6e23fafb20e8f986e1acf91eb071f9be8c36f96477fbf80b70c0f8b17685f8528b4af8ecad0ff87aded4f7f91c9af766695ff7bec324f7fe2beaf621a2aff6262675f608b83af6c45700f65705c6f5bec08bf5f68951f5fa6017f5c845ddf45d38a3f4b63869f4ce462ff4a462f5f3328cbbf378c381f3700848f3185b0ef36cbbd4f26a299bf20ea561f2552e28f23bc5eef1be69b5f1da1b7cf18cdb42f1d1a809f1a583d0f0056c97f0ef615ef05e6525f05076ecefc294b3efb0c07aef16fa41eff34009ef4295d0ee01f797ee2c665feec0e226eeba6ceeed1704b6edd4a87deded5a45ed5f1a0ded27e7d4ec42c19cecada864ec659d2cec669ff4ebadaebceb37cb84eb02f54ceb092c15eb4a70ddeac2c1a5ea6d206eea488c36ea5105ffe9848bc7e9dd1e90e95bbf58e9f96c21e9b527eae88befb2e879c47be87ba644e88e950de8b091d6e7dc9a9fe710b168e749d431e78404fbe6be41c4e6f38b8de620e356e6434720e658b8e9e55d36b3e54ec17ce5285946e5e8fd0fe58bafd9e40e6ea3e46e396de4a81137e4b8f600e49de8cae352e794e3d4f25ee3220b29e33730f3e21162bde2aca087e206ec51e21b441ce2e9a8e6e16d1ab1e1a2987be1882346e11abb10e1555fdbe03710a6e0bccd70e0e1973be0a46e06e00252d1dff7419cdf813e67df9c4732df455dfdde7b7fc8de38ae93de7ce95ede42312ade8885f5dd4ae6c0dd86538cdd39cd57dd605323ddf8e5eedcfe84badc6e3086dc47e851dc85ac1ddc257de9db245ab5db804381db35394ddb403b19db9f49e5da4f64b1da4c8b7dda94be49da24fe15daf849e2d90fa2aed965067bd9f77647d9c3f313d9c57ce0d8fa11add860b379d8f46046d8b31a13d899e0dfd7a5b2acd7d39079d7207b46d78a7113d70d74e0d6a782add6559d7ad614c447d6e1f614d6b935e2d59a80afd580d77cd5693a4ad552a917d53824e5d418abb2d4ef3d80d4bbdc4dd478871bd4253ee9d3bd00b7d33fcf84d3a7a952d3f28f20d31e82eed22880bcd20d8a8ad2cb9f58d25ec126d2c3eef4d1f927c3d1fb6c91d1c8bd5fd15c1a2ed1b582fcd0d0f6cad0aa7699d0400268d08f9936d0963c05d050ebd3cfbca5a2cfd66b71cf9c3d40cf0a1b0fcf1f04deced7f8acce30f97bce26054bceb81c1acee23fe9cda16eb8cdf4a887cdd6ee56cd464026cd419df5ccc305c5cccb7994cc55f963cc5e8433cce51a03cce6bcd2cb5e6aa2cb4b2372cbabe741cb79b711cbb592e1ca5a79b1ca666b81cad76851caaa7121cadc85f1c96ba5c1c953d091c9930662c9264832c90c9502c940edd2c8c150a3c88bbf73c89c3944c8f2be14c8894fe5c760ebb5c7729286c7be4457c7410228c7f9caf8c6e29ec9c6fa7d9ac63e686bc6ad5d3cc6425e0dc6fb69dec5d780afc5d1a280c5e8cf51c5190823c5614bf4c4be99c5c42cf396c4aa5768c435c739c4ca410bc466c7dcc30758aec3aaf37fc34d9a51c3ed4b23c38808f5c21ad0c6c2a2a298c21c806ac286683cc2de5b0ec2205ae0c14b63b2c15c7784c14f9656c123c028c1d5f4fac06334cdc0c97e9fc005d471c0153444c0f69e16c0a614e9bf2295bbbf66208ebf72b660bf425733bfd40206bf25b9d8be337aabbefa457ebe7a1c51beaefd23be95e9f6bd2be0c9bd6fe19cbd5eed6fbdf50343bd322516bd1351e9bc9487bcbcb3c88fbc6e1463bcc26a36bcadcb09bc2c37ddbb3dadb0bbdd2d84bb09b957bbc04e2bbbffeefebac299d2ba084fa6bacf0e7aba13d94dbad2ad21ba0b8df5b9b976c9b9db6a9db96e6971b9707245b9df8519b9b7a3edb8f7cbc1b89cfe95b8a33b6ab80a833eb8cfd412b8ee30e7b76797bbb7350890b7588364b7cb0839b78e980db79c32e2b6f5d6b6b695858bb67b3e60b6a30135b60bcf09b6b1a6deb59288b3b5ac7488b5fd6a5db5816b32b5387607b51d8bdcb430aab1b46dd386b4d2065cb45c4431b40a8c06b4d8dddbb3c539b1b3ce9f86b3f00f5cb32099c0d9861546f530336e7a710600000000002edb0b65000000000a0d0a0000000a0a0000000f001e000a000000140000003c00000001000000000000000000000000000000000000000000000000350c0020a10700a0860100e803000064000000070507083704000002000000000000000801000000000000000b80012003", - "hash": "0x28ccbc633e0d22e19752f5e65c0d22055a7d59756bfa754b8839088e18a6a5a6" -} + "bytes":"0x000307746573746e657403726d736400000000000000010a000000000000006400000000000000640000000000000064000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000003f01118001bb4ec3ffdaab86ff59174aff35910dff6a19d1fef5af94fed35458fe00081cfe78c9dffd3999a3fd3f7767fd87632bfd0d5eeffccd66b3fcc67d77fcf2a23bfc4fd6fffbd917c4fb8e6788fb69c54cfb673111fb85abd5fac0339afa14ca5efa7e6e23fafb20e8f986e1acf91eb071f9be8c36f96477fbf80b70c0f8b17685f8528b4af8ecad0ff87aded4f7f91c9af766695ff7bec324f7fe2beaf621a2aff6262675f608b83af6c45700f65705c6f5bec08bf5f68951f5fa6017f5c845ddf45d38a3f4b63869f4ce462ff4a462f5f3328cbbf378c381f3700848f3185b0ef36cbbd4f26a299bf20ea561f2552e28f23bc5eef1be69b5f1da1b7cf18cdb42f1d1a809f1a583d0f0056c97f0ef615ef05e6525f05076ecefc294b3efb0c07aef16fa41eff34009ef4295d0ee01f797ee2c665feec0e226eeba6ceeed1704b6edd4a87deded5a45ed5f1a0ded27e7d4ec42c19cecada864ec659d2cec669ff4ebadaebceb37cb84eb02f54ceb092c15eb4a70ddeac2c1a5ea6d206eea488c36ea5105ffe9848bc7e9dd1e90e95bbf58e9f96c21e9b527eae88befb2e879c47be87ba644e88e950de8b091d6e7dc9a9fe710b168e749d431e78404fbe6be41c4e6f38b8de620e356e6434720e658b8e9e55d36b3e54ec17ce5285946e5e8fd0fe58bafd9e40e6ea3e46e396de4a81137e4b8f600e49de8cae352e794e3d4f25ee3220b29e33730f3e21162bde2aca087e206ec51e21b441ce2e9a8e6e16d1ab1e1a2987be1882346e11abb10e1555fdbe03710a6e0bccd70e0e1973be0a46e06e00252d1dff7419cdf813e67df9c4732df455dfdde7b7fc8de38ae93de7ce95ede42312ade8885f5dd4ae6c0dd86538cdd39cd57dd605323ddf8e5eedcfe84badc6e3086dc47e851dc85ac1ddc257de9db245ab5db804381db35394ddb403b19db9f49e5da4f64b1da4c8b7dda94be49da24fe15daf849e2d90fa2aed965067bd9f77647d9c3f313d9c57ce0d8fa11add860b379d8f46046d8b31a13d899e0dfd7a5b2acd7d39079d7207b46d78a7113d70d74e0d6a782add6559d7ad614c447d6e1f614d6b935e2d59a80afd580d77cd5693a4ad552a917d53824e5d418abb2d4ef3d80d4bbdc4dd478871bd4253ee9d3bd00b7d33fcf84d3a7a952d3f28f20d31e82eed22880bcd20d8a8ad2cb9f58d25ec126d2c3eef4d1f927c3d1fb6c91d1c8bd5fd15c1a2ed1b582fcd0d0f6cad0aa7699d0400268d08f9936d0963c05d050ebd3cfbca5a2cfd66b71cf9c3d40cf0a1b0fcf1f04deced7f8acce30f97bce26054bceb81c1acee23fe9cda16eb8cdf4a887cdd6ee56cd464026cd419df5ccc305c5cccb7994cc55f963cc5e8433cce51a03cce6bcd2cb5e6aa2cb4b2372cbabe741cb79b711cbb592e1ca5a79b1ca666b81cad76851caaa7121cadc85f1c96ba5c1c953d091c9930662c9264832c90c9502c940edd2c8c150a3c88bbf73c89c3944c8f2be14c8894fe5c760ebb5c7729286c7be4457c7410228c7f9caf8c6e29ec9c6fa7d9ac63e686bc6ad5d3cc6425e0dc6fb69dec5d780afc5d1a280c5e8cf51c5190823c5614bf4c4be99c5c42cf396c4aa5768c435c739c4ca410bc466c7dcc30758aec3aaf37fc34d9a51c3ed4b23c38808f5c21ad0c6c2a2a298c21c806ac286683cc2de5b0ec2205ae0c14b63b2c15c7784c14f9656c123c028c1d5f4fac06334cdc0c97e9fc005d471c0153444c0f69e16c0a614e9bf2295bbbf66208ebf72b660bf425733bfd40206bf25b9d8be337aabbefa457ebe7a1c51beaefd23be95e9f6bd2be0c9bd6fe19cbd5eed6fbdf50343bd322516bd1351e9bc9487bcbcb3c88fbc6e1463bcc26a36bcadcb09bc2c37ddbb3dadb0bbdd2d84bb09b957bbc04e2bbbffeefebac299d2ba084fa6bacf0e7aba13d94dbad2ad21ba0b8df5b9b976c9b9db6a9db96e6971b9707245b9df8519b9b7a3edb8f7cbc1b89cfe95b8a33b6ab80a833eb8cfd412b8ee30e7b76797bbb7350890b7588364b7cb0839b78e980db79c32e2b6f5d6b6b695858bb67b3e60b6a30135b60bcf09b6b1a6deb59288b3b5ac7488b5fd6a5db5816b32b5387607b51d8bdcb430aab1b46dd386b4d2065cb45c4431b40a8c06b4d8dddbb3c539b1b3ce9f86b3f00f5cb32099c0d9861546f530336e7a710600000000002edb0b65000000000a0d0a0000000a0a0000000f001e000a000000140000003c00000001000000000000000000000000000000000000000000000000350c0020a10700a0860100e803000064000000070507083704000002080000000000000001000000000000000b80012003", + "hash":"0x21e0f6e8607b04fa34d54a8a776adfe7e0e5a8931005ce8a66c5990fa1c2f960" +} \ No newline at end of file diff --git a/sdk/tests/types/protocol_parameters.rs b/sdk/tests/types/protocol_parameters.rs index 84c6c201be..3159695c6b 100644 --- a/sdk/tests/types/protocol_parameters.rs +++ b/sdk/tests/types/protocol_parameters.rs @@ -5,16 +5,19 @@ use iota_sdk::types::block::protocol::ProtocolParameters; use packable::PackableExt; use pretty_assertions::assert_eq; -// // Test from https://github.com/iotaledger/tips/blob/tip49/tips/TIP-0049/tip-0049.md#protocol-parameter-hash -// #[test] -// fn serde_packable_hash() { -// let file = std::fs::read_to_string("./tests/types/fixtures/protocol_parameters.json").unwrap(); -// let json = serde_json::from_str::(&file).unwrap(); -// let params_json = &json["params"]; -// let params = serde_json::from_value::(params_json.clone()).unwrap(); -// let params_bytes = params.pack_to_vec(); +// Test from https://github.com/iotaledger/tips/blob/tip49/tips/TIP-0049/tip-0049.md#protocol-parameter-hash +#[test] +fn serde_packable_hash() { + let file = std::fs::read_to_string("./tests/types/fixtures/protocol_parameters.json").unwrap(); + let json = serde_json::from_str::(&file).unwrap(); + let params_json = &json["params"]; + let params = serde_json::from_value::(params_json.clone()).unwrap(); + let params_bytes = params.pack_to_vec(); -// assert_eq!(prefix_hex::encode(¶ms_bytes), json["bytes"]); -// assert_eq!(params, ProtocolParameters::unpack_verified(params_bytes, &()).unwrap()); -// assert_eq!(params.hash().to_string(), json["hash"]); -// } + assert_eq!(prefix_hex::encode(¶ms_bytes), json["bytes"]); + assert_eq!( + params, + ProtocolParameters::unpack_bytes_verified(params_bytes, &()).unwrap() + ); + assert_eq!(params.hash().to_string(), json["hash"]); +}