EntropyTestUtils.t.sol 788 B

123456789101112131415161718192021222324
  1. // SPDX-License-Identifier: Apache 2
  2. pragma solidity ^0.8.0;
  3. import "forge-std/Test.sol";
  4. import "@pythnetwork/entropy-sdk-solidity/EntropyStructs.sol";
  5. abstract contract EntropyTestUtils is Test {
  6. // Generate a hash chain for a provider that can be used for test purposes.
  7. function generateHashChain(
  8. address provider,
  9. uint64 startSequenceNumber,
  10. uint64 size
  11. ) public pure returns (bytes32[] memory hashChain) {
  12. bytes32 initialValue = keccak256(
  13. abi.encodePacked(provider, startSequenceNumber)
  14. );
  15. hashChain = new bytes32[](size);
  16. for (uint64 i = 0; i < size; i++) {
  17. hashChain[size - (i + 1)] = initialValue;
  18. initialValue = keccak256(bytes.concat(initialValue));
  19. }
  20. }
  21. }