Skip to content

Commit

Permalink
add to tests
Browse files Browse the repository at this point in the history
Signed-off-by: Charles Ferrell <[email protected]>
  • Loading branch information
ferrell-code committed Nov 19, 2023
1 parent cfa5224 commit eb17f95
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
9 changes: 7 additions & 2 deletions pallets/pallet-lottery/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ pub const CHARLIE: AccountId = 3;
pub const DAVE: AccountId = 4;
pub const EVE: AccountId = 5;
pub const TREASURY_ACCOUNT: AccountId = 10;

pub const JUMBO: Balance = 1_000_000_000_000;
pub const INIT_JUMBO_AMOUNT: Balance = 1_000 * JUMBO;
pub const INIT_V_MANTA_AMOUNT: Balance = JUMBO;
pub const V_MANTA_ID: CalamariAssetId = 8;
pub const JUMBO_ID: CalamariAssetId = 9;

Expand Down Expand Up @@ -681,13 +684,15 @@ impl ExtBuilder {
<MantaAssetConfig as AssetConfig<Test>>::FungibleLedger::deposit_minting(
JUMBO_ID,
&ALICE,
1_000 * JUMBO
INIT_JUMBO_AMOUNT,
)
);

assert_ok!(
<MantaAssetConfig as AssetConfig<Test>>::FungibleLedger::deposit_minting(
V_MANTA_ID, &ALICE, JUMBO
V_MANTA_ID,
&ALICE,
INIT_V_MANTA_AMOUNT
)
);

Expand Down
15 changes: 13 additions & 2 deletions pallets/pallet-lottery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use crate::{
mock::{
roll_one_block, roll_to, roll_to_round_begin, roll_to_round_end, AccountId, Assets,
Balance, Balances, ExtBuilder, Lottery, ParachainStaking, RuntimeOrigin as Origin, System,
Test, ALICE, BOB, CHARLIE, DAVE, EVE, TREASURY_ACCOUNT, V_MANTA_ID,
Test, ALICE, BOB, CHARLIE, DAVE, EVE, INIT_JUMBO_AMOUNT, INIT_V_MANTA_AMOUNT, JUMBO_ID,
TREASURY_ACCOUNT, V_MANTA_ID,
},
Config, Error, FarmingParameters,
};
Expand Down Expand Up @@ -1002,14 +1003,24 @@ fn farming_deposit_withdraw() {
.with_farming()
.build()
.execute_with(|| {
assert_eq!(INIT_JUMBO_AMOUNT, Assets::total_supply(JUMBO_ID));
assert_eq!(INIT_V_MANTA_AMOUNT, Assets::total_supply(V_MANTA_ID));

assert!(HIGH_BALANCE > balance);
assert_eq!(0, Lottery::staked_collators(BOB));
assert_ok!(Lottery::deposit(Origin::signed(ALICE), balance));
let alice_post_deposit_balance = Balances::free_balance(ALICE);
assert_eq!(balance, Lottery::staked_collators(BOB));
assert_eq!(balance, Lottery::total_pot());
assert_eq!(balance, Lottery::sum_of_deposits());
assert_eq!(balance, Assets::balance(V_MANTA_ID, ALICE));

// asset accounting is correct
assert_eq!(INIT_JUMBO_AMOUNT, Assets::total_supply(JUMBO_ID));
assert_eq!(
balance + INIT_V_MANTA_AMOUNT,
Assets::total_supply(V_MANTA_ID)
);
assert_eq!(0, Assets::balance(V_MANTA_ID, ALICE));

assert_ok!(Lottery::request_withdraw(
Origin::signed(ALICE),
Expand Down

0 comments on commit eb17f95

Please sign in to comment.