From 67a9dbdaf2221e408988825aed27ff49b38bfd4b Mon Sep 17 00:00:00 2001 From: Matt Carter <96356887+0xDegenDeveloper@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:03:40 -0400 Subject: [PATCH] Notes for some tests to be removed and the rest re-located --- src/tests/option_auction_bid_test.cairo | 3 +++ src/tests/option_settle_test.cairo | 14 +++++++++----- src/tests/pitch_lake_test.cairo | 1 + .../vault_liquidity_deposit_withdraw_test.cairo | 2 +- src/tests/vault_option_param_test.cairo | 4 +++- src/tests/vault_option_round_test.cairo | 16 ++++++++++++++++ src/tests/vault_option_sequence_test.cairo | 5 +++++ src/tests/vault_premium_to_vault_test.cairo | 3 +++ .../vault_unallocated_to_collaterized_test.cairo | 5 ++++- 9 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/tests/option_auction_bid_test.cairo b/src/tests/option_auction_bid_test.cairo index a6412952..3ffda314 100644 --- a/src/tests/option_auction_bid_test.cairo +++ b/src/tests/option_auction_bid_test.cairo @@ -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() { diff --git a/src/tests/option_settle_test.cairo b/src/tests/option_settle_test.cairo index e78483ea..649271c4 100644 --- a/src/tests/option_settle_test.cairo +++ b/src/tests/option_settle_test.cairo @@ -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)] @@ -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)] @@ -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)] @@ -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() { @@ -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() { @@ -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() { @@ -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() { @@ -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 diff --git a/src/tests/pitch_lake_test.cairo b/src/tests/pitch_lake_test.cairo index 53172940..99c41ebc 100644 --- a/src/tests/pitch_lake_test.cairo +++ b/src/tests/pitch_lake_test.cairo @@ -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() { diff --git a/src/tests/vault_liquidity_deposit_withdraw_test.cairo b/src/tests/vault_liquidity_deposit_withdraw_test.cairo index 0038452b..8eb11427 100644 --- a/src/tests/vault_liquidity_deposit_withdraw_test.cairo +++ b/src/tests/vault_liquidity_deposit_withdraw_test.cairo @@ -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 ); } diff --git a/src/tests/vault_option_param_test.cairo b/src/tests/vault_option_param_test.cairo index 6b717b05..1773a0a8 100644 --- a/src/tests/vault_option_param_test.cairo +++ b/src/tests/vault_option_param_test.cairo @@ -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() { @@ -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(); diff --git a/src/tests/vault_option_round_test.cairo b/src/tests/vault_option_round_test.cairo index e6456ee4..9ae969b2 100644 --- a/src/tests/vault_option_round_test.cairo +++ b/src/tests/vault_option_round_test.cairo @@ -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)] @@ -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] @@ -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() { @@ -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] @@ -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)] @@ -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)] @@ -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)] @@ -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] @@ -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] @@ -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] @@ -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)] @@ -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)] @@ -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)] @@ -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)] @@ -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] diff --git a/src/tests/vault_option_sequence_test.cairo b/src/tests/vault_option_sequence_test.cairo index 409a8609..0315aae4 100644 --- a/src/tests/vault_option_sequence_test.cairo +++ b/src/tests/vault_option_sequence_test.cairo @@ -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)] @@ -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)] @@ -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)] @@ -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)] @@ -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)] diff --git a/src/tests/vault_premium_to_vault_test.cairo b/src/tests/vault_premium_to_vault_test.cairo index cb779d3e..a4ebf971 100644 --- a/src/tests/vault_premium_to_vault_test.cairo +++ b/src/tests/vault_premium_to_vault_test.cairo @@ -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] @@ -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] @@ -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() { diff --git a/src/tests/vault_unallocated_to_collaterized_test.cairo b/src/tests/vault_unallocated_to_collaterized_test.cairo index 6d329b36..4fc41847 100644 --- a/src/tests/vault_unallocated_to_collaterized_test.cairo +++ b/src/tests/vault_unallocated_to_collaterized_test.cairo @@ -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)] @@ -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)] @@ -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)] @@ -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)]