Skip to content

Commit

Permalink
prepare tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chralt98 committed Oct 11, 2023
1 parent 22887b9 commit 929a836
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion zrml/parimutuel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ where
report: None,
resolved_outcome: None,
scoring_rule: ScoringRule::Parimutuel,
status: MarketStatus::Disputed,
status: MarketStatus::Active,
bonds: MarketBonds::default(),
}
}
6 changes: 3 additions & 3 deletions zrml/parimutuel/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use frame_support::{
parameter_types,
traits::{Everything, OnFinalize, OnInitialize},
};
use sp_runtime::Perbill;
use orml_traits::MultiCurrency;
use sp_runtime::{
testing::Header,
Expand All @@ -55,8 +56,6 @@ pub const FEE_ACCOUNT: AccountIdTest = 42;

pub const INITIAL_BALANCE: u128 = 1_000 * BASE;

pub const EXTERNAL_FEES: Balance = CENT;

parameter_types! {
pub const FeeAccount: AccountIdTest = FEE_ACCOUNT;
}
Expand All @@ -78,7 +77,8 @@ where
account: &Self::AccountId,
amount: Self::Balance,
) -> Self::Balance {
let fees = amount.saturated_into::<BalanceOf<T>>() * EXTERNAL_FEES.saturated_into();
let fees =
Perbill::from_rational(1u64, 100u64).mul_floor(amount.saturated_into::<BalanceOf<T>>());
let _ = T::AssetManager::transfer(asset, account, &F::get(), fees);
fees
}
Expand Down
27 changes: 23 additions & 4 deletions zrml/parimutuel/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,37 @@
#![cfg(test)]

use crate::{mock::*, *};
use frame_support::assert_ok;
use zeitgeist_primitives::types::{Asset, MarketType, Outcome, MarketStatus};
use zrml_market_commons::Markets;

#[test]
fn buy_shares() {
fn buy_works() {
ExtBuilder::default().build().execute_with(|| {
Markets::<Runtime>::insert(0, market_mock::<Runtime>());
let market_id = 0;
let mut market = market_mock::<Runtime>();
market.market_type = MarketType::Categorical(10u16);
market.status = MarketStatus::Active;
Markets::<Runtime>::insert(market_id, market);

let asset = Asset::ParimutuelShare(Outcome::CategoricalOutcome(market_id, 0u16));
let amount = <Runtime as Config>::MinBetSize::get();
assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount,));
});
}

#[test]
fn claim_rewards_works() {
ExtBuilder::default().build().execute_with(|| {
let market_id = 0;
Markets::<Runtime>::insert(market_id, market_mock::<Runtime>());
});
}

#[test]
fn claim_rewards() {
fn refund_pot_works() {
ExtBuilder::default().build().execute_with(|| {
Markets::<Runtime>::insert(0, market_mock::<Runtime>());
let market_id = 0;
Markets::<Runtime>::insert(market_id, market_mock::<Runtime>());
});
}

0 comments on commit 929a836

Please sign in to comment.