Skip to content

Commit

Permalink
Prefund pallet accounts in genesis to ensure they are always alive (#319
Browse files Browse the repository at this point in the history
)

* Prefund pallet accounts in genesis to ensure they are always alive

* Fix wrong staking test (there was no rounding)
  • Loading branch information
tmpolaczyk authored Nov 9, 2023
1 parent e1a9ead commit afe7210
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ fn testnet_genesis(
mock_container_chains: &[ParaId],
configuration: pallet_configuration::GenesisConfig<dancebox_runtime::Runtime>,
) -> 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
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit afe7210

Please sign in to comment.