Skip to content

Commit

Permalink
Notes for some tests to be removed and the rest re-located
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDegenDeveloper committed Apr 23, 2024
1 parent 736653f commit 67a9dbd
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/tests/option_auction_bid_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ use starknet::contract_address::ContractAddressZeroable;
use traits::Into;
use traits::TryInto;


// @note Moving these tests to option_round/bidding&clearing_price_tests

#[test]
#[available_gas(10000000)]
fn test_clearing_price_1() {
Expand Down
14 changes: 9 additions & 5 deletions src/tests/option_settle_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ use pitch_lake_starknet::tests::mock_market_aggregator::{
};
use pitch_lake_starknet::option_round::{IOptionRoundDispatcher, IOptionRoundDispatcherTrait};

// @note add test that unallocated decrements when round settles (premiums + unsold were rolled over)

// @dev this test belongs (and i think might already exist) in the premium tests, test OB cannot collect premium after round settles

// @note move this to option_round/payout_tests.cairo
// Test that an OB with 0 options gets 0 payout
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -82,8 +80,8 @@ fn test_user_with_no_options_gets_no_payout() {
); // option_bidder_buyer_2 never auction_place_bid in the auction, so should not be able to claim payout
}

// @note add test that eth transfers to next round on settlement

// @note move this to vault/option_settle_tests
// Test that collected premiums do not roll over to the next round
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -136,6 +134,7 @@ fn test_collected_premium_does_not_roll_over() {
assert(next_round_unallocated == deposit_amount_wei, 'Rollover amount wrong');
}

// @note move to vault/option_settle_tests
// Test that uncollected premiums roll over
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -180,6 +179,7 @@ fn test_remaining_liqudity_rolls_over() {
);
}

