Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fpt token flag #130

Merged
merged 5 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions contracts/borrow-operations-contract/tests/failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use test_utils::{

#[tokio::test]
async fn fails_open_two_troves_of_same_coll_type() {
let (contracts, admin, _) = setup_protocol(100, 2, false).await;
let (contracts, admin, _) = setup_protocol(100, 2, false, false).await;

token_abi::mint_to_id(
&contracts.asset_contracts[0].asset,
Expand Down Expand Up @@ -185,7 +185,7 @@ async fn fails_open_two_troves_of_same_coll_type() {

#[tokio::test]
async fn fails_open_trove_under_minimum_collateral_ratio() {
let (contracts, admin, _) = setup_protocol(100, 2, false).await;
let (contracts, admin, _) = setup_protocol(100, 2, false, false).await;

token_abi::mint_to_id(
&contracts.asset_contracts[0].asset,
Expand Down Expand Up @@ -225,7 +225,7 @@ async fn fails_open_trove_under_minimum_collateral_ratio() {

#[tokio::test]
async fn fails_open_trove_under_min_usdf_required() {
let (contracts, admin, _) = setup_protocol(100, 2, false).await;
let (contracts, admin, _) = setup_protocol(100, 2, false, false).await;

token_abi::mint_to_id(
&contracts.asset_contracts[0].asset,
Expand Down Expand Up @@ -271,7 +271,7 @@ async fn fails_open_trove_under_min_usdf_required() {

#[tokio::test]
async fn fails_reduce_debt_under_min_usdf_required() {
let (contracts, admin, _) = setup_protocol(100, 2, false).await;
let (contracts, admin, _) = setup_protocol(100, 2, false, false).await;

token_abi::mint_to_id(
&contracts.asset_contracts[0].asset,
Expand Down Expand Up @@ -338,7 +338,7 @@ async fn fails_reduce_debt_under_min_usdf_required() {

#[tokio::test]
async fn fails_decrease_collateral_under_mcr() {
let (contracts, admin, _) = setup_protocol(100, 2, false).await;
let (contracts, admin, _) = setup_protocol(100, 2, false, false).await;

token_abi::mint_to_id(
&contracts.asset_contracts[0].asset,
Expand Down Expand Up @@ -400,7 +400,7 @@ async fn fails_decrease_collateral_under_mcr() {

#[tokio::test]
async fn fails_incorrect_token_as_collateral_or_repayment() {
let (contracts, admin, _) = setup_protocol(100, 2, false).await;
let (contracts, admin, _) = setup_protocol(100, 2, false, false).await;

let mock_fake_token = deploy_token(&admin).await;

Expand Down
16 changes: 8 additions & 8 deletions contracts/borrow-operations-contract/tests/success.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use test_utils::{

#[tokio::test]
async fn proper_creating_trove() {
let (contracts, admin, _) = setup_protocol(100, 2, false).await;
let (contracts, admin, _) = setup_protocol(100, 2, false, false).await;

token_abi::mint_to_id(
&contracts.asset_contracts[0].asset,
Expand Down Expand Up @@ -173,7 +173,7 @@ async fn proper_creating_trove() {

#[tokio::test]
async fn proper_increase_collateral() {
let (contracts, admin, _) = setup_protocol(100, 2, false).await;
let (contracts, admin, _) = setup_protocol(100, 2, false, false).await;

let _ = token_abi::mint_to_id(
&contracts.asset_contracts[0].asset,
Expand Down Expand Up @@ -323,7 +323,7 @@ async fn proper_increase_collateral() {

#[tokio::test]
async fn proper_decrease_collateral() {
let (contracts, admin, _) = setup_protocol(100, 2, false).await;
let (contracts, admin, _) = setup_protocol(100, 2, false, false).await;

let balance = 5000 * PRECISION;
token_abi::mint_to_id(
Expand Down Expand Up @@ -490,7 +490,7 @@ async fn proper_decrease_collateral() {

#[tokio::test]
async fn proper_increase_debt() {
let (contracts, admin, _) = setup_protocol(100, 2, false).await;
let (contracts, admin, _) = setup_protocol(100, 2, false, false).await;

let balance = 5000 * PRECISION;
token_abi::mint_to_id(
Expand Down Expand Up @@ -658,7 +658,7 @@ async fn proper_increase_debt() {

#[tokio::test]
async fn proper_decrease_debt() {
let (contracts, admin, _) = setup_protocol(100, 2, false).await;
let (contracts, admin, _) = setup_protocol(100, 2, false, false).await;

let balance = 5000 * PRECISION;
token_abi::mint_to_id(
Expand Down Expand Up @@ -837,7 +837,7 @@ async fn proper_decrease_debt() {

#[tokio::test]
async fn proper_open_multiple_troves() {
let (contracts, _admin, mut wallets) = setup_protocol(100, 4, false).await;
let (contracts, _admin, mut wallets) = setup_protocol(100, 4, false, false).await;

let wallet1 = wallets.pop().unwrap();
let wallet2 = wallets.pop().unwrap();
Expand Down Expand Up @@ -986,7 +986,7 @@ async fn proper_open_multiple_troves() {

#[tokio::test]
async fn proper_close_trove() {
let (contracts, admin, mut wallets) = setup_protocol(100, 4, false).await;
let (contracts, admin, mut wallets) = setup_protocol(100, 4, false, false).await;

let wallet1 = wallets.pop().unwrap();
let wallet2 = wallets.pop().unwrap();
Expand Down Expand Up @@ -1181,7 +1181,7 @@ async fn proper_close_trove() {

#[tokio::test]
async fn proper_creating_trove_with_2nd_asset() {
let (contracts, admin, mut wallets) = setup_protocol(100, 2, true).await;
let (contracts, admin, mut wallets) = setup_protocol(100, 2, true, false).await;

let wallet2 = wallets.pop().unwrap();

Expand Down
8 changes: 4 additions & 4 deletions contracts/community-issuance-contract/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn abs_dif(a: u64, b: u64) -> u64 {

#[tokio::test]
async fn test_emissions() {
let (contracts, admin, _wallets) = setup_protocol(10, 4, false).await;
let (contracts, admin, _wallets) = setup_protocol(10, 4, false, false).await;
let provider = admin.provider().unwrap();
let fpt_asset_id = contracts
.fpt_token
Expand Down Expand Up @@ -159,7 +159,7 @@ async fn test_emissions() {

#[tokio::test]
async fn test_admin_start_rewards_increase_transition() {
let (contracts, admin, mut _wallets) = setup_protocol(10, 4, false).await;
let (contracts, admin, mut _wallets) = setup_protocol(10, 4, false, false).await;
let provider = admin.provider().unwrap();
let fpt_asset_id = contracts
.fpt_token
Expand Down Expand Up @@ -277,7 +277,7 @@ async fn test_admin_start_rewards_increase_transition() {

#[tokio::test]
async fn test_public_start_rewards_increase_transition_after_deadline() {
let (contracts, admin, mut wallets) = setup_protocol(10, 4, false).await;
let (contracts, admin, mut wallets) = setup_protocol(10, 4, false, false).await;
let provider = admin.provider().unwrap();
let fpt_asset_id = contracts
.fpt_token
Expand Down Expand Up @@ -401,7 +401,7 @@ async fn test_public_start_rewards_increase_transition_after_deadline() {

#[tokio::test]
async fn test_emissions_multiple_deposits() {
let (contracts, admin, mut wallets) = setup_protocol(100, 4, false).await;
let (contracts, admin, mut wallets) = setup_protocol(100, 4, false, false).await;

let provider = admin.provider().unwrap();
let fpt_asset_id = contracts
Expand Down
17 changes: 12 additions & 5 deletions contracts/fpt-staking-contract/tests/failure.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
use fuels::{prelude::*, types::Identity};
use test_utils::{
data_structures::PRECISION,
interfaces::{fpt_staking::fpt_staking_abi, token::token_abi},
interfaces::{
fpt_staking::fpt_staking_abi,
token::{token_abi, Token},
},
setup::common::setup_protocol,
};

#[tokio::test]
async fn fails_unstake_wrong_amount() {
let (contracts, admin, _wallets) = setup_protocol(10, 4, false).await;
let (contracts, admin, mut _wallets) = setup_protocol(10, 4, false, true).await;

let mock_token = Token::new(
contracts.fpt_token.contract_id().clone(),
_wallets.pop().unwrap().clone(),
);
token_abi::mint_to_id(
&contracts.fpt,
&mock_token,
5_000 * PRECISION,
Identity::Address(admin.address().into()),
)
.await;

fpt_staking_abi::stake(&contracts.fpt_staking, &contracts.fpt, 1 * PRECISION).await;
fpt_staking_abi::stake(&contracts.fpt_staking, &mock_token, 1 * PRECISION).await;

fpt_staking_abi::unstake(
&contracts.fpt_staking,
&contracts.usdf,
&contracts.asset_contracts[0].asset,
&contracts.fpt,
&mock_token,
1_000 * PRECISION,
)
.await
Expand Down
37 changes: 23 additions & 14 deletions contracts/fpt-staking-contract/tests/success.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use test_utils::{
oracle::oracle_abi,
protocol_manager::{protocol_manager_abi, ProtocolManager},
pyth_oracle::{pyth_oracle_abi, pyth_price_feed, PYTH_TIMESTAMP},
token::token_abi,
token::{token_abi, Token},
},
setup::common::setup_protocol,
};

#[tokio::test]
async fn proper_intialize() {
let (contracts, admin, _wallets) = setup_protocol(10, 4, false).await;
let (contracts, admin, _wallets) = setup_protocol(10, 4, false, true).await;
println!("admin address {:?}", admin.address());
token_abi::mint_to_id(
&contracts.asset_contracts[0].asset,
Expand Down Expand Up @@ -43,24 +43,28 @@ async fn proper_intialize() {

#[tokio::test]
async fn proper_staking_deposit() {
let (contracts, admin, _wallets) = setup_protocol(10, 4, false).await;
let (contracts, admin, mut _wallets) = setup_protocol(10, 4, false, true).await;

let provider = admin.provider().unwrap();

let fpt_asset_id = contracts
.fpt
.fpt_token
.contract_id()
.asset_id(&AssetId::zeroed().into())
.into();

let mock_token = Token::new(
contracts.fpt_token.contract_id().clone(),
_wallets.pop().unwrap().clone(),
);
token_abi::mint_to_id(
&contracts.fpt,
&mock_token,
5 * PRECISION,
Identity::Address(admin.address().into()),
)
.await;

fpt_staking_abi::stake(&contracts.fpt_staking, &contracts.fpt, 1 * PRECISION).await;
fpt_staking_abi::stake(&contracts.fpt_staking, &mock_token, 1 * PRECISION).await;

let fpt_balance = provider
.get_asset_balance(admin.address().into(), fpt_asset_id)
Expand All @@ -72,12 +76,12 @@ async fn proper_staking_deposit() {

#[tokio::test]
async fn proper_staking_multiple_positions() {
let (contracts, admin, mut wallets) = setup_protocol(10, 4, false).await;
let (contracts, admin, mut wallets) = setup_protocol(10, 4, false, true).await;

let provider = admin.provider().unwrap();

let fpt_asset_id = contracts
.fpt
.fpt_token
.contract_id()
.asset_id(&AssetId::zeroed().into())
.into();
Expand All @@ -91,15 +95,20 @@ async fn proper_staking_multiple_positions() {
let healthy_wallet2 = wallets.pop().unwrap();
let healthy_wallet3 = wallets.pop().unwrap();

let mock_token = Token::new(
contracts.fpt_token.contract_id().clone(),
healthy_wallet1.clone(),
);

token_abi::mint_to_id(
&contracts.fpt,
&mock_token,
5 * PRECISION,
Identity::Address(healthy_wallet1.address().into()),
)
.await;

token_abi::mint_to_id(
&contracts.fpt,
&mock_token,
5 * PRECISION,
Identity::Address(healthy_wallet2.address().into()),
)
Expand All @@ -115,9 +124,9 @@ async fn proper_staking_multiple_positions() {
healthy_wallet2.clone(),
);

fpt_staking_abi::stake(&fpt_staking_healthy_wallet1, &contracts.fpt, 1 * PRECISION).await;
fpt_staking_abi::stake(&fpt_staking_healthy_wallet1, &mock_token, 1 * PRECISION).await;

fpt_staking_abi::stake(&fpt_staking_healthy_wallet2, &contracts.fpt, 1 * PRECISION).await;
fpt_staking_abi::stake(&fpt_staking_healthy_wallet2, &mock_token, 1 * PRECISION).await;

let fpt_balance_user1 = provider
.get_asset_balance(healthy_wallet1.address().into(), fpt_asset_id)
Expand Down Expand Up @@ -238,7 +247,7 @@ async fn proper_staking_multiple_positions() {
&fpt_staking_healthy_wallet1,
&contracts.usdf,
&contracts.asset_contracts[0].asset,
&contracts.fpt,
&mock_token,
500_000_000,
)
.await;
Expand All @@ -247,7 +256,7 @@ async fn proper_staking_multiple_positions() {
&fpt_staking_healthy_wallet2,
&contracts.usdf,
&contracts.asset_contracts[0].asset,
&contracts.fpt,
&mock_token,
500_000_000,
)
.await;
Expand Down
2 changes: 1 addition & 1 deletion contracts/fpt-token-contract/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use test_utils::{

#[tokio::test]
async fn proper_intialize() {
let (contracts, admin, _wallets) = setup_protocol(10, 4, false).await;
let (contracts, admin, _wallets) = setup_protocol(10, 4, false, false).await;
let provider = admin.provider().unwrap();
let fpt_asset_id = contracts
.fpt_token
Expand Down
2 changes: 1 addition & 1 deletion contracts/hint-helper-contract/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use test_utils::{
#[tokio::test]
async fn proper_hint_generations() {
// let (active_pool, _admin) = get_contract_instance().await;
let (contracts, _admin, mut wallets) = setup_protocol(100, 20, false).await;
let (contracts, _admin, mut wallets) = setup_protocol(100, 20, false, false).await;
let wallet = wallets.pop().unwrap();

let hint_helper = deploy_hint_helper(&wallet).await;
Expand Down
2 changes: 1 addition & 1 deletion contracts/multi-trove-getter-contract/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use test_utils::{
#[ignore = "MemoryWriteOverlap Fuel Error in current version"]
#[tokio::test]
async fn proper_hint_generations() {
let (contracts, _admin, mut wallets) = setup_protocol(100, 20, false).await;
let (contracts, _admin, mut wallets) = setup_protocol(100, 20, false, false).await;
let wallet = wallets.pop().unwrap();

let hint_helper = deploy_hint_helper(&wallet).await;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use test_utils::{

#[tokio::test]
async fn proper_redemption_from_partially_closed() {
let (contracts, _admin, mut wallets) = setup_protocol(10, 5, true).await;
let (contracts, _admin, mut wallets) = setup_protocol(10, 5, true, false).await;

let healthy_wallet1 = wallets.pop().unwrap();
let healthy_wallet2 = wallets.pop().unwrap();
Expand Down Expand Up @@ -233,7 +233,7 @@ async fn proper_redemption_from_partially_closed() {

#[tokio::test]
async fn proper_redemption_with_a_trove_closed_fully() {
let (contracts, _admin, mut wallets) = setup_protocol(10, 5, true).await;
let (contracts, _admin, mut wallets) = setup_protocol(10, 5, true, false).await;

let healthy_wallet1 = wallets.pop().unwrap();
let healthy_wallet2 = wallets.pop().unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use test_utils::{

#[tokio::test]
async fn proper_multi_collateral_redemption_from_partially_closed() {
let (contracts, _admin, mut wallets) = setup_protocol(10, 5, true).await;
let (contracts, _admin, mut wallets) = setup_protocol(10, 5, true, false).await;

let healthy_wallet1 = wallets.pop().unwrap();
let healthy_wallet2 = wallets.pop().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions contracts/stability-pool-contract/tests/functions/failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use test_utils::{

#[tokio::test]
async fn fails_fake_usdf_deposit() {
let (contracts, admin, _wallets) = setup_protocol(10, 4, false).await;
let (contracts, admin, _wallets) = setup_protocol(10, 4, false, false).await;

let fake_usdf = deploy_usdf_token(&admin).await;

Expand Down Expand Up @@ -44,7 +44,7 @@ async fn fails_fake_usdf_deposit() {

#[tokio::test]
async fn fails_unauthorized() {
let (contracts, _admin, mut wallets) = setup_protocol(10, 4, false).await;
let (contracts, _admin, mut wallets) = setup_protocol(10, 4, false, false).await;

let attacker = wallets.pop().unwrap();

Expand Down
Loading
Loading