@@ -33,7 +33,7 @@ fn test_prost_enum_to_self_describing() {
3333 let prost_enum = SelfDescribingProstEnum :: < Topic > :: new ( value) ;
3434 assert_eq ! (
3535 SelfDescribingValue :: from( SelfDescribingValuePb :: from( prost_enum) ) ,
36- SelfDescribingValue :: Text ( expected. to_string ( ) )
36+ SelfDescribingValue :: from ( expected)
3737 ) ;
3838 }
3939}
@@ -46,7 +46,7 @@ fn test_motion_to_self_describing() {
4646 assert_proposal_action_self_describing_value_is (
4747 motion,
4848 SelfDescribingValue :: Map ( hashmap ! {
49- "motion_text" . to_string( ) => SelfDescribingValue :: Text ( "This is a motion" . to_string ( ) ) ,
49+ "motion_text" . to_string( ) => SelfDescribingValue :: from ( "This is a motion" ) ,
5050 } ) ,
5151 ) ;
5252}
@@ -63,17 +63,15 @@ fn test_approve_genesis_kyc_to_self_describing() {
6363 approve_genesis_kyc,
6464 SelfDescribingValue :: Map ( hashmap ! {
6565 "principals" . to_string( ) => SelfDescribingValue :: Array ( vec![
66- SelfDescribingValue :: Text ( "6fyp7-3ibaa-aaaaa-aaaap-4ai" . to_string ( ) ) ,
67- SelfDescribingValue :: Text ( "djduj-3qcaa-aaaaa-aaaap-4ai" . to_string ( ) ) ,
66+ SelfDescribingValue :: from ( "6fyp7-3ibaa-aaaaa-aaaap-4ai" ) ,
67+ SelfDescribingValue :: from ( "djduj-3qcaa-aaaaa-aaaap-4ai" ) ,
6868 ] ) ,
6969 } ) ,
7070 ) ;
7171}
7272
7373#[ test]
7474fn test_network_economics_to_self_describing_all_fields ( ) {
75- use SelfDescribingValue :: * ;
76-
7775 assert_self_describing_value_is (
7876 NetworkEconomics {
7977 // We want to avoid the reject_cost_e8s from being set to the same value as the
@@ -83,60 +81,58 @@ fn test_network_economics_to_self_describing_all_fields() {
8381 } ,
8482 SelfDescribingValue :: Map ( hashmap ! {
8583 "reject_cost_e8s" . to_string( ) =>
86- Nat ( candid :: Nat :: from( 1_000_000_000_u64 ) ) ,
84+ SelfDescribingValue :: from( 1_000_000_000_u64 ) ,
8785 "neuron_minimum_stake_e8s" . to_string( ) =>
88- Nat ( candid :: Nat :: from( 100_000_000_u64 ) ) ,
86+ SelfDescribingValue :: from( 100_000_000_u64 ) ,
8987 "neuron_management_fee_per_proposal_e8s" . to_string( ) =>
90- Nat ( candid :: Nat :: from( 1_000_000_u64 ) ) ,
88+ SelfDescribingValue :: from( 1_000_000_u64 ) ,
9189 "minimum_icp_xdr_rate" . to_string( ) =>
92- Nat ( candid :: Nat :: from( 100_u64 ) ) ,
90+ SelfDescribingValue :: from( 100_u64 ) ,
9391 "neuron_spawn_dissolve_delay_seconds" . to_string( ) =>
94- Nat ( candid :: Nat :: from( 604_800_u64 ) ) ,
92+ SelfDescribingValue :: from( 604_800_u64 ) ,
9593 "maximum_node_provider_rewards_e8s" . to_string( ) =>
96- Nat ( candid :: Nat :: from( 100_000_000_000_000_u64 ) ) ,
94+ SelfDescribingValue :: from( 100_000_000_000_000_u64 ) ,
9795 "transaction_fee_e8s" . to_string( ) =>
98- Nat ( candid :: Nat :: from( 10_000_u64 ) ) ,
96+ SelfDescribingValue :: from( 10_000_u64 ) ,
9997 "max_proposals_to_keep_per_topic" . to_string( ) =>
100- Nat ( candid :: Nat :: from( 100_u32 ) ) ,
98+ SelfDescribingValue :: from( 100_u32 ) ,
10199 "neurons_fund_economics" . to_string( ) =>
102- Map ( hashmap! {
100+ SelfDescribingValue :: Map ( hashmap! {
103101 "max_theoretical_neurons_fund_participation_amount_xdr" . to_string( ) =>
104- Text ( "750_000.0" . to_string ( ) ) ,
102+ SelfDescribingValue :: from ( "750_000.0" ) ,
105103 "neurons_fund_matched_funding_curve_coefficients" . to_string( ) =>
106- Map ( hashmap! {
104+ SelfDescribingValue :: Map ( hashmap! {
107105 "contribution_threshold_xdr" . to_string( ) =>
108- Text ( "75_000.0" . to_string ( ) ) ,
106+ SelfDescribingValue :: from ( "75_000.0" ) ,
109107 "one_third_participation_milestone_xdr" . to_string( ) =>
110- Text ( "225_000.0" . to_string ( ) ) ,
108+ SelfDescribingValue :: from ( "225_000.0" ) ,
111109 "full_participation_milestone_xdr" . to_string( ) =>
112- Text ( "375_000.0" . to_string ( ) ) ,
110+ SelfDescribingValue :: from ( "375_000.0" ) ,
113111 } ) ,
114112 "minimum_icp_xdr_rate" . to_string( ) =>
115- Map ( hashmap! {
116- "basis_points" . to_string( ) => Nat ( candid :: Nat :: from( 10000_u64 ) ) ,
113+ SelfDescribingValue :: Map ( hashmap! {
114+ "basis_points" . to_string( ) => SelfDescribingValue :: from( 10000_u64 ) ,
117115 } ) ,
118116 "maximum_icp_xdr_rate" . to_string( ) =>
119- Map ( hashmap! {
120- "basis_points" . to_string( ) => Nat ( candid :: Nat :: from( 1000000_u64 ) ) ,
117+ SelfDescribingValue :: Map ( hashmap! {
118+ "basis_points" . to_string( ) => SelfDescribingValue :: from( 1000000_u64 ) ,
121119 } ) ,
122120 } ) ,
123121 "voting_power_economics" . to_string( ) =>
124- Map ( hashmap! {
122+ SelfDescribingValue :: Map ( hashmap! {
125123 "start_reducing_voting_power_after_seconds" . to_string( ) =>
126- Nat ( candid :: Nat :: from( 15_778_800_u64 ) ) ,
124+ SelfDescribingValue :: from( 15_778_800_u64 ) ,
127125 "clear_following_after_seconds" . to_string( ) =>
128- Nat ( candid :: Nat :: from( 2_629_800_u64 ) ) ,
126+ SelfDescribingValue :: from( 2_629_800_u64 ) ,
129127 "neuron_minimum_dissolve_delay_to_vote_seconds" . to_string( ) =>
130- Nat ( candid :: Nat :: from( 15_778_800_u64 ) ) ,
128+ SelfDescribingValue :: from( 15_778_800_u64 ) ,
131129 } ) ,
132130 } ) ,
133131 ) ;
134132}
135133
136134#[ test]
137135fn test_network_economics_to_self_describing_minimal ( ) {
138- use SelfDescribingValue :: * ;
139-
140136 assert_self_describing_value_is (
141137 NetworkEconomics {
142138 neurons_fund_economics : None ,
@@ -146,27 +142,27 @@ fn test_network_economics_to_self_describing_minimal() {
146142 reject_cost_e8s : 1_000_000_000_u64 ,
147143 ..NetworkEconomics :: with_default_values ( )
148144 } ,
149- Map ( hashmap ! {
145+ SelfDescribingValue :: Map ( hashmap ! {
150146 "reject_cost_e8s" . to_string( ) =>
151- Nat ( candid :: Nat :: from( 1_000_000_000_u64 ) ) ,
147+ SelfDescribingValue :: from( 1_000_000_000_u64 ) ,
152148 "neuron_minimum_stake_e8s" . to_string( ) =>
153- Nat ( candid :: Nat :: from( 100_000_000_u64 ) ) ,
149+ SelfDescribingValue :: from( 100_000_000_u64 ) ,
154150 "neuron_management_fee_per_proposal_e8s" . to_string( ) =>
155- Nat ( candid :: Nat :: from( 1_000_000_u64 ) ) ,
151+ SelfDescribingValue :: from( 1_000_000_u64 ) ,
156152 "minimum_icp_xdr_rate" . to_string( ) =>
157- Nat ( candid :: Nat :: from( 100_u64 ) ) ,
153+ SelfDescribingValue :: from( 100_u64 ) ,
158154 "neuron_spawn_dissolve_delay_seconds" . to_string( ) =>
159- Nat ( candid :: Nat :: from( 604_800_u64 ) ) ,
155+ SelfDescribingValue :: from( 604_800_u64 ) ,
160156 "maximum_node_provider_rewards_e8s" . to_string( ) =>
161- Nat ( candid :: Nat :: from( 100_000_000_000_000_u64 ) ) ,
157+ SelfDescribingValue :: from( 100_000_000_000_000_u64 ) ,
162158 "transaction_fee_e8s" . to_string( ) =>
163- Nat ( candid :: Nat :: from( 10_000_u64 ) ) ,
159+ SelfDescribingValue :: from( 10_000_u64 ) ,
164160 "max_proposals_to_keep_per_topic" . to_string( ) =>
165- Nat ( candid :: Nat :: from( 100_u32 ) ) ,
161+ SelfDescribingValue :: from( 100_u32 ) ,
166162 "neurons_fund_economics" . to_string( ) =>
167- Null ,
163+ SelfDescribingValue :: Null ,
168164 "voting_power_economics" . to_string( ) =>
169- Null ,
165+ SelfDescribingValue :: Null ,
170166 } ) ,
171167 ) ;
172168}
@@ -363,8 +359,8 @@ fn test_derive_named_struct() {
363359 count : Some ( 42 ) ,
364360 } ,
365361 SelfDescribingValue :: Map ( hashmap ! {
366- "name" . to_string( ) => SelfDescribingValue :: Text ( "test" . to_string ( ) ) ,
367- "count" . to_string( ) => SelfDescribingValue :: Nat ( candid :: Nat :: from( 42u64 ) ) ,
362+ "name" . to_string( ) => SelfDescribingValue :: from ( "test" ) ,
363+ "count" . to_string( ) => SelfDescribingValue :: from( 42_u64 ) ,
368364 } ) ,
369365 ) ;
370366}
@@ -376,10 +372,7 @@ fn test_derive_all_unit_enum() {
376372 ( TestAllUnitEnum :: VariantB , "VariantB" ) ,
377373 ( TestAllUnitEnum :: VariantC , "VariantC" ) ,
378374 ] {
379- assert_self_describing_value_is (
380- variant,
381- SelfDescribingValue :: Text ( expected_name. to_string ( ) ) ,
382- ) ;
375+ assert_self_describing_value_is ( variant, SelfDescribingValue :: from ( expected_name) ) ;
383376 }
384377}
385378
0 commit comments