Skip to content

Commit

Permalink
fix: allow setting min gas price in launchNode args (#2814)
Browse files Browse the repository at this point in the history
* add conditional based on input

* add missing flags

* unskip test

* changeset
  • Loading branch information
mvares committed Jul 22, 2024
1 parent f3453b9 commit 83bcfcf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .changeset/mighty-crews-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

fix: allow setting min gas price in `launchNode` args
15 changes: 7 additions & 8 deletions packages/account/src/providers/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1072,18 +1072,17 @@ Supported fuel-core version: ${mock.supportedVersion}.`
});
});

// TODO: validate if this test still makes sense
it.skip('should ensure estimated fee values on getTransactionCost are never 0', async () => {
using launched = await setupTestProviderAndWallets();
it('should ensure estimated fee values on getTransactionCost are never 0', async () => {
using launched = await setupTestProviderAndWallets({
nodeOptions: { args: ['--min-gas-price', '0'] },
});
const { provider } = launched;
const request = new ScriptTransactionRequest();

// forcing calculatePriceWithFactor to return 0
const calculateGasFeeMock = vi.spyOn(gasMod, 'calculateGasFee').mockReturnValue(bn(0));
const request = new ScriptTransactionRequest();

const { minFee, maxFee } = await provider.getTransactionCost(request);
const { minFee, maxFee, gasPrice } = await provider.getTransactionCost(request);

expect(calculateGasFeeMock).toHaveBeenCalled();
expect(gasPrice.eq(0)).toBeTruthy();

expect(maxFee.eq(0)).not.toBeTruthy();
expect(minFee.eq(0)).not.toBeTruthy();
Expand Down
6 changes: 5 additions & 1 deletion packages/account/src/test-utils/launchNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export const launchNode = async ({
'--consensus-key',
'--db-type',
'--poa-instant',
'--min-gas-price',
'--native-executor-version',
]);

const snapshotDir = getFlagValueFromArgs(args, '--snapshot');
Expand All @@ -142,6 +144,8 @@ export const launchNode = async ({

const nativeExecutorVersion = getFlagValueFromArgs(args, '--native-executor-version') || '0';

const minGasPrice = getFlagValueFromArgs(args, '--min-gas-price') || '1';

// This string is logged by the client when the node has successfully started. We use it to know when to resolve.
const graphQLStartSubstring = 'Binding GraphQL provider to';

Expand Down Expand Up @@ -194,7 +198,7 @@ export const launchNode = async ({
['--ip', ipToUse],
['--port', portToUse],
useInMemoryDb ? ['--db-type', 'in-memory'] : ['--db-path', tempDir],
['--min-gas-price', '1'],
['--min-gas-price', minGasPrice],
poaInstant ? ['--poa-instant', 'true'] : [],
['--native-executor-version', nativeExecutorVersion],
['--consensus-key', consensusKey],
Expand Down

0 comments on commit 83bcfcf

Please sign in to comment.