Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Jan 2, 2025
1 parent 4980b22 commit 21821ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
17 changes: 7 additions & 10 deletions src/gasPriceOracle/adapters/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,20 @@ export class PolygonGasStation extends BaseHTTPAdapter {
}
}

export class MockRevertingPolygonGasStation extends PolygonGasStation {
class MockRevertingPolygonGasStation extends PolygonGasStation {
getFeeData(): Promise<GasPriceEstimate> {
throw new Error();
}
}

export class MockPolygonGasStation extends PolygonGasStation {
static BASE_FEE(): BigNumber {
return parseUnits("12", 9);
}
static PRIORITY_FEE(): BigNumber {
return parseUnits("1", 9);
}
export const MockPolygonGasStationBaseFee = parseUnits("12", 9);
export const MockPolygonGasStationPriorityFee = parseUnits("1", 9);

class MockPolygonGasStation extends PolygonGasStation {
getFeeData(): Promise<GasPriceEstimate> {
return Promise.resolve({
maxPriorityFeePerGas: MockPolygonGasStation.PRIORITY_FEE(),
maxFeePerGas: MockPolygonGasStation.BASE_FEE().add(MockPolygonGasStation.PRIORITY_FEE()),
maxPriorityFeePerGas: MockPolygonGasStationPriorityFee,
maxFeePerGas: MockPolygonGasStationBaseFee.add(MockPolygonGasStationPriorityFee),
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/GasPriceOracle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getGasPriceEstimate } from "../src/gasPriceOracle";
import { BigNumber, bnZero, parseUnits } from "../src/utils";
import { assertPromiseError, expect, makeCustomTransport, randomAddress } from "../test/utils";
import { MockedProvider } from "./utils/provider";
import { MockPolygonGasStation } from "../src/gasPriceOracle/adapters/polygon";
import { MockPolygonGasStationBaseFee, MockPolygonGasStationPriorityFee } from "../src/gasPriceOracle/adapters/polygon";
dotenv.config({ path: ".env" });

const stdLastBaseFeePerGas = parseUnits("12", 9);
Expand Down Expand Up @@ -190,9 +190,9 @@ describe("Gas Price Oracle", function () {
});

expect(maxFeePerGas).to.equal(
MockPolygonGasStation.BASE_FEE().mul(baseFeeMultiplier).add(MockPolygonGasStation.PRIORITY_FEE())
MockPolygonGasStationBaseFee.mul(baseFeeMultiplier).add(MockPolygonGasStationPriorityFee)
);
expect(maxPriorityFeePerGas).to.equal(MockPolygonGasStation.PRIORITY_FEE());
expect(maxPriorityFeePerGas).to.equal(MockPolygonGasStationPriorityFee);
delete process.env["TEST_POLYGON_GAS_STATION"];
});
it("Ethers Polygon GasStation: Fallback", async function () {
Expand Down

0 comments on commit 21821ca

Please sign in to comment.