@@ -11,6 +11,7 @@ import "@pythnetwork/pyth-sdk-solidity/PythStructs.sol";
1111import  "./utils/WormholeTestUtils.t.sol " ;
1212import  "./utils/PythTestUtils.t.sol " ;
1313import  "./utils/RandTestUtils.t.sol " ;
14+ import  "forge-std/console.sol " ;
1415
1516contract  PythTest  is  Test , WormholeTestUtils , PythTestUtils  {
1617    IPyth public  pyth;
@@ -105,7 +106,7 @@ contract PythTest is Test, WormholeTestUtils, PythTestUtils {
105106    function createBatchedTwapUpdateDataFromMessagesWithConfig  (
106107        PriceFeedMessage[] memory  messages ,
107108        MerkleUpdateConfig memory  config 
108-     ) public  returns  (bytes [][]  memory  updateData , uint  updateFee ) {
109+     ) public  returns  (bytes [] memory  updateData , uint  updateFee ) {
109110        require (messages.length  >=  2 , "At least 2 messages required for TWAP " );
110111
111112        // Create TWAP messages from regular price feed messages 
@@ -140,33 +141,24 @@ contract PythTest is Test, WormholeTestUtils, PythTestUtils {
140141        endTwapMessages[0 ].prevPublishTime =  messages[1 ].prevPublishTime;
141142        endTwapMessages[0 ].publishSlot =  1100 ; // End slot (100 slots after start) 
142143
143-         // Generate  the update data for start and end using the TWAP-specific function  
144-         bytes []  memory  startUpdateData  =  new  bytes [](1 );
145-         startUpdateData [0 ] =  generateWhMerkleTwapUpdateWithSource (
144+         // Create  the updateData array with exactly 2 elements as required by parseTwapPriceFeedUpdates  
145+         updateData  =  new  bytes [](2 );
146+         updateData [0 ] =  generateWhMerkleTwapUpdateWithSource (
146147            startTwapMessages,
147148            config
148149        );
149- 
150-         bytes [] memory  endUpdateData =  new  bytes [](1 );
151-         endUpdateData[0 ] =  generateWhMerkleTwapUpdateWithSource (
150+         updateData[1 ] =  generateWhMerkleTwapUpdateWithSource (
152151            endTwapMessages,
153152            config
154153        );
155154
156-         // Create the updateData array with exactly 2 elements as required by parseTwapPriceFeedUpdates 
157-         updateData =  new  bytes [][](2 );
158-         updateData[0 ] =  startUpdateData;
159-         updateData[1 ] =  endUpdateData;
160- 
161155        // Calculate the update fee 
162-         // We only charge fee for 1 update even though we need 2 updates to derive TWAP. 
163-         // This is for better UX since user's intention is to get a single TWAP price. 
164-         updateFee =  pyth.getUpdateFee (updateData[0 ]);
156+         updateFee =  pyth.getUpdateFee (updateData);
165157    }
166158
167159    function createBatchedTwapUpdateDataFromMessages  (
168160        PriceFeedMessage[] memory  messages 
169-     ) internal  returns  (bytes [][]  memory  updateData , uint  updateFee ) {
161+     ) internal  returns  (bytes [] memory  updateData , uint  updateFee ) {
170162        (
171163            updateData,
172164            updateFee
@@ -423,7 +415,7 @@ contract PythTest is Test, WormholeTestUtils, PythTestUtils {
423415
424416        // Create update data for TWAP calculation 
425417        (
426-             bytes [][]  memory  updateData ,
418+             bytes [] memory  updateData ,
427419            uint  updateFee 
428420        ) =  createBatchedTwapUpdateDataFromMessages (messages);
429421
@@ -461,8 +453,8 @@ contract PythTest is Test, WormholeTestUtils, PythTestUtils {
461453        priceIds[0 ] =  bytes32 (uint256 (1 ));
462454
463455        // Create invalid update data with wrong length 
464-         bytes [][]  memory  updateData =  new  bytes [] [](1 ); // Should be 2 
465-         updateData[0 ] =  new  bytes [] (1 );
456+         bytes [] memory  updateData =  new  bytes [](1 ); // Should be 2 
457+         updateData[0 ] =  new  bytes (1 );
466458
467459        vm.expectRevert (PythErrors.InvalidUpdateData.selector );
468460        pyth.parseTwapPriceFeedUpdates {value: 0 }(updateData, priceIds);
@@ -489,7 +481,7 @@ contract PythTest is Test, WormholeTestUtils, PythTestUtils {
489481        messages[1 ].prevPublishTime =  1000 ;
490482
491483        (
492-             bytes [][]  memory  updateData ,
484+             bytes [] memory  updateData ,
493485            uint  updateFee 
494486        ) =  createBatchedTwapUpdateDataFromMessages (messages);
495487
@@ -518,7 +510,7 @@ contract PythTest is Test, WormholeTestUtils, PythTestUtils {
518510        messages[1 ].prevPublishTime =  900 ;
519511
520512        (
521-             bytes [][]  memory  updateData ,
513+             bytes [] memory  updateData ,
522514            uint  updateFee 
523515        ) =  createBatchedTwapUpdateDataFromMessages (messages);
524516
@@ -549,7 +541,7 @@ contract PythTest is Test, WormholeTestUtils, PythTestUtils {
549541        messages[1 ].prevPublishTime =  1000 ;
550542
551543        (
552-             bytes [][]  memory  updateData ,
544+             bytes [] memory  updateData ,
553545            uint  updateFee 
554546        ) =  createBatchedTwapUpdateDataFromMessages (messages);
555547
@@ -578,7 +570,7 @@ contract PythTest is Test, WormholeTestUtils, PythTestUtils {
578570        messages[1 ].prevPublishTime =  1000 ;
579571
580572        (
581-             bytes [][]  memory  updateData ,
573+             bytes [] memory  updateData ,
582574            uint  updateFee 
583575        ) =  createBatchedTwapUpdateDataFromMessages (messages);
584576
@@ -603,7 +595,7 @@ contract PythTest is Test, WormholeTestUtils, PythTestUtils {
603595        messages[1 ].prevPublishTime =  1000 ;
604596
605597        (
606-             bytes [][]  memory  updateData ,
598+             bytes [] memory  updateData ,
607599            uint  updateFee 
608600        ) =  createBatchedTwapUpdateDataFromMessages (messages);
609601
0 commit comments