@tunghm/relay-kit
Version:
75 lines • 3.31 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const PimlicoFeeEstimator_1 = require("./PimlicoFeeEstimator");
const fixtures = __importStar(require("../testing-utils/fixtures"));
const constants = __importStar(require("../constants"));
jest.mock('../utils', () => ({
...jest.requireActual('../utils'),
getEip4337BundlerProvider: () => ({
send: async (method) => {
switch (method) {
case constants.RPC_4337_CALLS.SPONSOR_USER_OPERATION:
return fixtures.SPONSORED_GAS_ESTIMATION;
case 'pimlico_getUserOperationGasPrice':
return fixtures.USER_OPERATION_GAS_PRICE;
default:
return undefined;
}
}
})
}));
describe('PimlicoFeeEstimator', () => {
let estimator;
beforeEach(() => {
estimator = new PimlicoFeeEstimator_1.PimlicoFeeEstimator();
});
it('should enable to setup the gas estimation', async () => {
const sponsoredGasEstimation = await estimator.setupEstimation({
bundlerUrl: fixtures.BUNDLER_URL,
userOperation: fixtures.USER_OPERATION,
entryPoint: fixtures.ENTRYPOINTS[0]
});
expect(sponsoredGasEstimation).toEqual(fixtures.USER_OPERATION_GAS_PRICE.fast);
});
// TODO: This tests breaks because of the BigInt serialization and requires further investigation
// it('should enable to adjust the gas estimation', async () => {
// const sponsoredGasEstimation = await estimator.adjustEstimation({
// bundlerUrl: fixtures.BUNDLER_URL,
// userOperation: fixtures.USER_OPERATION,
// entryPoint: fixtures.ENTRYPOINTS[0]
// })
// expect(sponsoredGasEstimation).toEqual({ verificationGasLimit: 41_528n })
// })
it('should get the paymaster estimation', async () => {
const paymasterGasEstimation = await estimator.getPaymasterEstimation({
userOperation: fixtures.USER_OPERATION,
paymasterUrl: fixtures.PAYMASTER_URL,
entryPoint: fixtures.ENTRYPOINTS[0]
});
expect(paymasterGasEstimation).toEqual(fixtures.SPONSORED_GAS_ESTIMATION);
});
});
//# sourceMappingURL=PimlicoFeeEstimator.test.js.map