Skip to content

Commit 4c23692

Browse files
committed
add quote tokens setter test
1 parent 27ed1de commit 4c23692

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

src/constants.cairo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Constants for tokens
22
pub const DAI_DECIMALS: u8 = 18;
3+
pub const LUSD_DECIMALS: u8 = 18;
34
pub const USDC_DECIMALS: u8 = 6;
45
pub const USDT_DECIMALS: u8 = 6;
56
pub const WBTC_DECIMALS: u8 = 8;

src/tests/receptor/test_receptor.cairo

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
mod test_receptor {
22
use access_control::{IAccessControlDispatcher, IAccessControlDispatcherTrait};
3+
use opus::constants;
34
use opus::core::receptor::receptor as receptor_contract;
45
use opus::core::roles::receptor_roles;
56
use opus::core::shrine::shrine as shrine_contract;
@@ -51,6 +52,44 @@ mod test_receptor {
5152
receptor.set_oracle_extension(receptor_utils::mock_oracle_extension());
5253
}
5354

55+
#[test]
56+
fn test_set_quote_tokens() {
57+
let (_, receptor, _) = receptor_utils::receptor_deploy(Option::None);
58+
let mut spy = spy_events(SpyOn::One(receptor.contract_address));
59+
60+
start_prank(CheatTarget::One(receptor.contract_address), shrine_utils::admin());
61+
62+
let new_quote_tokens: Span<QuoteTokenInfo> = array![
63+
QuoteTokenInfo { address: receptor_utils::mock_dai(), decimals: constants::DAI_DECIMALS },
64+
QuoteTokenInfo { address: receptor_utils::mock_usdc(), decimals: constants::USDC_DECIMALS },
65+
QuoteTokenInfo { address: receptor_utils::mock_lusd(), decimals: constants::LUSD_DECIMALS },
66+
]
67+
.span();
68+
receptor.set_quote_tokens(new_quote_tokens);
69+
70+
assert_eq!(receptor.get_quote_tokens(), new_quote_tokens, "wrong quote tokens");
71+
72+
let expected_events = array![
73+
(
74+
receptor.contract_address,
75+
receptor_contract::Event::QuoteTokensUpdated(
76+
receptor_contract::QuoteTokensUpdated { quote_tokens: new_quote_tokens }
77+
)
78+
)
79+
];
80+
81+
spy.assert_emitted(@expected_events);
82+
}
83+
84+
#[test]
85+
#[should_panic(expected: ('Caller missing role',))]
86+
fn test_set_quote_tokens_unauthorized() {
87+
let (_, receptor, _) = receptor_utils::receptor_deploy(Option::None);
88+
89+
start_prank(CheatTarget::One(receptor.contract_address), common::badguy());
90+
receptor.set_quote_tokens(receptor_utils::quote_tokens());
91+
}
92+
5493
#[test]
5594
fn test_set_twap_duration_pass() {
5695
let (_, receptor, _) = receptor_utils::receptor_deploy(Option::None);

src/tests/receptor/utils.cairo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ pub mod receptor_utils {
3434
'mock DAI'.try_into().unwrap()
3535
}
3636

37+
pub fn mock_lusd() -> ContractAddress {
38+
'mock LUSD'.try_into().unwrap()
39+
}
40+
3741
pub fn mock_oracle_extension() -> ContractAddress {
3842
'mock oracle extension'.try_into().unwrap()
3943
}

0 commit comments

Comments
 (0)