EchoTestUtils.sol 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // SPDX-License-Identifier: Apache 2
  2. pragma solidity ^0.8.0;
  3. import "forge-std/Test.sol";
  4. import "@openzeppelin/contracts/utils/math/SafeCast.sol";
  5. import "../../contracts/echo/IEcho.sol";
  6. import "./MockPriceFeedTestUtils.sol";
  7. abstract contract EchoTestUtils is Test, MockPriceFeedTestUtils {
  8. // Helper function to setup consumer request
  9. function setupConsumerRequest(
  10. IEcho echo,
  11. address provider,
  12. address consumerAddress
  13. )
  14. internal
  15. returns (
  16. uint64 sequenceNumber,
  17. bytes32[] memory priceIds,
  18. uint64 publishTime
  19. )
  20. {
  21. priceIds = createPriceIds();
  22. publishTime = SafeCast.toUint64(block.timestamp);
  23. vm.deal(consumerAddress, 1 gwei);
  24. uint96 totalFee = echo.getFee(provider, CALLBACK_GAS_LIMIT, priceIds);
  25. vm.prank(consumerAddress);
  26. sequenceNumber = echo.requestPriceUpdatesWithCallback{value: totalFee}(
  27. provider,
  28. publishTime,
  29. priceIds,
  30. CALLBACK_GAS_LIMIT
  31. );
  32. return (sequenceNumber, priceIds, publishTime);
  33. }
  34. }