From 755f8e04ba56411e4a02c8acf483376b0d217cf8 Mon Sep 17 00:00:00 2001 From: chad Date: Wed, 17 Jul 2024 11:09:24 -0500 Subject: [PATCH] refactor: PR feedback --- apps/demo-typegen/src/demo.test.ts | 42 ++--------- .../fuel-gauge/src/advanced-logging.test.ts | 11 --- .../fuel-gauge/src/await-execution.test.ts | 12 +--- packages/fuel-gauge/src/bytes.test.ts | 9 +-- .../src/configurable-contract.test.ts | 2 +- .../fuel-gauge/src/contract-factory.test.ts | 38 ++++------ packages/fuel-gauge/src/contract.test.ts | 54 +++----------- .../fuel-gauge/src/coverage-contract.test.ts | 2 +- packages/fuel-gauge/src/doc-examples.test.ts | 13 +--- .../src/dry-run-multiple-txs.test.ts | 6 -- packages/fuel-gauge/src/edge-cases.test.ts | 6 +- packages/fuel-gauge/src/fee.test.ts | 6 +- .../src/funding-transaction.test.ts | 23 ++---- packages/fuel-gauge/src/min-gas.test.ts | 24 ++----- .../src/predicate-conditional-inputs.test.ts | 12 +--- .../src/predicate/predicate-arguments.test.ts | 60 ++++------------ .../predicate/predicate-configurables.test.ts | 30 ++------ .../predicate/predicate-estimations.test.ts | 36 ++-------- .../predicate/predicate-input-data.test.ts | 6 +- .../predicate-populate-witness.test.ts | 16 +---- .../predicate/predicate-with-script.test.ts | 6 +- .../src/script-with-configurable.test.ts | 24 ++----- .../src/script-with-vectors.test.ts | 24 ++----- .../fuel-gauge/src/std-lib-string.test.ts | 14 +--- .../src/transaction-response.test.ts | 15 +--- .../src/transaction-summary.test.ts | 45 ++---------- packages/fuel-gauge/src/utils.ts | 2 +- packages/fuel-gauge/src/vectors.test.ts | 2 +- packages/fuel-gauge/test/fixtures/index.ts | 72 ------------------- 29 files changed, 94 insertions(+), 518 deletions(-) delete mode 100644 packages/fuel-gauge/test/fixtures/index.ts diff --git a/apps/demo-typegen/src/demo.test.ts b/apps/demo-typegen/src/demo.test.ts index b4f96e65d7c..42a6bb1ebd1 100644 --- a/apps/demo-typegen/src/demo.test.ts +++ b/apps/demo-typegen/src/demo.test.ts @@ -16,11 +16,7 @@ import { ScriptAbi__factory } from './script-types'; */ describe('ExampleContract', () => { it('with imported storage slots', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -38,11 +34,7 @@ describe('ExampleContract', () => { expect(contract.id).toBeTruthy(); }); it('should return the input', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -73,11 +65,7 @@ describe('ExampleContract', () => { }); it('deployContract method', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -104,11 +92,7 @@ describe('ExampleContract', () => { // #endregion Testing-in-ts-ts it('should throw when simulating via contract factory with wallet with no resources', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -128,11 +112,7 @@ it('should throw when simulating via contract factory with wallet with no resour }); it('should not throw when dry running via contract factory with wallet with no resources', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -149,11 +129,7 @@ it('should not throw when dry running via contract factory with wallet with no r }); test('Example script', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -175,11 +151,7 @@ test('Example predicate', async () => { // #context import { PredicateAbi__factory } from './types'; // In this exchange, we are first transferring some coins to the predicate - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { provider, diff --git a/packages/fuel-gauge/src/advanced-logging.test.ts b/packages/fuel-gauge/src/advanced-logging.test.ts index baf9c13aa7b..ec5512b9da5 100644 --- a/packages/fuel-gauge/src/advanced-logging.test.ts +++ b/packages/fuel-gauge/src/advanced-logging.test.ts @@ -225,9 +225,6 @@ describe('Advanced Logging', () => { { deployer: ConfigurableContractAbi__factory, bytecode: ConfigurableContractAbiHex }, { deployer: CoverageContractAbi__factory, bytecode: CoverageContractAbiHex }, ], - walletsConfig: { - amountPerCoin: 500_000, - }, }); const { @@ -288,8 +285,6 @@ describe('Advanced Logging', () => { amount, ]; - beforeAll(async () => {}); - it('when using InvocationScope', async () => { using launched = await launchTestNode({ contractsConfigs: [ @@ -299,9 +294,6 @@ describe('Advanced Logging', () => { bytecode: AdvancedLoggingOtherContractAbiHex, }, ], - walletsConfig: { - amountPerCoin: 300_000, - }, }); const { @@ -334,9 +326,6 @@ describe('Advanced Logging', () => { bytecode: AdvancedLoggingOtherContractAbiHex, }, ], - walletsConfig: { - amountPerCoin: 300_000, - }, }); const { diff --git a/packages/fuel-gauge/src/await-execution.test.ts b/packages/fuel-gauge/src/await-execution.test.ts index e71576f8d5b..342292a32b5 100644 --- a/packages/fuel-gauge/src/await-execution.test.ts +++ b/packages/fuel-gauge/src/await-execution.test.ts @@ -40,11 +40,7 @@ describe('await-execution', () => { }); test.skip('transferring funds with awaitExecution works', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider } = launched; @@ -66,11 +62,7 @@ describe('await-execution', () => { }); test('withdrawToBaseLayer works with awaitExecution', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, diff --git a/packages/fuel-gauge/src/bytes.test.ts b/packages/fuel-gauge/src/bytes.test.ts index 48f70d7d373..1e493015c3b 100644 --- a/packages/fuel-gauge/src/bytes.test.ts +++ b/packages/fuel-gauge/src/bytes.test.ts @@ -92,9 +92,6 @@ describe('Bytes Tests', () => { bytecode: BytesAbiHex, }, ], - walletsConfig: { - amountPerCoin: 1_000_000, - }, }); const { @@ -153,11 +150,7 @@ describe('Bytes Tests', () => { }); it('should test bytes input [script-bytes]', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], diff --git a/packages/fuel-gauge/src/configurable-contract.test.ts b/packages/fuel-gauge/src/configurable-contract.test.ts index 7a828fddce5..1b95c486f8a 100644 --- a/packages/fuel-gauge/src/configurable-contract.test.ts +++ b/packages/fuel-gauge/src/configurable-contract.test.ts @@ -25,7 +25,7 @@ const defaultValues = { }, }; -async function setupContract(configurableConstants?: { [name: string]: unknown }) { +function setupContract(configurableConstants?: { [name: string]: unknown }) { return launchTestNode({ contractsConfigs: [ { diff --git a/packages/fuel-gauge/src/contract-factory.test.ts b/packages/fuel-gauge/src/contract-factory.test.ts index b720c77806b..216f7b96b18 100644 --- a/packages/fuel-gauge/src/contract-factory.test.ts +++ b/packages/fuel-gauge/src/contract-factory.test.ts @@ -102,11 +102,7 @@ describe('Contract Factory', () => { }); it('should not override user input maxFee when calling deployContract', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 5_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], } = launched; @@ -137,24 +133,24 @@ describe('Contract Factory', () => { storageSlots: StorageTestContractAbi__factory.storageSlots, }); - const { waitForResult } = await contract.functions.return_var1().call(); - const { value: var1 } = await waitForResult(); + const call1 = await contract.functions.return_var1().call(); + const { value: var1 } = await call1.waitForResult(); expect(var1.toHex()).toEqual(toHex(0)); - const { waitForResult: waitForSecondResult } = await contract.functions.return_var2().call(); - const { value: var2 } = await waitForSecondResult(); + const call2 = await contract.functions.return_var2().call(); + const { value: var2 } = await call2.waitForResult(); expect(var2).toEqual(20); - const { waitForResult: waitForThirdResult } = await contract.functions.return_var3().call(); - const { value: var3 } = await waitForThirdResult(); + const call3 = await contract.functions.return_var3().call(); + const { value: var3 } = await call3.waitForResult(); expect(var3).toEqual(30); - const { waitForResult: waitForFourthResult } = await contract.functions.return_var4().call(); - const { value: var4 } = await waitForFourthResult(); + const call4 = await contract.functions.return_var4().call(); + const { value: var4 } = await call4.waitForResult(); expect(var4).toEqual(true); - const { waitForResult: waitForFifthResult } = await contract.functions.return_var5().call(); - const { value: var5 } = await waitForFifthResult(); + const call5 = await contract.functions.return_var5().call(); + const { value: var5 } = await call5.waitForResult(); expect(JSON.stringify(var5)).toEqual( JSON.stringify({ v1: true, @@ -164,11 +160,7 @@ describe('Contract Factory', () => { }); it('Creates a contract with initial storage (dynamic key)', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 5_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], } = launched; @@ -192,11 +184,7 @@ describe('Contract Factory', () => { }); it('Creates a contract with initial storage. Both dynamic key and fixed vars', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 5_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], } = launched; diff --git a/packages/fuel-gauge/src/contract.test.ts b/packages/fuel-gauge/src/contract.test.ts index 1b2a2850737..eef146e366b 100644 --- a/packages/fuel-gauge/src/contract.test.ts +++ b/packages/fuel-gauge/src/contract.test.ts @@ -17,6 +17,7 @@ import { } from 'fuels'; import type { JsonAbi, ScriptTransactionRequest, TransferParams } from 'fuels'; import { expectToThrowFuelError, ASSET_A, ASSET_B, launchTestNode } from 'fuels/test-utils'; +import type { DeployContractConfig } from 'fuels/test-utils'; import { CallTestContractAbi__factory, @@ -28,7 +29,7 @@ import { PredicateTrueAbi__factory } from '../test/typegen/predicates/factories/ import { launchTestContract } from './utils'; -const contractsConfigs = [ +const contractsConfigs: DeployContractConfig[] = [ { deployer: CallTestContractAbi__factory, bytecode: CallTestContractAbiHex, @@ -172,11 +173,7 @@ function setupTestContract() { */ describe('Contract', () => { it('generates function methods on a simple contract', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], } = launched; @@ -219,11 +216,7 @@ describe('Contract', () => { }); it('assigns a provider if passed', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000, - }, - }); + using launched = await launchTestNode({}); const { provider } = launched; const contract = new Contract(getRandomB256(), jsonFragment, provider); @@ -744,11 +737,7 @@ describe('Contract', () => { }); it('Parse create TX to JSON and parse back to create TX', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, wallets: [wallet], @@ -815,9 +804,6 @@ describe('Contract', () => { it('should transfer asset to a deployed contract just fine (NATIVE ASSET)', async () => { using launched = await launchTestNode({ contractsConfigs, - walletsConfig: { - amountPerCoin: 1_000_000, - }, }); const { provider, @@ -846,9 +832,6 @@ describe('Contract', () => { it('should set "gasLimit" and "maxFee" when transferring amounts to contract just fine', async () => { using launched = await launchTestNode({ contractsConfigs, - walletsConfig: { - amountPerCoin: 1_000_000, - }, }); const { provider, @@ -883,9 +866,6 @@ describe('Contract', () => { it('should ensure gas price and gas limit are validated when transfering to contract', async () => { using launched = await launchTestNode({ contractsConfigs, - walletsConfig: { - amountPerCoin: 1_000_000, - }, }); const { wallets: [wallet], @@ -912,9 +892,6 @@ describe('Contract', () => { using launched = await launchTestNode({ contractsConfigs, - walletsConfig: { - amountPerCoin: 1_000_000, - }, }); const { wallets: [wallet], @@ -937,9 +914,6 @@ describe('Contract', () => { it('should tranfer asset to a deployed contract just fine (FROM PREDICATE)', async () => { using launched = await launchTestNode({ contractsConfigs, - walletsConfig: { - amountPerCoin: 1_000_000, - }, }); const { provider, @@ -1017,11 +991,7 @@ describe('Contract', () => { }); it('should ensure assets can be transfered to wallets (MULTI TRANSFER)', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, wallets: [wallet], @@ -1067,11 +1037,7 @@ describe('Contract', () => { }); it('should throw when trying to transfer a zero or negative amount to a contract', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, wallets: [wallet], @@ -1205,11 +1171,7 @@ describe('Contract', () => { }); it('should ensure "get" does not modify the blockchain state', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], } = launched; diff --git a/packages/fuel-gauge/src/coverage-contract.test.ts b/packages/fuel-gauge/src/coverage-contract.test.ts index 43c372670de..8478298f215 100644 --- a/packages/fuel-gauge/src/coverage-contract.test.ts +++ b/packages/fuel-gauge/src/coverage-contract.test.ts @@ -35,7 +35,7 @@ enum MixedNativeEnum { NotNative = 12, } -async function setupContract() { +function setupContract() { return launchTestContract({ deployer: CoverageContractAbi__factory, bytecode: CoverageContractAbiHex, diff --git a/packages/fuel-gauge/src/doc-examples.test.ts b/packages/fuel-gauge/src/doc-examples.test.ts index 8472ccd66d8..8b82b1d7fcf 100644 --- a/packages/fuel-gauge/src/doc-examples.test.ts +++ b/packages/fuel-gauge/src/doc-examples.test.ts @@ -188,12 +188,7 @@ describe('Doc Examples', () => { }); it('can create wallets', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - assets: [AssetId.A, AssetId.B], - }, - }); + using launched = await launchTestNode(); const { provider, @@ -260,11 +255,7 @@ describe('Doc Examples', () => { }); it('can create a predicate and use', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, wallets: [fundingWallet], diff --git a/packages/fuel-gauge/src/dry-run-multiple-txs.test.ts b/packages/fuel-gauge/src/dry-run-multiple-txs.test.ts index 89f9d6ef874..ba0a6aea021 100644 --- a/packages/fuel-gauge/src/dry-run-multiple-txs.test.ts +++ b/packages/fuel-gauge/src/dry-run-multiple-txs.test.ts @@ -31,9 +31,6 @@ describe('dry-run-multiple-txs', () => { bytecode: RevertErrorAbiHex, }, ], - walletsConfig: { - amountPerCoin: 1_000_000, - }, }); const { @@ -144,9 +141,6 @@ describe('dry-run-multiple-txs', () => { bytecode: AdvancedLoggingOtherContractAbiHex, }, ], - walletsConfig: { - amountPerCoin: 1_000_000, - }, }); const { diff --git a/packages/fuel-gauge/src/edge-cases.test.ts b/packages/fuel-gauge/src/edge-cases.test.ts index 77f40457b0a..c9887c10514 100644 --- a/packages/fuel-gauge/src/edge-cases.test.ts +++ b/packages/fuel-gauge/src/edge-cases.test.ts @@ -24,11 +24,7 @@ describe('Edge Cases', () => { }); test("SSE subscriptions that are closed by the node don't hang a for-await-of loop", async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, diff --git a/packages/fuel-gauge/src/fee.test.ts b/packages/fuel-gauge/src/fee.test.ts index 3ff893cfa24..a59ef2226e5 100644 --- a/packages/fuel-gauge/src/fee.test.ts +++ b/packages/fuel-gauge/src/fee.test.ts @@ -312,11 +312,7 @@ describe('Fee', () => { }); it('should ensure fee is properly calculated on transactions with predicate', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode(); const { provider, diff --git a/packages/fuel-gauge/src/funding-transaction.test.ts b/packages/fuel-gauge/src/funding-transaction.test.ts index a10054f59ac..d15500bc9da 100644 --- a/packages/fuel-gauge/src/funding-transaction.test.ts +++ b/packages/fuel-gauge/src/funding-transaction.test.ts @@ -2,7 +2,7 @@ import { FuelError } from '@fuel-ts/errors'; import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; import type { Account, CoinTransactionRequestInput } from 'fuels'; import { ScriptTransactionRequest, Wallet, bn } from 'fuels'; -import { AssetId, launchTestNode } from 'fuels/test-utils'; +import { launchTestNode } from 'fuels/test-utils'; /** * @group node @@ -98,12 +98,7 @@ describe('Funding Transactions', () => { }); it('should not fund a transaction request when it is already funded', async () => { - using launched = await launchTestNode({ - walletsConfig: { - count: 1, - amountPerCoin: 200_000_000, - }, - }); + using launched = await launchTestNode(); const { provider, @@ -281,12 +276,7 @@ describe('Funding Transactions', () => { }); it('should ensure a partially funded Transaction will require only missing funds', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - assets: [AssetId.A, AssetId.B], - }, - }); + using launched = await launchTestNode(); const { provider, @@ -363,12 +353,7 @@ describe('Funding Transactions', () => { }); it('should ensure a funded Transaction will not require more funds from another user', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - assets: [AssetId.A, AssetId.B], - }, - }); + using launched = await launchTestNode(); const { provider, wallets: [fundedWallet], diff --git a/packages/fuel-gauge/src/min-gas.test.ts b/packages/fuel-gauge/src/min-gas.test.ts index d648605190f..dd9d5169b72 100644 --- a/packages/fuel-gauge/src/min-gas.test.ts +++ b/packages/fuel-gauge/src/min-gas.test.ts @@ -24,11 +24,7 @@ import CoverageContractAbiHex from '../test/typegen/contracts/CoverageContractAb */ describe('Minimum gas tests', () => { it('sets gas requirements (contract)', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -74,11 +70,7 @@ describe('Minimum gas tests', () => { }); it('sets gas requirements (script)', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -116,11 +108,7 @@ describe('Minimum gas tests', () => { }); it('sets gas requirements (predicate)', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -171,11 +159,7 @@ describe('Minimum gas tests', () => { }); it('sets gas requirements (account and predicate with script)', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, diff --git a/packages/fuel-gauge/src/predicate-conditional-inputs.test.ts b/packages/fuel-gauge/src/predicate-conditional-inputs.test.ts index 7bbe763ec80..b84107d8006 100644 --- a/packages/fuel-gauge/src/predicate-conditional-inputs.test.ts +++ b/packages/fuel-gauge/src/predicate-conditional-inputs.test.ts @@ -9,11 +9,7 @@ import { PredicateConditionalInputsAbi__factory } from '../test/typegen/predicat */ describe('PredicateConditionalInputs', () => { it('should execute custom transaction where predicate transfers to Alice (ALICE PAYS FEES)', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -90,11 +86,7 @@ describe('PredicateConditionalInputs', () => { }); it('should execute custom transaction where predicate transfer to Alice (PREDICATE PAYS FEES)', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, diff --git a/packages/fuel-gauge/src/predicate/predicate-arguments.test.ts b/packages/fuel-gauge/src/predicate/predicate-arguments.test.ts index dc3a5a5517a..929d298165d 100644 --- a/packages/fuel-gauge/src/predicate/predicate-arguments.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-arguments.test.ts @@ -23,11 +23,7 @@ describe('Predicate', () => { const amountToPredicate = 900_000; it('calls a predicate with valid address data and returns true', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -42,7 +38,7 @@ describe('Predicate', () => { }); // transfer funds to predicate - await fundPredicate(fundingWallet, predicate, amountToPredicate); + await fundPredicate(fundingWallet, predicate, amountToPredicate, 3); const receiver = Wallet.generate({ provider }); const initialReceiverBalance = await receiver.getBalance(); @@ -61,12 +57,8 @@ describe('Predicate', () => { expect(isStatusSuccess).toBeTruthy(); }); - it('calls a predicate with invalid address data and returns false', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + it('calls a predicate with invalid address data and throws error', async () => { + using launched = await launchTestNode({}); const { provider, @@ -91,11 +83,7 @@ describe('Predicate', () => { }); it('calls a predicate with valid u32 data and returns true', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -131,11 +119,7 @@ describe('Predicate', () => { }); it('calls a predicate with invalid u32 data and returns false', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -150,7 +134,7 @@ describe('Predicate', () => { }); // fund predicate - await fundPredicate(fundingWallet, predicate, 90_000_00); + await fundPredicate(fundingWallet, predicate, 90_000_00, 3); const receiver = Wallet.generate({ provider }); const initialReceiverBalance = await receiver.getBalance(); @@ -165,11 +149,7 @@ describe('Predicate', () => { }); it('calls a predicate with a valid struct argument and returns true', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -247,11 +227,7 @@ describe('Predicate', () => { }); it('can call a Coin predicate which returns true with valid predicate data [main args vector]', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -286,11 +262,7 @@ describe('Predicate', () => { }); it('calls a predicate with valid multiple arguments and returns true', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -327,11 +299,7 @@ describe('Predicate', () => { }); it('calls a predicate with valid multiple arguments and returns true - using setData', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -366,11 +334,7 @@ describe('Predicate', () => { }); it('calls a predicate with invalid multiple arguments and throws error', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, diff --git a/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts b/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts index 6134a9456b7..de88d17a35d 100644 --- a/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts @@ -22,11 +22,7 @@ describe('Predicate', () => { }; it('calls a predicate with configurables using default values', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -66,11 +62,7 @@ describe('Predicate', () => { }); it('calls a predicate with configurables where first param is equal', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -115,11 +107,7 @@ describe('Predicate', () => { }); it('calls a predicate with configurables where second param is equal', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -164,11 +152,7 @@ describe('Predicate', () => { }); it('calls a predicate with configurables where both params are equal', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -215,11 +199,7 @@ describe('Predicate', () => { }); it('throws when configurable data is not set', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, diff --git a/packages/fuel-gauge/src/predicate/predicate-estimations.test.ts b/packages/fuel-gauge/src/predicate/predicate-estimations.test.ts index 211fe7df48b..34d14d9b4d6 100644 --- a/packages/fuel-gauge/src/predicate/predicate-estimations.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-estimations.test.ts @@ -33,11 +33,7 @@ describe('Predicate', () => { const fundingAmount = 10_000; it('estimatePredicates should assign gas to the correct input', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -134,11 +130,7 @@ describe('Predicate', () => { }); test('predicate does not get estimated again if it has already been estimated', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -166,11 +158,7 @@ describe('Predicate', () => { }); test('Predicates get estimated if one of them is not estimated', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -215,11 +203,7 @@ describe('Predicate', () => { }); test('transferring funds from a predicate estimates the predicate and does only one dry run', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -264,11 +248,7 @@ describe('Predicate', () => { describe('predicate resource fetching and predicateData population', () => { test('getting predicate resources via the predicate automatically populates predicateData', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -302,11 +282,7 @@ describe('Predicate', () => { }); test('getting predicate resources via the provider requires manual predicateData population', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], diff --git a/packages/fuel-gauge/src/predicate/predicate-input-data.test.ts b/packages/fuel-gauge/src/predicate/predicate-input-data.test.ts index 1d29920d8df..535b1ab1f26 100644 --- a/packages/fuel-gauge/src/predicate/predicate-input-data.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-input-data.test.ts @@ -13,11 +13,7 @@ import { fundPredicate } from './utils/predicate'; describe('Predicate', () => { describe('Input Data', () => { it('throws invalid transaction when input_predicate_data is required for predicate validation', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, wallets: [wallet], diff --git a/packages/fuel-gauge/src/predicate/predicate-populate-witness.test.ts b/packages/fuel-gauge/src/predicate/predicate-populate-witness.test.ts index 685ebafb73a..d1aae2da83e 100644 --- a/packages/fuel-gauge/src/predicate/predicate-populate-witness.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-populate-witness.test.ts @@ -34,11 +34,7 @@ describe('Predicate', () => { ); it('should properly populate predicate data and remove placeholder witness [CASE 1]', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, wallets: [wallet], @@ -88,11 +84,7 @@ describe('Predicate', () => { }); it('should properly populate predicate data and remove placeholder witness [CASE 2]', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, wallets: [fundingWallet, wallet1], @@ -150,7 +142,6 @@ describe('Predicate', () => { it('should properly populate predicate data and remove placeholder witness [CASE 3]', async () => { using launched = await launchTestNode({ walletsConfig: { - amountPerCoin: 100_000_000, count: 3, }, }); @@ -223,7 +214,6 @@ describe('Predicate', () => { it('should properly populate predicate data and remove placeholder witness [CASE 4]', async () => { using launched = await launchTestNode({ walletsConfig: { - amountPerCoin: 100_000_000, count: 4, }, }); @@ -319,7 +309,6 @@ describe('Predicate', () => { it('should properly populate predicate data and remove placeholder witness [CASE 5]', async () => { using launched = await launchTestNode({ walletsConfig: { - amountPerCoin: 100_000_000, count: 3, }, }); @@ -402,7 +391,6 @@ describe('Predicate', () => { it('should properly populate predicate data and remove placeholder witness [CASE 6]', async () => { using launched = await launchTestNode({ walletsConfig: { - amountPerCoin: 100_000_000, count: 4, }, }); diff --git a/packages/fuel-gauge/src/predicate/predicate-with-script.test.ts b/packages/fuel-gauge/src/predicate/predicate-with-script.test.ts index 666359f7250..20d61dcfdb6 100644 --- a/packages/fuel-gauge/src/predicate/predicate-with-script.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-with-script.test.ts @@ -17,11 +17,7 @@ import { fundPredicate } from './utils/predicate'; describe('Predicate', () => { describe('With script', () => { it('calls a predicate and uses proceeds for a script call', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, wallets: [wallet], diff --git a/packages/fuel-gauge/src/script-with-configurable.test.ts b/packages/fuel-gauge/src/script-with-configurable.test.ts index 26580181a85..27aba35e6c6 100644 --- a/packages/fuel-gauge/src/script-with-configurable.test.ts +++ b/packages/fuel-gauge/src/script-with-configurable.test.ts @@ -13,11 +13,7 @@ const defaultValues = { */ describe('Script With Configurable', () => { it('should returns true when input value matches default configurable constant', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -38,11 +34,7 @@ describe('Script With Configurable', () => { }); it('should returns false when input value differs from default configurable constant', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -67,11 +59,7 @@ describe('Script With Configurable', () => { }); it('should returns true when input value matches manually set configurable constant', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -94,11 +82,7 @@ describe('Script With Configurable', () => { }); it('should returns false when input value differs from manually set configurable constant', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], diff --git a/packages/fuel-gauge/src/script-with-vectors.test.ts b/packages/fuel-gauge/src/script-with-vectors.test.ts index d5e1659bffd..ec056808846 100644 --- a/packages/fuel-gauge/src/script-with-vectors.test.ts +++ b/packages/fuel-gauge/src/script-with-vectors.test.ts @@ -13,11 +13,7 @@ import { */ describe('Script With Vectors', () => { it('can call script and use main argument [array]', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -33,11 +29,7 @@ describe('Script With Vectors', () => { }); it('can call script and use main argument [vec]', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -67,11 +59,7 @@ describe('Script With Vectors', () => { }); it('can call script and use main argument [struct in vec in struct in vec in struct in vec]', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], @@ -115,11 +103,7 @@ describe('Script With Vectors', () => { }); it('can call script and use main argument [struct in vec in struct in vec in struct in vec]', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], diff --git a/packages/fuel-gauge/src/std-lib-string.test.ts b/packages/fuel-gauge/src/std-lib-string.test.ts index e3e54c27682..85711167c26 100644 --- a/packages/fuel-gauge/src/std-lib-string.test.ts +++ b/packages/fuel-gauge/src/std-lib-string.test.ts @@ -15,7 +15,7 @@ import { launchTestContract } from './utils'; * @group browser */ -async function setupContract() { +function setupContract() { return launchTestContract({ deployer: StdLibStringAbi__factory, bytecode: StdLibStringAbiHex, @@ -44,11 +44,7 @@ describe('std-lib-string Tests', () => { }); it('should test String input [predicate-std-lib-string]', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -99,11 +95,7 @@ describe('std-lib-string Tests', () => { }); it('should test String input [script-std-lib-string]', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 1_000_000, - }, - }); + using launched = await launchTestNode({}); const { wallets: [wallet], diff --git a/packages/fuel-gauge/src/transaction-response.test.ts b/packages/fuel-gauge/src/transaction-response.test.ts index 1aae4c0b307..8a145224e54 100644 --- a/packages/fuel-gauge/src/transaction-response.test.ts +++ b/packages/fuel-gauge/src/transaction-response.test.ts @@ -77,11 +77,7 @@ function getSubscriptionStreamFromFetch(streamHolder: { stream: ReadableStream { it('should ensure create method waits till a transaction response is given', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -107,11 +103,7 @@ describe('TransactionResponse', () => { }); it('should ensure getTransactionSummary fetchs a transaction and assembles transaction summary', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -261,9 +253,6 @@ describe('TransactionResponse', () => { { retry: 10 }, async () => { using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 500_000, - }, nodeOptions: { args: ['--poa-instant', 'false', '--poa-interval-period', '4s', '--tx-pool-ttl', '1s'], loggingEnabled: false, diff --git a/packages/fuel-gauge/src/transaction-summary.test.ts b/packages/fuel-gauge/src/transaction-summary.test.ts index d34891a5e5b..55cd1aa85d1 100644 --- a/packages/fuel-gauge/src/transaction-summary.test.ts +++ b/packages/fuel-gauge/src/transaction-summary.test.ts @@ -54,11 +54,7 @@ describe('TransactionSummary', () => { }; it('should ensure getTransactionSummary executes just fine', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -102,11 +98,7 @@ describe('TransactionSummary', () => { }); it('should ensure getTransactionsSummaries executes just fine', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -159,11 +151,7 @@ describe('TransactionSummary', () => { }); it('should ensure getTransactionSummaryFromRequest executes just fine', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -221,11 +209,7 @@ describe('TransactionSummary', () => { }; it('should ensure transfer operation is assembled (ACCOUNT TRANSFER)', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, @@ -264,9 +248,6 @@ describe('TransactionSummary', () => { bytecode: MultiTokenContractAbiHex, }, ], - walletsConfig: { - amountPerCoin: 100_000_000, - }, }); const { @@ -299,9 +280,6 @@ describe('TransactionSummary', () => { bytecode: TokenContractAbiHex, }, ], - walletsConfig: { - amountPerCoin: 100_000_000, - }, }); const { @@ -344,9 +322,6 @@ describe('TransactionSummary', () => { bytecode: TokenContractAbiHex, }, ], - walletsConfig: { - amountPerCoin: 100_000_000, - }, }); const { @@ -430,9 +405,6 @@ describe('TransactionSummary', () => { bytecode: TokenContractAbiHex, }, ], - walletsConfig: { - amountPerCoin: 100_000_000, - }, }); const { @@ -486,9 +458,6 @@ describe('TransactionSummary', () => { bytecode: TokenContractAbiHex, }, ], - walletsConfig: { - amountPerCoin: 100_000_000, - }, }); const { @@ -553,11 +522,7 @@ describe('TransactionSummary', () => { }); it('should ensure transfer operations are assembled (CUSTOM SCRIPT TRANSFER)', async () => { - using launched = await launchTestNode({ - walletsConfig: { - amountPerCoin: 100_000_000, - }, - }); + using launched = await launchTestNode({}); const { provider, diff --git a/packages/fuel-gauge/src/utils.ts b/packages/fuel-gauge/src/utils.ts index 1a2a6cfc3a3..a34532a5676 100644 --- a/packages/fuel-gauge/src/utils.ts +++ b/packages/fuel-gauge/src/utils.ts @@ -9,6 +9,6 @@ export async function launchTestContract(config: contractsConfigs: [config], }); return Object.assign(contract, { - [Symbol.dispose]: () => Promise.resolve(cleanup()), + [Symbol.dispose]: cleanup, }); } diff --git a/packages/fuel-gauge/src/vectors.test.ts b/packages/fuel-gauge/src/vectors.test.ts index 0e7ab54f781..10bd0f46d70 100644 --- a/packages/fuel-gauge/src/vectors.test.ts +++ b/packages/fuel-gauge/src/vectors.test.ts @@ -12,7 +12,7 @@ enum SmallEnum { Empty = 'Empty', } -async function setupContract() { +function setupContract() { return launchTestContract({ deployer: VectorsAbi__factory, bytecode: VectorsAbiHex, diff --git a/packages/fuel-gauge/test/fixtures/index.ts b/packages/fuel-gauge/test/fixtures/index.ts deleted file mode 100644 index e33c1093a9f..00000000000 --- a/packages/fuel-gauge/test/fixtures/index.ts +++ /dev/null @@ -1,72 +0,0 @@ -import type { JsonAbi } from 'fuels'; -import { getForcProject } from 'fuels/test-utils'; -import { join } from 'path'; - -export enum FuelGaugeProjectsEnum { - ADVANCED_LOGGING = 'advanced-logging', - ADVANCED_LOGGING_OTHER_CONTRACT = 'advanced-logging-other-contract', - ADVANCED_LOGGING_OTHER_CONTRACT_ABI = 'advanced-logging-other-contract-abi', - AUTH_TESTING_ABI = 'auth_testing_abi', - AUTH_TESTING_CONTRACT = 'auth_testing_contract', - BYTES = 'bytes', - BYTECODE_SWAY_LIB = 'bytecode-sway-lib', - CALL_TEST_CONTRACT = 'call-test-contract', - CONFIGURABLE_CONTRACT = 'configurable-contract', - COMPLEX_SCRIPT = 'complex-script', - COMPLEX_PREDICATE = 'complex-predicate', - COLLISION_IN_FN_NAMES = 'collision_in_fn_names', - COVERAGE_CONTRACT = 'coverage-contract', - GENERIC_TYPES_CONTRACT = 'generic-types-contract', - MULTI_TOKEN_CONTRACT = 'multi-token-contract', - OPTIONS = 'options', - PAYABLE_ANNOTATION = 'payable-annotation', - PREDICATE_ADDRESS = 'predicate-address', - PREDICATE_ASSERT_VALUE = 'predicate-assert-value', - PREDICATE_ASSERT_NUMBER = 'predicate-assert-number', - PREDICATE_SUM = 'predicate-sum', - PREDICATE_BYTES = 'predicate-bytes', - PREDICATE_CONDITIONAL_INPUTS = 'predicate-conditional-inputs', - PREDICATE_FALSE = 'predicate-false', - PREDICATE_MAIN_ARGS_STRUCT = 'predicate-main-args-struct', - PREDICATE_MAIN_ARGS_VECTOR = 'predicate-main-args-vector', - PREDICATE_MULTI_ARGS = 'predicate-multi-args', - PREDICATE_RAW_SLICE = 'predicate-raw-slice', - PREDICATE_STD_LIB_STRING = 'predicate-std-lib-string', - PREDICATE_STRUCT = 'predicate-struct', - PREDICATE_TRIPLE_SIG = 'predicate-triple-sig', - PREDICATE_TRUE = 'predicate-true', - PREDICATE_WITH_CONFIGURABLE = 'predicate-with-configurable', - PREDICATE_U32 = 'predicate-u32', - PREDICATE_VECTOR_TYPES = 'predicate-vector-types', - PREDICATE_INPUT_DATA = 'predicate-input-data', - PREDICATE_VALIDATE_TRANSFER = 'predicate-validate-transfer', - RAW_SLICE = 'raw-slice', - REVERT_ERROR = 'revert-error', - SCRIPT_BYTES = 'script-bytes', - SCRIPT_CALL_CONTRACT = 'script-call-contract', - SCRIPT_MAIN_ARGS = 'script-main-args', - SCRIPT_MAIN_RETURN_STRUCT = 'script-main-return-struct', - SCRIPT_MAIN_TWO_ARGS = 'script-main-two-args', - SCRIPT_STD_LIB_STRING = 'script-std-lib-string', - SCRIPT_WITH_CONFIGURABLE = 'script-with-configurable', - REENTRANT_FOO = 'reentrant-foo', - REENTRANT_BAR = 'reentrant-bar', - SCRIPT_WITH_ARRAY = 'script-with-array', - SCRIPT_WITH_VECTOR = 'script-with-vector', - SCRIPT_WITH_VECTOR_ADVANCED = 'script-with-vector-advanced', - SCRIPT_WITH_VECTOR_MIXED = 'script-with-vector-mixed', - STD_LIB_STRING = 'std-lib-string', - STORAGE_TEST_CONTRACT = 'storage-test-contract', - TOKEN_ABI = 'token-abi', - TOKEN_CONTRACT = 'token-contract', - VECTOR_TYPES_CONTRACT = 'vector-types-contract', - VECTOR_TYPES_SCRIPT = 'vector-types-script', - VECTORS = 'vectors', -} - -export const getFuelGaugeForcProject = (project: FuelGaugeProjectsEnum) => - getForcProject({ - projectDir: join(__dirname, 'forc-projects', project), - projectName: project, - build: 'release', - });