Skip to content

Commit c6e0a83

Browse files
fix: Override lower bound gas when gasLimit is defined
1 parent cd15a64 commit c6e0a83

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

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

+36-36
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ type UnrestrictedMessenger = Messenger<
101101

102102
const MOCK_V1_UUID = '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d';
103103
const TRANSACTION_HASH_MOCK = '0x123456';
104-
104+
const MINIMUM_GAS_LIMIT = '0x5208';
105105
jest.mock('@metamask/eth-query');
106106
jest.mock('./api/accounts-api');
107107
jest.mock('./gas-flows/DefaultGasFeeFlow');
@@ -212,7 +212,7 @@ function buildMockEthQuery(): EthQuery {
212212
const txs: any = [
213213
{
214214
blockHash: '1337',
215-
gasUsed: '0x5208',
215+
gasUsed: MINIMUM_GAS_LIMIT,
216216
hash: '1337',
217217
status: '0x1',
218218
transactionIndex: 1337,
@@ -1345,7 +1345,7 @@ describe('TransactionController', () => {
13451345
const { transactionMeta } = await controller.addTransaction(
13461346
{
13471347
from: ACCOUNT_MOCK,
1348-
gas: '0x0',
1348+
gas: MINIMUM_GAS_LIMIT,
13491349
gasPrice: '0x50fd51da',
13501350
to: ACCOUNT_MOCK,
13511351
value: '0x0',
@@ -1630,7 +1630,7 @@ describe('TransactionController', () => {
16301630
async (gasPropName: keyof DappSuggestedGasFees) => {
16311631
const { controller } = setupController();
16321632
const mockDappOrigin = 'MockDappOrigin';
1633-
const mockGasValue = '0x1';
1633+
const mockGasValue = MINIMUM_GAS_LIMIT;
16341634
await controller.addTransaction(
16351635
{
16361636
from: ACCOUNT_MOCK,
@@ -1736,7 +1736,7 @@ describe('TransactionController', () => {
17361736
const { result: firstResult } = await controller.addTransaction(
17371737
{
17381738
from: ACCOUNT_MOCK,
1739-
gas: '0x0',
1739+
gas: MINIMUM_GAS_LIMIT,
17401740
gasPrice: '0x50fd51da',
17411741
to: ACCOUNT_MOCK,
17421742
value: '0x0',
@@ -1759,7 +1759,7 @@ describe('TransactionController', () => {
17591759
const { result: secondResult } = await controller.addTransaction(
17601760
{
17611761
from: ACCOUNT_MOCK,
1762-
gas: '0x2',
1762+
gas: MINIMUM_GAS_LIMIT,
17631763
gasPrice: '0x50fd51da',
17641764
to: ACCOUNT_MOCK,
17651765
value: '0x1290',
@@ -2027,7 +2027,7 @@ describe('TransactionController', () => {
20272027
const { result } = await controller.addTransaction(
20282028
{
20292029
from: ACCOUNT_MOCK,
2030-
gas: '0x0',
2030+
gas: MINIMUM_GAS_LIMIT,
20312031
gasPrice: '0x0',
20322032
to: ACCOUNT_MOCK,
20332033
value: '0x0',
@@ -2239,7 +2239,7 @@ describe('TransactionController', () => {
22392239
const { result } = await controller.addTransaction(
22402240
{
22412241
from: ACCOUNT_MOCK,
2242-
gas: '0x0',
2242+
gas: MINIMUM_GAS_LIMIT,
22432243
gasPrice: '0x0',
22442244
to: ACCOUNT_MOCK,
22452245
value: '0x0',
@@ -2265,7 +2265,7 @@ describe('TransactionController', () => {
22652265
const { result } = await controller.addTransaction(
22662266
{
22672267
from: ACCOUNT_MOCK,
2268-
gas: '0x0',
2268+
gas: MINIMUM_GAS_LIMIT,
22692269
gasPrice: '0x0',
22702270
to: ACCOUNT_MOCK,
22712271
value: '0x0',
@@ -2285,7 +2285,7 @@ describe('TransactionController', () => {
22852285
const { result } = await controller.addTransaction(
22862286
{
22872287
from: ACCOUNT_MOCK,
2288-
gas: '0x0',
2288+
gas: MINIMUM_GAS_LIMIT,
22892289
gasPrice: '0x0',
22902290
to: ACCOUNT_MOCK,
22912291
value: '0x0',
@@ -2894,7 +2894,7 @@ describe('TransactionController', () => {
28942894
const { transactionMeta } = await controller.addTransaction(
28952895
{
28962896
from: ACCOUNT_MOCK,
2897-
gas: '0x0',
2897+
gas: MINIMUM_GAS_LIMIT,
28982898
gasPrice: '0x1',
28992899
to: ACCOUNT_MOCK,
29002900
value: '0x0',
@@ -2955,7 +2955,7 @@ describe('TransactionController', () => {
29552955
const { result } = await controller.addTransaction(
29562956
{
29572957
from: ACCOUNT_MOCK,
2958-
gas: '0xFF',
2958+
gas: MINIMUM_GAS_LIMIT,
29592959
gasPrice: '0xEE',
29602960
to: ACCOUNT_MOCK,
29612961
value: '0x0',
@@ -2983,8 +2983,8 @@ describe('TransactionController', () => {
29832983
time: expect.any(Number),
29842984
transaction: {
29852985
from: ACCOUNT_MOCK,
2986-
gas: '0xFF',
2987-
gasLimit: '0xFF',
2986+
gas: MINIMUM_GAS_LIMIT,
2987+
gasLimit: MINIMUM_GAS_LIMIT,
29882988
gasPrice: '0x105',
29892989
nonce: '0xc',
29902990
to: ACCOUNT_MOCK,
@@ -3010,7 +3010,7 @@ describe('TransactionController', () => {
30103010
const { transactionMeta } = await controller.addTransaction(
30113011
{
30123012
from: ACCOUNT_MOCK,
3013-
gas: '0x0',
3013+
gas: MINIMUM_GAS_LIMIT,
30143014
gasPrice: '0x50fd51da',
30153015
to: ACCOUNT_MOCK,
30163016
value: '0x0',
@@ -3143,7 +3143,7 @@ describe('TransactionController', () => {
31433143
const { transactionMeta } = await controller.addTransaction(
31443144
{
31453145
from: ACCOUNT_MOCK,
3146-
gas: '0x0',
3146+
gas: MINIMUM_GAS_LIMIT,
31473147
gasPrice: '0x50fd51da',
31483148
to: ACCOUNT_MOCK,
31493149
value: '0x0',
@@ -3179,7 +3179,7 @@ describe('TransactionController', () => {
31793179
const { transactionMeta } = await controller.addTransaction(
31803180
{
31813181
from: ACCOUNT_MOCK,
3182-
gas: '0x0',
3182+
gas: MINIMUM_GAS_LIMIT,
31833183
gasPrice: '0x50fd51da',
31843184
to: ACCOUNT_MOCK,
31853185
value: '0x0',
@@ -3220,7 +3220,7 @@ describe('TransactionController', () => {
32203220
const { transactionMeta } = await controller.addTransaction(
32213221
{
32223222
from: ACCOUNT_MOCK,
3223-
gas: '0x0',
3223+
gas: MINIMUM_GAS_LIMIT,
32243224
gasPrice: '0x50fd51da',
32253225
to: ACCOUNT_MOCK,
32263226
value: '0x0',
@@ -3251,7 +3251,7 @@ describe('TransactionController', () => {
32513251
const { transactionMeta } = await controller.addTransaction(
32523252
{
32533253
from: ACCOUNT_MOCK,
3254-
gas: '0x0',
3254+
gas: MINIMUM_GAS_LIMIT,
32553255
gasPrice: '0x50fd51da',
32563256
to: ACCOUNT_MOCK,
32573257
value: '0x0',
@@ -3282,7 +3282,7 @@ describe('TransactionController', () => {
32823282
const { transactionMeta, result } = await controller.addTransaction(
32833283
{
32843284
from: ACCOUNT_MOCK,
3285-
gas: '0x1',
3285+
gas: MINIMUM_GAS_LIMIT,
32863286
gasPrice: '0x50fd51da',
32873287
to: ACCOUNT_MOCK,
32883288
value: '0x0',
@@ -3305,7 +3305,7 @@ describe('TransactionController', () => {
33053305
transactions[1].txParams.nonce,
33063306
);
33073307
expect(transactions[1].estimatedBaseFee).toBe('0x123');
3308-
expect(transactions[1].originalGasEstimate).toBe('0x1');
3308+
expect(transactions[1].originalGasEstimate).toBe(MINIMUM_GAS_LIMIT);
33093309
});
33103310

33113311
it('allows transaction count to exceed txHistorylimit', async () => {
@@ -3324,7 +3324,7 @@ describe('TransactionController', () => {
33243324
{
33253325
from: ACCOUNT_MOCK,
33263326
nonce: '1111111',
3327-
gas: '0x0',
3327+
gas: MINIMUM_GAS_LIMIT,
33283328
gasPrice: '0x50fd51da',
33293329
to: ACCOUNT_MOCK,
33303330
value: '0x0',
@@ -3364,7 +3364,7 @@ describe('TransactionController', () => {
33643364
await controller.addTransaction(
33653365
{
33663366
from: ACCOUNT_MOCK,
3367-
gas: '0x0',
3367+
gas: MINIMUM_GAS_LIMIT,
33683368
gasPrice: '0x1',
33693369
to: ACCOUNT_MOCK,
33703370
value: '0x0',
@@ -3414,7 +3414,7 @@ describe('TransactionController', () => {
34143414
const { result } = await controller.addTransaction(
34153415
{
34163416
from: ACCOUNT_MOCK,
3417-
gas: '0xFF',
3417+
gas: MINIMUM_GAS_LIMIT,
34183418
gasPrice: '0xEE',
34193419
to: ACCOUNT_MOCK,
34203420
value: '0x0',
@@ -3442,8 +3442,8 @@ describe('TransactionController', () => {
34423442
time: expect.any(Number),
34433443
transaction: {
34443444
from: ACCOUNT_MOCK,
3445-
gas: '0xFF',
3446-
gasLimit: '0xFF',
3445+
gas: MINIMUM_GAS_LIMIT,
3446+
gasLimit: MINIMUM_GAS_LIMIT,
34473447
gasPrice: '0x105',
34483448
nonce: '0xc',
34493449
to: ACCOUNT_MOCK,
@@ -3474,7 +3474,7 @@ describe('TransactionController', () => {
34743474
},
34753475
};
34763476
const externalTransactionReceipt = {
3477-
gasUsed: '0x5208',
3477+
gasUsed: MINIMUM_GAS_LIMIT,
34783478
};
34793479
const externalBaseFeePerGas = '0x14';
34803480

@@ -3514,7 +3514,7 @@ describe('TransactionController', () => {
35143514
};
35153515

35163516
const externalTransactionReceipt = {
3517-
gasUsed: '0x5208',
3517+
gasUsed: MINIMUM_GAS_LIMIT,
35183518
};
35193519

35203520
const externalBaseFeePerGas = '0x14';
@@ -3590,7 +3590,7 @@ describe('TransactionController', () => {
35903590
},
35913591
};
35923592
const externalTransactionReceipt = {
3593-
gasUsed: '0x5208',
3593+
gasUsed: MINIMUM_GAS_LIMIT,
35943594
};
35953595
const externalBaseFeePerGas = '0x14';
35963596

@@ -3683,7 +3683,7 @@ describe('TransactionController', () => {
36833683
},
36843684
};
36853685
const externalTransactionReceipt = {
3686-
gasUsed: '0x5208',
3686+
gasUsed: MINIMUM_GAS_LIMIT,
36873687
};
36883688
const externalBaseFeePerGas = '0x14';
36893689

@@ -3774,7 +3774,7 @@ describe('TransactionController', () => {
37743774
} as any;
37753775

37763776
const externalTransactionReceipt = {
3777-
gasUsed: '0x5208',
3777+
gasUsed: MINIMUM_GAS_LIMIT,
37783778
};
37793779
const externalBaseFeePerGas = '0x14';
37803780

@@ -3824,7 +3824,7 @@ describe('TransactionController', () => {
38243824
// eslint-disable-next-line @typescript-eslint/no-explicit-any
38253825
} as any;
38263826
const externalTransactionReceipt = {
3827-
gasUsed: '0x5208',
3827+
gasUsed: MINIMUM_GAS_LIMIT,
38283828
};
38293829
const externalBaseFeePerGas = '0x14';
38303830

@@ -4254,8 +4254,8 @@ describe('TransactionController', () => {
42544254
updateToInitialState: true,
42554255
});
42564256

4257-
const gas = '0x1';
4258-
const gasLimit = '0x2';
4257+
const gas = MINIMUM_GAS_LIMIT;
4258+
const gasLimit = '0x5209';
42594259
const gasPrice = '0x12';
42604260
const estimateUsed = '0x3';
42614261
const estimateSuggested = '0x123';
@@ -4708,7 +4708,7 @@ describe('TransactionController', () => {
47084708
const mockTransactionParam = {
47094709
from: ACCOUNT_MOCK,
47104710
nonce: '0x1',
4711-
gas: '0x5208',
4711+
gas: MINIMUM_GAS_LIMIT,
47124712
to: ACCOUNT_2_MOCK,
47134713
value: '0x0',
47144714
chainId: MOCK_NETWORK.chainId,
@@ -5760,7 +5760,7 @@ describe('TransactionController', () => {
57605760
const params = {
57615761
data: '0x12',
57625762
from: ACCOUNT_2_MOCK,
5763-
gas: '0x0',
5763+
gas: MINIMUM_GAS_LIMIT,
57645764
gasPrice: '0x50fd51da',
57655765
to: ACCOUNT_MOCK,
57665766
value: '0x0',

0 commit comments

Comments
 (0)