All files / src/contracts ContractParamsProviderMock.ts

40% Statements 4/10
0% Branches 0/2
0% Functions 0/4
40% Lines 4/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 343x 3x   3x   3x                                                        
import { hexlify } from "@ethersproject/bytes";
import { toUtf8Bytes } from "@ethersproject/strings/lib/utf8";
import { DataPackagesRequestParams } from "../index";
import { ContractParamsProvider } from "./ContractParamsProvider";
 
export class ContractParamsProviderMock extends ContractParamsProvider {
  overriddenFeedIds?: string[];
 
  constructor(
    dataFeeds: string[],
    private filePath: string,
    private fileReader: (filePath: string) => Buffer
  ) {
    super({
      uniqueSignersCount: 0,
      dataServiceId: "",
      dataFeeds: dataFeeds,
    });
  }
 
  protected override requestPayload(
    _: DataPackagesRequestParams
  ): Promise<string> {
    return Promise.resolve(this.fileReader(this.filePath).toString());
  }
 
  override getHexlifiedFeedIds(): string[] {
    return (
      this.overriddenFeedIds?.map((feed) => hexlify(toUtf8Bytes(feed))) ||
      super.getHexlifiedFeedIds()
    );
  }
}