I have a separate canister that pulls neuron data from our sns governance canister. As part of testing we want to do some integration testing. To do this, we require to either simulate or mock the sns_goverenance canister and so in turn simulate neurons with accuring maturity.
I downloaded the sns goverenance wasm file using dfx sns
extension and are now using pocket-ic to create a sns subnet with the governance canister. During this process of installing the canister I have to provide the init args.
I use encode_one to encode the init args and i always get an error "Canister lxzze-o7777-77777-aaaaa-cai trapped explicitly: Panicked at 'Deserialization Failed: \"Fail to decode argument 0\"'
Am I doing this correctly?
Here is what the code looks like.
let pic = PocketIcBuilder::new().with_sns_subnet().build();
let sns_subnet = pic.topology().get_sns().unwrap();
let sns_gov_id = pic.create_canister_on_subnet(None, None, sns_subnet);
pic.add_cycles(sns_gov_id, INIT_CYCLES);
let sns_controller = Principal::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 1]).to_string();
let sns_gov_init_args = SnsInitPayload {
confirmation_text: Some("Welcome to the jungle baby".to_string()),
transaction_fee_e8s: Some(10000u64),
token_name: Some("Simulation Governance".to_string()),
token_symbol: Some("SIMG".to_string()),
proposal_reject_cost_e8s: Some(10000u64),
neuron_minimum_stake_e8s: Some(10000u64),
fallback_controller_principal_ids: vec![sns_controller.clone()],
logo: Some("data:image/png;base64,iVBORw0".to_string()),
url: Some("https://google.com".to_string()),
name: Some("Simulation Gov".to_string()),
description: Some("Simulation gov desc".to_string()),
neuron_minimum_dissolve_delay_to_vote_seconds: Some(1),
initial_reward_rate_basis_points: Some(10u64),
final_reward_rate_basis_points: Some(20u64),
reward_rate_transition_duration_seconds: Some(1u64),
max_dissolve_delay_seconds: Some(1u64),
max_neuron_age_seconds_for_age_bonus: Some(1u64),
max_dissolve_delay_bonus_percentage: Some(10u64),
max_age_bonus_percentage: Some(10u64),
initial_voting_period_seconds: Some(1u64),
wait_for_quiet_deadline_increase_seconds: Some(1u64),
restricted_countries: None,
dapp_canisters: None,
min_participants: Some(1),
min_icp_e8s: Some(1u64),
max_icp_e8s: Some(10_000_000_000u64),
min_direct_participation_icp_e8s: Some(10000u64),
min_participant_icp_e8s: Some(10000u64),
max_direct_participation_icp_e8s: Some(100_000u64),
max_participant_icp_e8s: Some(10000u64),
swap_start_timestamp_seconds: None,
swap_due_timestamp_seconds: Some(32512438014000u64), // year 3000 - hopefully we'll all be gone by then,
neuron_basket_construction_parameters: None,
nns_proposal_id: Some(1),
neurons_fund_participation: None,
neurons_fund_participants: None,
token_logo: Some("data:image/png;base64,iVBORw0".to_string()),
neurons_fund_participation_constraints: None,
initial_token_distribution: Some(
crate::sns_init_payload::InitialTokenDistribution::FractionalDeveloperVotingPower(
FractionalDeveloperVotingPower {
airdrop_distribution: None,
developer_distribution: None,
treasury_distribution: None,
swap_distribution: None,
}
)
),
};
let init_args_two = SnsInitArg { sns_initialization_parameters: sns_gov_init_args };
pic.install_canister(
sns_gov_id,
get_governance_canister_wasm(),
encode_one(init_args_two).unwrap(),
None
);