Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chopan123 committed Dec 11, 2024
1 parent 6d647a5 commit a67c1c5
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions apps/contracts/strategies/hodl/src/test/hodl/deposit.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::test::create_hodl_strategy;
use crate::test::HodlStrategyTest;
use crate::test::StrategyError;

// test deposit with negative amount
#[test]
fn deposit_with_negative_amount() {
Expand All @@ -27,7 +26,6 @@ fn deposit_mock_auths() {
fn deposit_and_withdrawal_flow() {
let test = HodlStrategyTest::setup();

// initialize
let strategy = create_hodl_strategy(&test.env, &test.token.address);

// Initial user token balance
Expand Down Expand Up @@ -76,36 +74,30 @@ fn deposit_and_withdrawal_flow() {
#[test]
fn deposit_from_a_withdrawal_from_b() {
let test = HodlStrategyTest::setup();

let result = test.strategy.try_deposit(&10_000_000, &test.user);
assert_eq!(result, Err(Ok(StrategyError::NotInitialized)));

// initialize
let init_fn_args: Vec<Val> = (0,).into_val(&test.env);
test.strategy.initialize(&test.token.address, &init_fn_args);
let strategy = create_hodl_strategy(&test.env, &test.token.address);

// Initial user token balance
let balance = test.token.balance(&test.user);

let amount = 123456;

// Deposit amount of token from the user to the strategy
test.strategy.deposit(&amount, &test.user);
strategy.deposit(&amount, &test.user);

let balance_after_deposit = test.token.balance(&test.user);
assert_eq!(balance_after_deposit, balance - amount);

// Reading strategy balance
let strategy_balance_after_deposit = test.token.balance(&test.strategy.address);
let strategy_balance_after_deposit = test.token.balance(&strategy.address);
assert_eq!(strategy_balance_after_deposit, amount);

// Reading user balance on strategy contract
let user_balance_on_strategy = test.strategy.balance(&test.user);
let user_balance_on_strategy = strategy.balance(&test.user);
assert_eq!(user_balance_on_strategy, amount);


let amount_to_withdraw = 100_000;
// Withdrawing token from the strategy to user
let result = test.strategy.try_withdraw(&amount_to_withdraw, &test.user1);
let result = strategy.try_withdraw(&amount_to_withdraw, &test.user1);
assert_eq!(result, Err(Ok(StrategyError::InsufficientBalance)));
}

0 comments on commit a67c1c5

Please sign in to comment.