Skip to content

Commit d977d84

Browse files
authored
feat(STX-169): test disable transaction-controller automatic gas fee update (#6671)
## Explanation The goal of this PR is to make sure the automatic gas fee update is disabled when `isAutomaticGasFeeUpdateEnabled` returns false. ## References * Related to MetaMask/metamask-extension#36153 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
1 parent 73a5aad commit d977d84

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

packages/transaction-controller/src/TransactionController.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5489,6 +5489,55 @@ describe('TransactionController', () => {
54895489
expect(updatedTransaction?.txParams.gasPrice).toBe('0x5678');
54905490
expect(updatedTransaction?.userFeeLevel).toBe('custom');
54915491
});
5492+
5493+
it('does not update transaction gas estimates when isAutomaticGasFeeUpdateEnabled returns false', () => {
5494+
const transactionId = '1';
5495+
5496+
const { controller } = setupController({
5497+
options: {
5498+
isAutomaticGasFeeUpdateEnabled: () => false,
5499+
state: {
5500+
transactions: [
5501+
{
5502+
id: transactionId,
5503+
chainId: '0x1',
5504+
networkClientId: NETWORK_CLIENT_ID_MOCK,
5505+
time: 123456789,
5506+
status: TransactionStatus.unapproved as const,
5507+
gasFeeEstimates: {
5508+
type: GasFeeEstimateType.Legacy,
5509+
low: '0x1',
5510+
medium: '0x2',
5511+
high: '0x3',
5512+
},
5513+
txParams: {
5514+
type: TransactionEnvelopeType.legacy,
5515+
from: ACCOUNT_MOCK,
5516+
to: ACCOUNT_2_MOCK,
5517+
gasPrice: '0x1234',
5518+
},
5519+
},
5520+
],
5521+
},
5522+
},
5523+
updateToInitialState: true,
5524+
});
5525+
5526+
controller.updateTransactionGasFees(transactionId, {
5527+
userFeeLevel: GasFeeEstimateLevel.Medium,
5528+
gasPrice: '0x5678',
5529+
});
5530+
5531+
expect(updateTransactionGasEstimatesMock).not.toHaveBeenCalled();
5532+
5533+
const updatedTransaction = controller.state.transactions.find(
5534+
({ id }) => id === transactionId,
5535+
);
5536+
expect(updatedTransaction?.txParams.gasPrice).toBe('0x5678');
5537+
expect(updatedTransaction?.userFeeLevel).toBe(
5538+
GasFeeEstimateLevel.Medium,
5539+
);
5540+
});
54925541
});
54935542
});
54945543

0 commit comments

Comments
 (0)