From afe721010b5a917b94fcee269f769c4985c7fc94 Mon Sep 17 00:00:00 2001 From: tmpolaczyk <44604217+tmpolaczyk@users.noreply.github.com> Date: Thu, 9 Nov 2023 16:12:08 +0100 Subject: [PATCH] Prefund pallet accounts in genesis to ensure they are always alive (#319) * Prefund pallet accounts in genesis to ensure they are always alive * Fix wrong staking test (there was no rounding) --- node/src/chain_spec.rs | 11 +++++++++++ .../staking/test_staking_rewards_balanced.ts | 4 ++-- .../staking/test_staking_rewards_non_balanced.ts | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index a839793db..b9cdbaead 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -293,6 +293,11 @@ fn testnet_genesis( mock_container_chains: &[ParaId], configuration: pallet_configuration::GenesisConfig, ) -> dancebox_runtime::RuntimeGenesisConfig { + let accounts_with_ed = vec![ + dancebox_runtime::StakingAccount::get(), + dancebox_runtime::ParachainBondAccount::get(), + dancebox_runtime::PendingRewardsAccount::get(), + ]; dancebox_runtime::RuntimeGenesisConfig { system: dancebox_runtime::SystemConfig { code: dancebox_runtime::WASM_BINARY @@ -305,6 +310,12 @@ fn testnet_genesis( .iter() .cloned() .map(|k| (k, 1 << 60)) + .chain( + accounts_with_ed + .iter() + .cloned() + .map(|k| (k, dancebox_runtime::EXISTENTIAL_DEPOSIT)), + ) .collect(), }, parachain_info: dancebox_runtime::ParachainInfoConfig { diff --git a/test/suites/dev-tanssi/staking/test_staking_rewards_balanced.ts b/test/suites/dev-tanssi/staking/test_staking_rewards_balanced.ts index 73974a1c0..a9a4c7022 100644 --- a/test/suites/dev-tanssi/staking/test_staking_rewards_balanced.ts +++ b/test/suites/dev-tanssi/staking/test_staking_rewards_balanced.ts @@ -134,8 +134,8 @@ describeSuite({ const events = await polkadotJs.query.system.events(); const reward = await fetchRewardAuthorOrchestrator(events); - // 20% plus 1 from rounding - const collatorPercentage = (20n * reward.balance.toBigInt()) / 100n + 1n; + // 20% collator percentage + const collatorPercentage = (20n * reward.balance.toBigInt()) / 100n; // Rounding const delegatorRewards = reward.balance.toBigInt() - collatorPercentage; diff --git a/test/suites/dev-tanssi/staking/test_staking_rewards_non_balanced.ts b/test/suites/dev-tanssi/staking/test_staking_rewards_non_balanced.ts index fce10f5c7..41ced4127 100644 --- a/test/suites/dev-tanssi/staking/test_staking_rewards_non_balanced.ts +++ b/test/suites/dev-tanssi/staking/test_staking_rewards_non_balanced.ts @@ -134,8 +134,8 @@ describeSuite({ const events = await polkadotJs.query.system.events(); const reward = await fetchRewardAuthorOrchestrator(events); - // 20% plus 1 from rounding - const collatorPercentage = (20n * reward.balance.toBigInt()) / 100n + 1n; + // 20% collator percentage + const collatorPercentage = (20n * reward.balance.toBigInt()) / 100n; // Rounding const delegatorRewards = reward.balance.toBigInt() - collatorPercentage;