From f4c26435aee60bed576ba3dd60c928e935bcdd36 Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Fri, 04 Jun 2021 13:03:39 +0000 Subject: [PATCH] SBP M2 review: comments on inflation pallet's tests --- --- a/pallets/inflation/src/tests.rs +++ b/pallets/inflation/src/tests.rs @@ -99,7 +99,9 @@ // BlockInflation should be set after 1st block and // first inflation deposit should be equal to BlockInflation Inflation::on_initialize(1); - assert!(Inflation::block_inflation() > 0); + + // SBP M2 review: Verify expected block inflation for year 1 + assert_eq!(Inflation::block_inflation(), 1901); assert_eq!(Balances::free_balance(1234) - initial_issuance, Inflation::block_inflation()); }); } @@ -140,11 +142,24 @@ Inflation::on_initialize(1); let block_inflation_year_0 = Inflation::block_inflation(); + // SBP M2 review: go through all the block inflations for year 1, + // total issuance will be updated accordingly + for block in (100..YEAR).step_by(100) { + Inflation::on_initialize(block); + } + assert_eq!( + initial_issuance + (1901 * (YEAR / 100)), + >::total_issuance() + ); + Inflation::on_initialize(YEAR); let block_inflation_year_1 = Inflation::block_inflation(); + // SBP M2 review: Verify expected block inflation for year 2 + assert_eq!(block_inflation_year_1, 1952); + // SBP M2 review: this is actually not true // Assert that year 1 inflation is less than year 0 - assert!(block_inflation_year_0 > block_inflation_year_1); + // assert!(block_inflation_year_0 > block_inflation_year_1); }); } @@ -162,6 +177,7 @@ Inflation::on_initialize(YEAR * year); let block_inflation_year_after = Inflation::block_inflation(); + // SBP M2 review: this is actually not true (not for the first few years) // Assert that next year inflation is less than previous year inflation assert!(block_inflation_year_before > block_inflation_year_after); } -- gitstuff