|
| 1 | +use super::*; |
| 2 | +use crate::proposals::self_describing::LocallyDescribableProposalAction; |
| 3 | +use ic_nns_governance_api::SelfDescribingValue; |
| 4 | +use maplit::hashmap; |
| 5 | + |
| 6 | +#[test] |
| 7 | +fn test_network_economics_all_fields() { |
| 8 | + let network_economics = NetworkEconomics::with_default_values(); |
| 9 | + |
| 10 | + let self_describing_value = |
| 11 | + SelfDescribingValue::from(network_economics.to_self_describing_value()); |
| 12 | + |
| 13 | + assert_eq!( |
| 14 | + self_describing_value, |
| 15 | + SelfDescribingValue::Map(hashmap! { |
| 16 | + "reject_cost_e8s".to_string() => |
| 17 | + SelfDescribingValue::Nat(candid::Nat::from(100_000_000u64)), |
| 18 | + "neuron_minimum_stake_e8s".to_string() => |
| 19 | + SelfDescribingValue::Nat(candid::Nat::from(100_000_000u64)), |
| 20 | + "neuron_management_fee_per_proposal_e8s".to_string() => |
| 21 | + SelfDescribingValue::Nat(candid::Nat::from(1_000_000u64)), |
| 22 | + "minimum_icp_xdr_rate".to_string() => |
| 23 | + SelfDescribingValue::Nat(candid::Nat::from(100u64)), |
| 24 | + "neuron_spawn_dissolve_delay_seconds".to_string() => |
| 25 | + SelfDescribingValue::Nat(candid::Nat::from(604_800u64)), |
| 26 | + "maximum_node_provider_rewards_e8s".to_string() => |
| 27 | + SelfDescribingValue::Nat(candid::Nat::from(100_000_000_000_000u64)), |
| 28 | + "transaction_fee_e8s".to_string() => |
| 29 | + SelfDescribingValue::Nat(candid::Nat::from(10_000u64)), |
| 30 | + "max_proposals_to_keep_per_topic".to_string() => |
| 31 | + SelfDescribingValue::Nat(candid::Nat::from(100u32)), |
| 32 | + "neurons_fund_economics".to_string() => |
| 33 | + SelfDescribingValue::Array(vec![ |
| 34 | + SelfDescribingValue::Map(hashmap! { |
| 35 | + "max_theoretical_neurons_fund_participation_amount_xdr".to_string() => |
| 36 | + SelfDescribingValue::Array(vec![ |
| 37 | + SelfDescribingValue::Map(hashmap! { |
| 38 | + "human_readable".to_string() => |
| 39 | + SelfDescribingValue::Array(vec![SelfDescribingValue::Text("750_000.0".to_string())]), |
| 40 | + }), |
| 41 | + ]), |
| 42 | + "neurons_fund_matched_funding_curve_coefficients".to_string() => |
| 43 | + SelfDescribingValue::Array(vec![ |
| 44 | + SelfDescribingValue::Map(hashmap! { |
| 45 | + "contribution_threshold_xdr".to_string() => |
| 46 | + SelfDescribingValue::Array(vec![ |
| 47 | + SelfDescribingValue::Map(hashmap! { |
| 48 | + "human_readable".to_string() => |
| 49 | + SelfDescribingValue::Array(vec![SelfDescribingValue::Text("75_000.0".to_string())]), |
| 50 | + }), |
| 51 | + ]), |
| 52 | + "one_third_participation_milestone_xdr".to_string() => |
| 53 | + SelfDescribingValue::Array(vec![ |
| 54 | + SelfDescribingValue::Map(hashmap! { |
| 55 | + "human_readable".to_string() => |
| 56 | + SelfDescribingValue::Array(vec![SelfDescribingValue::Text("225_000.0".to_string())]), |
| 57 | + }), |
| 58 | + ]), |
| 59 | + "full_participation_milestone_xdr".to_string() => |
| 60 | + SelfDescribingValue::Array(vec![ |
| 61 | + SelfDescribingValue::Map(hashmap! { |
| 62 | + "human_readable".to_string() => |
| 63 | + SelfDescribingValue::Array(vec![SelfDescribingValue::Text("375_000.0".to_string())]), |
| 64 | + }), |
| 65 | + ]), |
| 66 | + }), |
| 67 | + ]), |
| 68 | + "minimum_icp_xdr_rate".to_string() => |
| 69 | + SelfDescribingValue::Array(vec![ |
| 70 | + SelfDescribingValue::Map(hashmap! { |
| 71 | + "basis_points".to_string() => |
| 72 | + SelfDescribingValue::Array(vec![SelfDescribingValue::Nat(candid::Nat::from(10_000u64))]), |
| 73 | + }), |
| 74 | + ]), |
| 75 | + "maximum_icp_xdr_rate".to_string() => |
| 76 | + SelfDescribingValue::Array(vec![ |
| 77 | + SelfDescribingValue::Map(hashmap! { |
| 78 | + "basis_points".to_string() => |
| 79 | + SelfDescribingValue::Array(vec![SelfDescribingValue::Nat(candid::Nat::from(1_000_000u64))]), |
| 80 | + }), |
| 81 | + ]), |
| 82 | + }), |
| 83 | + ]), |
| 84 | + "voting_power_economics".to_string() => |
| 85 | + SelfDescribingValue::Array(vec![ |
| 86 | + SelfDescribingValue::Map(hashmap! { |
| 87 | + "start_reducing_voting_power_after_seconds".to_string() => |
| 88 | + SelfDescribingValue::Array(vec![SelfDescribingValue::Nat(candid::Nat::from(15_778_800u64))]), |
| 89 | + "clear_following_after_seconds".to_string() => |
| 90 | + SelfDescribingValue::Array(vec![SelfDescribingValue::Nat(candid::Nat::from(2_629_800u64))]), |
| 91 | + "neuron_minimum_dissolve_delay_to_vote_seconds".to_string() => |
| 92 | + SelfDescribingValue::Array(vec![SelfDescribingValue::Nat(candid::Nat::from(15_778_800u64))]), |
| 93 | + }), |
| 94 | + ]), |
| 95 | + }) |
| 96 | + ); |
| 97 | +} |
| 98 | + |
| 99 | +#[test] |
| 100 | +fn test_network_economics_minimal() { |
| 101 | + let network_economics = NetworkEconomics { |
| 102 | + neurons_fund_economics: None, |
| 103 | + voting_power_economics: None, |
| 104 | + ..NetworkEconomics::with_default_values() |
| 105 | + }; |
| 106 | + |
| 107 | + let self_describing_value = |
| 108 | + SelfDescribingValue::from(network_economics.to_self_describing_value()); |
| 109 | + |
| 110 | + assert_eq!( |
| 111 | + self_describing_value, |
| 112 | + SelfDescribingValue::Map(hashmap! { |
| 113 | + "reject_cost_e8s".to_string() => |
| 114 | + SelfDescribingValue::Nat(candid::Nat::from(100_000_000u64)), |
| 115 | + "neuron_minimum_stake_e8s".to_string() => |
| 116 | + SelfDescribingValue::Nat(candid::Nat::from(100_000_000u64)), |
| 117 | + "neuron_management_fee_per_proposal_e8s".to_string() => |
| 118 | + SelfDescribingValue::Nat(candid::Nat::from(1_000_000u64)), |
| 119 | + "minimum_icp_xdr_rate".to_string() => |
| 120 | + SelfDescribingValue::Nat(candid::Nat::from(100u64)), |
| 121 | + "neuron_spawn_dissolve_delay_seconds".to_string() => |
| 122 | + SelfDescribingValue::Nat(candid::Nat::from(604_800u64)), |
| 123 | + "maximum_node_provider_rewards_e8s".to_string() => |
| 124 | + SelfDescribingValue::Nat(candid::Nat::from(100_000_000_000_000u64)), |
| 125 | + "transaction_fee_e8s".to_string() => |
| 126 | + SelfDescribingValue::Nat(candid::Nat::from(10_000u64)), |
| 127 | + "max_proposals_to_keep_per_topic".to_string() => |
| 128 | + SelfDescribingValue::Nat(candid::Nat::from(100u32)), |
| 129 | + "neurons_fund_economics".to_string() => |
| 130 | + SelfDescribingValue::Array(vec![]), |
| 131 | + "voting_power_economics".to_string() => |
| 132 | + SelfDescribingValue::Array(vec![]), |
| 133 | + }) |
| 134 | + ); |
| 135 | +} |
0 commit comments