// @note move to option_round/payout_tests
#[test]
#[available_gas(10000000)]
fn test_option_payout_sends_eth() {
Expand Down Expand Up @@ -223,6 +223,7 @@ fn test_option_payout_sends_eth() {
assert_event_transfer(option_round.contract_address, option_bidder_buyer_1(), payout);
}

// @note move to vault/option_settle_test
#[test]
#[available_gas(10000000)]
fn test_option_payout_amount_index_higher_than_strike() {
Expand Down Expand Up @@ -263,6 +264,7 @@ fn test_option_payout_amount_index_higher_than_strike() {
assert(payout_balance == payout_balance_expected, 'expected payout doesnt match');
}

// @note move to vault/option_settle_tests
#[test]
#[available_gas(10000000)]
fn test_option_payout_amount_index_less_than_strike() {
Expand Down Expand Up @@ -301,6 +303,7 @@ fn test_option_payout_amount_index_less_than_strike() {
assert(payout_balance == 0, 'expected payout doesnt match');
}

// @note move to vault/option_settle_tests
#[test]
#[available_gas(10000000)]
fn test_option_payout_amount_index_at_strike() {
Expand Down Expand Up @@ -339,5 +342,6 @@ fn test_option_payout_amount_index_at_strike() {
assert(payout_balance == 0, 'expected payout doesnt match');
}
// @note Add test that payout is capped even if index >>> strike

// @note add test that unallocated decrements when round settles (premiums + unsold were rolled over)
// @note add test that eth transfers to next round on settlement

1 change: 1 addition & 0 deletions src/tests/pitch_lake_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ fn deploy() -> IPitchLakeDispatcher {
return IPitchLakeDispatcher { contract_address: address };
}

// @note move to vault/vault_tests
#[test]
#[available_gas(10000000)]
fn test_vault_type() {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/vault_liquidity_deposit_withdraw_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn test_deposit_liquidity_increments_rounds_total_unallocated() {
assert(next_total_deposits == init_total_deposits + deposit_amount_wei, 'should increment');
assert(final_total_deposits == next_total_deposits + topup_amount_wei, 'should increment');
assert_event_transfer(
liquidity_provider_1(), option_round_facade.contract_address() , topup_amount_wei
liquidity_provider_1(), option_round_facade.contract_address(), topup_amount_wei
);
}

Expand Down
4 changes: 3 additions & 1 deletion src/tests/vault_option_param_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ use pitch_lake_starknet::tests::utils::{
assert_no_events_left, deploy_pitch_lake
};

// @note move to option_round/initialize_params_tests.cario

#[test]
#[available_gas(10000000)]
fn test_strike_price_based_on_vault_types() {
Expand All @@ -66,7 +68,7 @@ fn test_strike_price_based_on_vault_types() {
// This means r1 will need to be manually initialized before its auction, and
// all following rounds will be automatically initialized when the current one settles.

// give more time for initial liquidity to collect, then initialize, then start the auction.
// @note Need to initialize r1 manually, then start the auction.

// let id, params = vault.initialize_first_round();

Expand Down
16 changes: 16 additions & 0 deletions src/tests/vault_option_round_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use pitch_lake_starknet::tests::mock_market_aggregator::{

/// Constructor Tests ///

// @note move this to vault/deployment_tests
// Test the vault's constructor
#[test]
#[available_gas(10000000)]
Expand All @@ -69,6 +70,7 @@ fn test_vault_constructor() {
assert(next_round_id == 1, 'next round should be 1');
}

// @note Move to vault/deployment_tests
// Test the option round constructor
// Test that round 0 deploys as settled, and round 1 deploys as open.
#[test]
Expand Down Expand Up @@ -122,8 +124,10 @@ fn test_option_round_constructor() {
);
}

// @note redundant, deposit test already covers this
// Test that deposits go into the open/next round
// @dev Move this test to deposit tests
// @note repeated in deposit tests
#[test]
#[available_gas(10000000)]
fn test_vault_deposits_go_into_the_next_round() {
Expand All @@ -149,6 +153,7 @@ fn test_vault_deposits_go_into_the_next_round() {

/// Auction Start Tests ///

// @note move to vault/start_auction_tests
// Test an auction starts and the round becomes the current round. Test that the
// next round is deployed.
#[test]
Expand Down Expand Up @@ -187,6 +192,7 @@ fn test_vault_start_auction_success() {
assert_event_auction_start(current_round_dispatcher.get_params().total_options_available);
}

// @note move to vault/start_auction_tests
// Test the next auction cannot start if the current round is Auctioning
#[test]
#[available_gas(10000000)]
Expand All @@ -209,6 +215,7 @@ fn test_vault_start_auction_while_current_round_Auctioning_failure() {
vault_dispatcher.start_auction();
}

// @note move to vault/start_auction_tests
// Test that an auction cannot start while the current is Running
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -241,6 +248,7 @@ fn test_vault_start_auction_while_current_round_Running_failure() {
vault_dispatcher.start_auction();
}

// @note move to vault/start_auction_tests
// Test that an auction cannot start before the round transition period is over
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -276,6 +284,7 @@ fn test_vault_start_auction_before_round_transition_period_is_over_failure() {
vault_dispatcher.start_auction();
}

// @note move to option_round/bidding_tests.cairo
// Test that OB cannot refund bids before auction settles
// @dev move this into auction/bid tests
#[test]
Expand Down Expand Up @@ -306,6 +315,7 @@ fn test_option_round_refund_unused_bids_too_early_failure() {
current_round_dispatcher.refund_unused_bids(option_bidder_buyer_1());
}

// @note move to option_round/clearing_price_tests
// Test that auction clearing price is 0 pre auction end
// @dev move to auction/bidding tests
#[test]
Expand Down Expand Up @@ -336,6 +346,7 @@ fn test_option_round_clearing_price_is_0_before_auction_end() {
assert(clearing_price == 0, 'should be 0 pre auction end');
}

// @note move to option_round/options_sold_tests
// Test that options sold is 0 pre auction end
// @dev move to auction/bid tests
#[test]
Expand Down Expand Up @@ -368,6 +379,7 @@ fn test_option_round_options_sold_before_auction_end_is_0() {

/// Auction End Tests ///

// @note move to vault/auction_end_tests
// Test that the auction clearing price is set post auction end, and state updates to Running
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -404,6 +416,7 @@ fn test_vault_end_auction_success() {
assert_event_auction_settle(current_round_dispatcher.get_auction_clearing_price());
}

// @note move to vault/auction_end_tests
// Test that the auction cannot be ended twice
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -437,6 +450,7 @@ fn test_option_round_end_auction_twice_failure() {

/// Round Settle Tests ///

// @note move to vault/option_settle_tests
// Test that the round settles
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -477,6 +491,7 @@ fn test_option_round_settle_success() {
assert(vault_dispatcher.current_option_round_id() == 1, 'current round should still be 1');
}

// @note move to vault/option_settle_tests
// Test that an option round cannot be settled twice
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -513,6 +528,7 @@ fn test_option_round_settle_twice_failure() {
}


// @note move to option_round/exercising_options_tests
// Test that OB cannot exercise options pre option settlement
// Move to auction/bidding tests
#[test]
Expand Down
5 changes: 5 additions & 0 deletions src/tests/vault_option_sequence_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fn assert_event_option_created(
assert_no_events_left(zero_address());
}

// @note move to option_round/bidding_tests
// Test OB cannot bid before the auction starts
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -81,6 +82,7 @@ fn test_bid_before_auction_starts_failure() {
next_round.place_bid(bid_amount, option_price);
}

// @note move to option_round/bidding_tests
// Test OB cannot bid after the auction end date (regardless if end_auction() is called)
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -112,6 +114,7 @@ fn test_bid_after_auction_ends_failure() {
current_round.place_bid(bid_amount, option_price);
}

// @note move to option_round/state_transition_tests
// Test auction cannot end if it has not started
#[test]
#[available_gas(10000000)]
Expand All @@ -136,6 +139,7 @@ fn test_auction_end_before_it_starts_failure() {
vault_dispatcher.settle_option_round();
}

// @note move to option_round/state_transition_tests
// Test auction cannot end before the auction end date
#[test]
#[available_gas(10000000)]
Expand All @@ -162,6 +166,7 @@ fn test_auction_end_before_end_date_failure() {
current_round.end_auction();
}

// @note move to option_round/state_transition_tests or /option_settle_tests
// Test options cannot settle before expiry date
#[test]
#[available_gas(10000000)]
Expand Down
3 changes: 3 additions & 0 deletions src/tests/vault_premium_to_vault_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use pitch_lake_starknet::tests::utils::{
use pitch_lake_starknet::option_round::{IOptionRoundDispatcher, IOptionRoundDispatcherTrait};


// redudnant
// Test that when LP withdraws premiums from the round, their unlocked liquidity decrements
// @dev these tests are basically already written in normal withdraw liquidity tests. they just test how is unlcocked once auction starts, need to add test that premiums become unlocked, and that you cannot withdraw more than unlocked
#[test]
Expand Down Expand Up @@ -74,6 +75,7 @@ fn test_withdraw_premiums_from_current_round() {
);
}

// @note move to vault/auction_end tests
// collateral balance of should be vault::get_unlocked_liquidity_for()
// @note Add test that unlocked is premium after auction, and is premium + next position if there is a deposit, and is premium + unsold options if there is any
#[test]
Expand Down Expand Up @@ -138,6 +140,7 @@ fn test_premium_collection_ratio_conversion_unallocated_pool_1() {
);
}

// @note move to vault/auction_end tests
#[test]
#[available_gas(10000000)]
fn test_premium_collection_ratio_conversion_unallocated_pool_2() {
Expand Down
5 changes: 4 additions & 1 deletion src/tests/vault_unallocated_to_collaterized_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use pitch_lake_starknet::tests::utils::{
vault_manager, weth_owner, mock_option_params
};

// @note move to vault/auction_end tests
// Test that LP can withdraw their liquidity during the round transition period (uncollaterized liquidity)
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -78,6 +79,7 @@ fn test_withdraw_liquidity_when_unlocked_success() {
);
}

// @note change/remove this, test needs to test deposit locks (unallocated->collateral) when auction start (vault/auction_start_tests)
// Test that LP cannot withdraw their liquidity while not in the round transition period
#[test]
#[available_gas(10000000)]
Expand All @@ -97,7 +99,7 @@ fn test_withdraw_liquidity_when_locked_failure() {
vault_dispatcher.withdraw_liquidity(deposit_amount_wei);
}


// @note move to vault/auction_start tests
// Test that round's unallocated liquidity becomes collateral when auction start (multiple LPs)
#[test]
#[available_gas(10000000)]
Expand Down Expand Up @@ -126,6 +128,7 @@ fn test_round_unallocated_becomes_collateral_when_auction_starts() {
assert(total_collateral == total_unallocated, 'all tokens shld be collaterized');
}

// @note move to vault/auction_start tests
// Test that LP's unallocated becomes collateral when auction start (multiple LPs)
#[test]
#[available_gas(10000000)]
Expand Down

0 comments on commit 67a9dbd

Please sign in to comment.