From 9b94d8fb2a08b8d9e948c2d16ac676cd89a15707 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Tue, 13 Jun 2023 21:25:12 +0200 Subject: [PATCH] fix initial TotalIssuance --- node/src/chain_spec/gdev.rs | 2 +- runtime/gdev/tests/common/mod.rs | 17 +++++++++++++++-- runtime/gdev/tests/integration_tests.rs | 8 ++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/node/src/chain_spec/gdev.rs b/node/src/chain_spec/gdev.rs index a943c06db..cf90e9805 100644 --- a/node/src/chain_spec/gdev.rs +++ b/node/src/chain_spec/gdev.rs @@ -416,7 +416,7 @@ fn gen_genesis_for_local_chain( .map(|(i, keys)| (i as u32 + 1, (keys.0.clone(), i < initial_authorities_len))) .collect(), }, - // Necessary to initialize TotalIssuence + // Necessary to initialize TotalIssuance balances: BalancesConfig { balances: initial_identities .iter() diff --git a/runtime/gdev/tests/common/mod.rs b/runtime/gdev/tests/common/mod.rs index 8f630fdd0..d78eee049 100644 --- a/runtime/gdev/tests/common/mod.rs +++ b/runtime/gdev/tests/common/mod.rs @@ -170,7 +170,17 @@ impl ExtBuilder { .unwrap();*/ pallet_duniter_account::GenesisConfig::<Runtime> { - accounts: initial_accounts, + accounts: initial_accounts.clone(), + } + .assimilate_storage(&mut t) + .unwrap(); + + // Necessary to initialize TotalIssuance + pallet_balances::GenesisConfig::<Runtime> { + balances: initial_accounts + .iter() + .map(|(key, balance)| (key.clone(), balance.balance.clone())) + .collect(), } .assimilate_storage(&mut t) .unwrap(); @@ -268,7 +278,10 @@ impl ExtBuilder { pallet_universal_dividend::GenesisConfig::<Runtime> { first_reeval: 100, first_ud: 1_000, - initial_monetary_mass: 0, + initial_monetary_mass: initial_accounts + .iter() + .map(|(_, balance)| balance.balance.clone()) + .sum(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index 282180349..534964b4d 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -257,7 +257,7 @@ fn test_ud_claimed_membership_on_and_off() { pallet_universal_dividend::Event::NewUdCreated { amount: 1000, index: 1, - monetary_mass: 4000, + monetary_mass: 4_000 + 4_000, // Initial + produced members_count: 4, }, )); @@ -289,8 +289,8 @@ fn test_ud_claimed_membership_on_and_off() { pallet_universal_dividend::Event::NewUdCreated { amount: 1000, index: 2, - monetary_mass: 7000, // 4000 + 3 × 1000 - members_count: 3, // alice is not member at this UD + monetary_mass: 11_000, // 4000 + 4000 + 3 × 1000 + members_count: 3, // alice is not member at this UD }, )); @@ -308,7 +308,7 @@ fn test_ud_claimed_membership_on_and_off() { pallet_universal_dividend::Event::NewUdCreated { amount: 1000, index: 3, - monetary_mass: 11000, // 7000 + 4 × 1000 + monetary_mass: 15000, // 11000 + 4 × 1000 members_count: 4, // alice is member again at this UD }, )); -- GitLab