@@ -196,7 +196,19 @@ contract PulseTest is Test, PulseEvents {
196196 PulseState.Request memory expectedRequest = PulseState.Request ({
197197 sequenceNumber: 1 ,
198198 publishTime: publishTime,
199- priceIdsHash: keccak256 (abi.encode (priceIds)),
199+ priceIds: [
200+ priceIds[0 ],
201+ priceIds[1 ],
202+ bytes32 (0 ), // Fill remaining slots with zero
203+ bytes32 (0 ),
204+ bytes32 (0 ),
205+ bytes32 (0 ),
206+ bytes32 (0 ),
207+ bytes32 (0 ),
208+ bytes32 (0 ),
209+ bytes32 (0 )
210+ ],
211+ numPriceIds: 2 ,
200212 callbackGasLimit: CALLBACK_GAS_LIMIT,
201213 requester: address (consumer)
202214 });
@@ -215,7 +227,10 @@ contract PulseTest is Test, PulseEvents {
215227 PulseState.Request memory lastRequest = pulse.getRequest (1 );
216228 assertEq (lastRequest.sequenceNumber, expectedRequest.sequenceNumber);
217229 assertEq (lastRequest.publishTime, expectedRequest.publishTime);
218- assertEq (lastRequest.priceIdsHash, expectedRequest.priceIdsHash);
230+ assertEq (lastRequest.numPriceIds, expectedRequest.numPriceIds);
231+ for (uint8 i = 0 ; i < lastRequest.numPriceIds; i++ ) {
232+ assertEq (lastRequest.priceIds[i], expectedRequest.priceIds[i]);
233+ }
219234 assertEq (
220235 lastRequest.callbackGasLimit,
221236 expectedRequest.callbackGasLimit
@@ -627,17 +642,13 @@ contract PulseTest is Test, PulseEvents {
627642 mockParsePriceFeedUpdates (priceFeeds);
628643 bytes [] memory updateData = createMockUpdateData (priceFeeds);
629644
630- // Calculate hashes for both arrays
631- bytes32 providedPriceIdsHash = keccak256 (abi.encode (wrongPriceIds));
632- bytes32 storedPriceIdsHash = keccak256 (abi.encode (priceIds));
633-
634645 // Should revert when trying to execute with wrong priceIds
635646 vm.prank (updater);
636647 vm.expectRevert (
637648 abi.encodeWithSelector (
638649 InvalidPriceIds.selector ,
639- providedPriceIdsHash ,
640- storedPriceIdsHash
650+ wrongPriceIds[ 0 ] ,
651+ priceIds[ 0 ]
641652 )
642653 );
643654 pulse.executeCallback (sequenceNumber, updateData, wrongPriceIds);
@@ -679,4 +690,30 @@ contract PulseTest is Test, PulseEvents {
679690 assertEq (consumer.lastSequenceNumber (), sequenceNumber);
680691 assertEq (consumer.lastUpdater (), updater);
681692 }
693+
694+ function testRevertOnTooManyPriceIds () public {
695+ uint256 maxPriceIds = uint256 (pulse.MAX_PRICE_IDS ());
696+ // Create array with MAX_PRICE_IDS + 1 price IDs
697+ bytes32 [] memory priceIds = new bytes32 [](maxPriceIds + 1 );
698+ for (uint i = 0 ; i < priceIds.length ; i++ ) {
699+ priceIds[i] = bytes32 (uint256 (i + 1 ));
700+ }
701+
702+ vm.deal (address (consumer), 1 gwei);
703+ uint128 totalFee = calculateTotalFee ();
704+
705+ vm.prank (address (consumer));
706+ vm.expectRevert (
707+ abi.encodeWithSelector (
708+ TooManyPriceIds.selector ,
709+ maxPriceIds + 1 ,
710+ maxPriceIds
711+ )
712+ );
713+ pulse.requestPriceUpdatesWithCallback {value: totalFee}(
714+ block .timestamp ,
715+ priceIds,
716+ CALLBACK_GAS_LIMIT
717+ );
718+ }
682719}
0 commit comments