@@ -2008,7 +2008,9 @@ contract SchedulerTest is Test, SchedulerEvents, PulseSchedulerTestUtils {
20082008 // Required to receive ETH when withdrawing funds
20092009 receive () external payable {}
20102010
2011- function testUpdateSubscriptionRemovesPriceUpdatesForRemovedPriceIds () public {
2011+ function testUpdateSubscriptionRemovesPriceUpdatesForRemovedPriceIds ()
2012+ public
2013+ {
20122014 // 1. Setup: Add subscription with 3 price feeds, update prices
20132015 uint8 numInitialFeeds = 3 ;
20142016 uint256 subscriptionId = addTestSubscriptionWithFeeds (
@@ -2021,42 +2023,49 @@ contract SchedulerTest is Test, SchedulerEvents, PulseSchedulerTestUtils {
20212023 // Get initial price IDs and create mock price feeds
20222024 bytes32 [] memory initialPriceIds = createPriceIds (numInitialFeeds);
20232025 uint64 publishTime = SafeCast.toUint64 (block .timestamp );
2024-
2026+
20252027 // Setup and perform initial price update
2026- (PythStructs.PriceFeed[] memory priceFeeds , uint64 [] memory slots ) =
2027- createMockPriceFeedsWithSlots (publishTime, numInitialFeeds);
2028+ (
2029+ PythStructs.PriceFeed[] memory priceFeeds ,
2030+ uint64 [] memory slots
2031+ ) = createMockPriceFeedsWithSlots (publishTime, numInitialFeeds);
20282032 mockParsePriceFeedUpdatesWithSlots (pyth, priceFeeds, slots);
2029-
2033+
20302034 vm.prank (pusher);
2031- scheduler.updatePriceFeeds (subscriptionId, createMockUpdateData (priceFeeds));
2035+ scheduler.updatePriceFeeds (
2036+ subscriptionId,
2037+ createMockUpdateData (priceFeeds)
2038+ );
20322039
20332040 // Store the removed price ID for later use
20342041 bytes32 removedPriceId = initialPriceIds[numInitialFeeds - 1 ];
20352042
20362043 // 2. Action: Update subscription to remove the last price feed
2037- (SchedulerState.SubscriptionParams memory params , ) = scheduler.getSubscription (subscriptionId);
2038-
2044+ (SchedulerState.SubscriptionParams memory params , ) = scheduler
2045+ .getSubscription (subscriptionId);
2046+
20392047 // Create new price IDs array without the last ID
20402048 bytes32 [] memory newPriceIds = new bytes32 [](numInitialFeeds - 1 );
20412049 for (uint i = 0 ; i < newPriceIds.length ; i++ ) {
20422050 newPriceIds[i] = initialPriceIds[i];
20432051 }
2044-
2052+
20452053 params.priceIds = newPriceIds;
2046-
2054+
20472055 vm.expectEmit ();
20482056 emit SubscriptionUpdated (subscriptionId);
20492057 scheduler.updateSubscription (subscriptionId, params);
20502058
20512059 // 3. Verification:
20522060 // - Verify that the removed price ID is no longer part of the subscription's price IDs
2053- (SchedulerState.SubscriptionParams memory updatedParams , ) = scheduler.getSubscription (subscriptionId);
2061+ (SchedulerState.SubscriptionParams memory updatedParams , ) = scheduler
2062+ .getSubscription (subscriptionId);
20542063 assertEq (
20552064 updatedParams.priceIds.length ,
20562065 numInitialFeeds - 1 ,
20572066 "Subscription should have one less price ID "
20582067 );
2059-
2068+
20602069 bool removedPriceIdFound = false ;
20612070 for (uint i = 0 ; i < updatedParams.priceIds.length ; i++ ) {
20622071 if (updatedParams.priceIds[i] == removedPriceId) {
@@ -2077,7 +2086,7 @@ contract SchedulerTest is Test, SchedulerEvents, PulseSchedulerTestUtils {
20772086 newPriceIds.length ,
20782087 "Querying all should only return remaining feeds "
20792088 );
2080-
2089+
20812090 // - Verify that the removed price ID is not included in the returned prices
20822091 for (uint i = 0 ; i < allPricesAfterUpdate.length ; i++ ) {
20832092 // We can't directly check the price ID from the Price struct
@@ -2090,8 +2099,6 @@ contract SchedulerTest is Test, SchedulerEvents, PulseSchedulerTestUtils {
20902099 );
20912100 }
20922101 }
2093-
2094-
20952102
20962103 function testUpdateSubscriptionRevertsWithTooManyPriceIds () public {
20972104 // 1. Setup: Create a subscription with a valid number of price IDs
@@ -2105,10 +2112,12 @@ contract SchedulerTest is Test, SchedulerEvents, PulseSchedulerTestUtils {
21052112 // 2. Prepare params with too many price IDs (MAX_PRICE_IDS_PER_SUBSCRIPTION + 1)
21062113 (SchedulerState.SubscriptionParams memory currentParams , ) = scheduler
21072114 .getSubscription (subscriptionId);
2108-
2109- uint16 tooManyFeeds = uint16 (scheduler.MAX_PRICE_IDS_PER_SUBSCRIPTION ()) + 1 ;
2115+
2116+ uint16 tooManyFeeds = uint16 (
2117+ scheduler.MAX_PRICE_IDS_PER_SUBSCRIPTION ()
2118+ ) + 1 ;
21102119 bytes32 [] memory tooManyPriceIds = createPriceIds (tooManyFeeds);
2111-
2120+
21122121 SchedulerState.SubscriptionParams memory newParams = currentParams;
21132122 newParams.priceIds = tooManyPriceIds;
21142123
0 commit comments