@@ -58,6 +58,13 @@ pub struct Params {
5858 pub snapshot_period : Uint ,
5959
6060 pub term_seconds : Option < Uint > ,
61+ pub nomination_expiration : Option < Uint > ,
62+ pub custody_period : Option < Uint > ,
63+ pub release_period : Option < Uint > ,
64+ pub max_num_of_validators : Option < Uint > ,
65+ pub min_num_of_validators : Option < Uint > ,
66+ pub delegation_threshold : Option < Uint > ,
67+ pub min_deposit : Option < Uint > ,
6168}
6269
6370#[ cfg( test) ]
@@ -67,6 +74,7 @@ mod tests {
6774 use super :: Params ;
6875
6976 #[ test]
77+ #[ allow( clippy:: cognitive_complexity) ]
7078 fn params_deserialization ( ) {
7179 let s = r#"{
7280 "maxExtraDataSize": "0x20",
@@ -119,10 +127,18 @@ mod tests {
119127 assert_eq ! ( deserialized. max_body_size, 4_194_304 . into( ) ) ;
120128 assert_eq ! ( deserialized. snapshot_period, 16_384 . into( ) ) ;
121129 assert_eq ! ( deserialized. term_seconds, None ) ;
130+ assert_eq ! ( deserialized. nomination_expiration, None ) ;
131+ assert_eq ! ( deserialized. custody_period, None ) ;
132+ assert_eq ! ( deserialized. release_period, None ) ;
133+ assert_eq ! ( deserialized. max_num_of_validators, None ) ;
134+ assert_eq ! ( deserialized. min_num_of_validators, None ) ;
135+ assert_eq ! ( deserialized. delegation_threshold, None ) ;
136+ assert_eq ! ( deserialized. min_deposit, None ) ;
122137 }
123138
124139
125140 #[ test]
141+ #[ allow( clippy:: cognitive_complexity) ]
126142 fn params_deserialization_with_term_seconds ( ) {
127143 let s = r#"{
128144 "maxExtraDataSize": "0x20",
@@ -176,5 +192,84 @@ mod tests {
176192 assert_eq ! ( deserialized. max_body_size, 4_194_304 . into( ) ) ;
177193 assert_eq ! ( deserialized. snapshot_period, 16_384 . into( ) ) ;
178194 assert_eq ! ( deserialized. term_seconds, Some ( 3600 . into( ) ) ) ;
195+ assert_eq ! ( deserialized. nomination_expiration, None ) ;
196+ assert_eq ! ( deserialized. custody_period, None ) ;
197+ assert_eq ! ( deserialized. release_period, None ) ;
198+ assert_eq ! ( deserialized. max_num_of_validators, None ) ;
199+ assert_eq ! ( deserialized. min_num_of_validators, None ) ;
200+ assert_eq ! ( deserialized. delegation_threshold, None ) ;
201+ assert_eq ! ( deserialized. min_deposit, None ) ;
202+ }
203+
204+
205+ #[ test]
206+ #[ allow( clippy:: cognitive_complexity) ]
207+ fn params_deserialization_with_stake_params ( ) {
208+ let s = r#"{
209+ "maxExtraDataSize": "0x20",
210+ "maxAssetSchemeMetadataSize": "0x0400",
211+ "maxTransferMetadataSize": "0x0100",
212+ "maxTextContentSize": "0x0200",
213+ "networkID" : "tc",
214+ "minPayCost" : 10,
215+ "minSetRegularKeyCost" : 11,
216+ "minCreateShardCost" : 12,
217+ "minSetShardOwnersCost" : 13,
218+ "minSetShardUsersCost" : 14,
219+ "minWrapCccCost" : 15,
220+ "minCustomCost" : 16,
221+ "minStoreCost" : 17,
222+ "minRemoveCost" : 18,
223+ "minMintAssetCost" : 19,
224+ "minTransferAssetCost" : 20,
225+ "minChangeAssetSchemeCost" : 21,
226+ "minComposeAssetCost" : 22,
227+ "minDecomposeAssetCost" : 23,
228+ "minUnwrapCccCost" : 24,
229+ "minIncreaseAssetSupplyCost": 25,
230+ "maxBodySize" : 4194304,
231+ "snapshotPeriod": 16384,
232+ "termSeconds": 3600,
233+ "nominationExpiration": 26,
234+ "custodyPeriod": 27,
235+ "releasePeriod": 28,
236+ "maxNumOfValidators": 29,
237+ "minNumOfValidators": 30,
238+ "delegationThreshold": 31,
239+ "minDeposit": 32
240+ }"# ;
241+
242+ let deserialized: Params = serde_json:: from_str ( s) . unwrap ( ) ;
243+ assert_eq ! ( deserialized. max_extra_data_size, 0x20 . into( ) ) ;
244+ assert_eq ! ( deserialized. max_asset_scheme_metadata_size, 0x0400 . into( ) ) ;
245+ assert_eq ! ( deserialized. max_transfer_metadata_size, 0x0100 . into( ) ) ;
246+ assert_eq ! ( deserialized. max_text_content_size, 0x0200 . into( ) ) ;
247+ assert_eq ! ( deserialized. network_id, "tc" . into( ) ) ;
248+ assert_eq ! ( deserialized. min_pay_cost, 10 . into( ) ) ;
249+ assert_eq ! ( deserialized. min_set_regular_key_cost, 11 . into( ) ) ;
250+ assert_eq ! ( deserialized. min_create_shard_cost, 12 . into( ) ) ;
251+ assert_eq ! ( deserialized. min_set_shard_owners_cost, 13 . into( ) ) ;
252+ assert_eq ! ( deserialized. min_set_shard_users_cost, 14 . into( ) ) ;
253+ assert_eq ! ( deserialized. min_wrap_ccc_cost, 15 . into( ) ) ;
254+ assert_eq ! ( deserialized. min_custom_cost, 16 . into( ) ) ;
255+ assert_eq ! ( deserialized. min_store_cost, 17 . into( ) ) ;
256+ assert_eq ! ( deserialized. min_remove_cost, 18 . into( ) ) ;
257+ assert_eq ! ( deserialized. min_mint_asset_cost, 19 . into( ) ) ;
258+ assert_eq ! ( deserialized. min_transfer_asset_cost, 20 . into( ) ) ;
259+ assert_eq ! ( deserialized. min_change_asset_scheme_cost, 21 . into( ) ) ;
260+ assert_eq ! ( deserialized. min_compose_asset_cost, 22 . into( ) ) ;
261+ assert_eq ! ( deserialized. min_decompose_asset_cost, 23 . into( ) ) ;
262+ assert_eq ! ( deserialized. min_unwrap_ccc_cost, 24 . into( ) ) ;
263+ assert_eq ! ( deserialized. min_increase_asset_supply_cost, 25 . into( ) ) ;
264+ assert_eq ! ( deserialized. max_body_size, 4_194_304 . into( ) ) ;
265+ assert_eq ! ( deserialized. snapshot_period, 16_384 . into( ) ) ;
266+ assert_eq ! ( deserialized. term_seconds, Some ( 3600 . into( ) ) ) ;
267+ assert_eq ! ( deserialized. nomination_expiration, Some ( 26 . into( ) ) ) ;
268+ assert_eq ! ( deserialized. custody_period, Some ( 27 . into( ) ) ) ;
269+ assert_eq ! ( deserialized. release_period, Some ( 28 . into( ) ) ) ;
270+ assert_eq ! ( deserialized. max_num_of_validators, Some ( 29 . into( ) ) ) ;
271+ assert_eq ! ( deserialized. min_num_of_validators, Some ( 30 . into( ) ) ) ;
272+ assert_eq ! ( deserialized. delegation_threshold, Some ( 31 . into( ) ) ) ;
273+ assert_eq ! ( deserialized. min_deposit, Some ( 32 . into( ) ) ) ;
179274 }
180275}
0 commit comments