-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
9 changed files
with
332 additions
and
81 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 |
---|---|---|
|
@@ -4,3 +4,4 @@ mod instantiate; | |
mod mock_querier; | ||
mod rewards; | ||
mod stake_unstake; | ||
mod modify_asset; |
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,76 @@ | ||
use crate::models::ModifyAssetPair; | ||
use crate::tests::helpers::{modify_asset, setup_contract, stake}; | ||
use alliance_protocol::error::ContractError; | ||
use cosmwasm_std::{Response, testing::mock_dependencies}; | ||
use cw_asset::AssetInfo; | ||
|
||
#[test] | ||
fn test_stake_non_whitelisted_asset() { | ||
let mut deps = mock_dependencies(); | ||
setup_contract(deps.as_mut()); | ||
|
||
let err = stake(deps.as_mut(), "user1", 100, "native_asset").unwrap_err(); | ||
|
||
assert_eq!( | ||
err, | ||
ContractError::AssetNotWhitelisted("native:native_asset".to_string()) | ||
); | ||
} | ||
|
||
#[test] | ||
fn test_remove_asset() { | ||
let mut deps = mock_dependencies(); | ||
setup_contract(deps.as_mut()); | ||
|
||
// Whitelist the pair aWHALE-uluna successfully | ||
let res = modify_asset( | ||
deps.as_mut(), | ||
Vec::from([ModifyAssetPair { | ||
asset_info: AssetInfo::Native("aWHALE".to_string()), | ||
reward_asset_info: Some(AssetInfo::Native("uluna".to_string())), | ||
delete: false, | ||
}]), | ||
) | ||
.unwrap(); | ||
assert_eq!( | ||
res, | ||
Response::default() | ||
.add_attributes(vec![("action", "modify_asset"), ("asset", "native:aWHALE"),]) | ||
); | ||
|
||
// Try to remove the asset aWHALE, it should error because | ||
// the reward_asset_info is not defined | ||
let err = modify_asset( | ||
deps.as_mut(), | ||
Vec::from([ModifyAssetPair { | ||
asset_info: AssetInfo::Native("aWHALE".to_string()), | ||
reward_asset_info: None, | ||
delete: true, | ||
}]), | ||
) | ||
.unwrap_err(); | ||
assert_eq!( | ||
err, | ||
ContractError::MissingRewardAsset("native:aWHALE".to_string()) | ||
); | ||
|
||
// Remove the asset pair aWHALE-uluna successfully because both | ||
// assets are defined | ||
let res = modify_asset( | ||
deps.as_mut(), | ||
Vec::from([ModifyAssetPair { | ||
asset_info: AssetInfo::Native("aWHALE".to_string()), | ||
reward_asset_info: Some(AssetInfo::Native("uluna".to_string())), | ||
delete: true, | ||
}]), | ||
) | ||
.unwrap(); | ||
assert_eq!( | ||
res, | ||
Response::default().add_attributes(vec![ | ||
("action", "modify_asset"), | ||
("asset", "native:aWHALE"), | ||
("to_remove", "true"), | ||
]) | ||
); | ||
} |
Oops, something went wrong.