forked from DA0-DA0/dao-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f05541b
commit 988cf5d
Showing
6 changed files
with
163 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
use crate::abc::{ | ||
ClosedConfig, CommonsPhaseConfig, CurveType, HatchConfig, MinMax, OpenConfig, ReserveToken, | ||
SupplyToken, | ||
}; | ||
use crate::msg::InstantiateMsg; | ||
use cosmwasm_std::{ | ||
testing::{mock_env, mock_info, MockApi, MockQuerier, MockStorage}, | ||
Decimal, OwnedDeps, Uint128, | ||
}; | ||
|
||
use crate::contract; | ||
use crate::contract::CwAbcResult; | ||
use cosmwasm_std::DepsMut; | ||
use std::marker::PhantomData; | ||
use token_bindings::{Metadata, TokenFactoryQuery}; | ||
|
||
pub(crate) mod prelude { | ||
pub use super::{ | ||
default_instantiate_msg, default_supply_metadata, mock_tf_dependencies, TEST_CREATOR, | ||
TEST_RESERVE_DENOM, TEST_SUPPLY_DENOM, _TEST_BUYER, _TEST_INVESTOR, | ||
}; | ||
pub use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; | ||
pub use speculoos::prelude::*; | ||
} | ||
|
||
pub const TEST_RESERVE_DENOM: &str = "satoshi"; | ||
pub const TEST_CREATOR: &str = "creator"; | ||
pub const _TEST_INVESTOR: &str = "investor"; | ||
pub const _TEST_BUYER: &str = "buyer"; | ||
|
||
pub const TEST_SUPPLY_DENOM: &str = "subdenom"; | ||
|
||
pub fn default_supply_metadata() -> Metadata { | ||
Metadata { | ||
name: Some("Bonded".to_string()), | ||
symbol: Some("EPOXY".to_string()), | ||
description: None, | ||
denom_units: vec![], | ||
base: None, | ||
display: None, | ||
} | ||
} | ||
|
||
pub fn default_instantiate_msg( | ||
decimals: u8, | ||
reserve_decimals: u8, | ||
curve_type: CurveType, | ||
) -> InstantiateMsg { | ||
InstantiateMsg { | ||
token_issuer_code_id: 1, | ||
supply: SupplyToken { | ||
subdenom: TEST_SUPPLY_DENOM.to_string(), | ||
metadata: Some(default_supply_metadata()), | ||
decimals, | ||
}, | ||
reserve: ReserveToken { | ||
denom: TEST_RESERVE_DENOM.to_string(), | ||
decimals: reserve_decimals, | ||
}, | ||
phase_config: CommonsPhaseConfig { | ||
hatch: HatchConfig { | ||
initial_raise: MinMax { | ||
min: Uint128::one(), | ||
max: Uint128::from(1000000u128), | ||
}, | ||
initial_price: Uint128::one(), | ||
initial_allocation_ratio: Decimal::percent(10u64), | ||
exit_tax: Decimal::zero(), | ||
}, | ||
open: OpenConfig { | ||
allocation_percentage: Decimal::percent(10u64), | ||
exit_tax: Decimal::percent(10u64), | ||
}, | ||
closed: ClosedConfig {}, | ||
}, | ||
hatcher_allowlist: None, | ||
curve_type, | ||
} | ||
} | ||
|
||
pub fn mock_init(deps: DepsMut<TokenFactoryQuery>, init_msg: InstantiateMsg) -> CwAbcResult { | ||
let info = mock_info(TEST_CREATOR, &[]); | ||
let env = mock_env(); | ||
contract::instantiate(deps, env, info, init_msg) | ||
} | ||
|
||
pub fn mock_tf_dependencies( | ||
) -> OwnedDeps<MockStorage, MockApi, MockQuerier<TokenFactoryQuery>, TokenFactoryQuery> { | ||
OwnedDeps { | ||
storage: MockStorage::default(), | ||
api: MockApi::default(), | ||
querier: MockQuerier::<TokenFactoryQuery>::new(&[]), | ||
custom_query_type: PhantomData::<TokenFactoryQuery>, | ||
} | ||
} |