From 0585ee4f1f862cec97037822a856b3faea29c1e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nedim=20Salki=C4=87?= Date: Thu, 14 Nov 2024 04:20:36 +0100 Subject: [PATCH] chore: use typegen'd outputs in some fuel-gauge tests (#3393) --- .changeset/orange-panthers-lay.md | 4 +++ .../fuel-gauge/src/advanced-logging.test.ts | 6 ++-- .../predicate/predicate-configurables.test.ts | 34 ++++++------------- 3 files changed, 17 insertions(+), 27 deletions(-) create mode 100644 .changeset/orange-panthers-lay.md diff --git a/.changeset/orange-panthers-lay.md b/.changeset/orange-panthers-lay.md new file mode 100644 index 00000000000..c87f6bfe52a --- /dev/null +++ b/.changeset/orange-panthers-lay.md @@ -0,0 +1,4 @@ +--- +--- + +chore: use typegen'd outputs in some fuel-gauge tests diff --git a/packages/fuel-gauge/src/advanced-logging.test.ts b/packages/fuel-gauge/src/advanced-logging.test.ts index ad7f42a0616..44d6b51d469 100644 --- a/packages/fuel-gauge/src/advanced-logging.test.ts +++ b/packages/fuel-gauge/src/advanced-logging.test.ts @@ -1,5 +1,5 @@ import type { FuelError } from '@fuel-ts/errors'; -import { Script, bn } from 'fuels'; +import { bn } from 'fuels'; import { launchTestNode } from 'fuels/test-utils'; import { @@ -280,7 +280,7 @@ describe('Advanced Logging', () => { wallets: [wallet], } = launched; - const script = new Script(ScriptCallContract.bytecode, ScriptCallContract.abi, wallet); + const script = new ScriptCallContract(wallet); const { waitForResult } = await script.functions .main(advancedLogContract.id.toB256(), otherAdvancedLogContract.id.toB256(), amount) @@ -305,7 +305,7 @@ describe('Advanced Logging', () => { wallets: [wallet], } = launched; - const script = new Script(ScriptCallContract.bytecode, ScriptCallContract.abi, wallet); + const script = new ScriptCallContract(wallet); const request = await script.functions .main(advancedLogContract.id.toB256(), otherAdvancedLogContract.id.toB256(), amount) diff --git a/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts b/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts index ab0f6b5560c..582f757e1a2 100644 --- a/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts @@ -1,4 +1,4 @@ -import { getRandomB256, WalletUnlocked, Predicate, FuelError } from 'fuels'; +import { getRandomB256, WalletUnlocked, FuelError } from 'fuels'; import { expectToThrowFuelError, launchTestNode } from 'fuels/test-utils'; import { PredicateTrue, PredicateWithConfigurable } from '../../test/typegen'; @@ -26,9 +26,7 @@ describe('Predicate', () => { wallets: [wallet], } = launched; - const predicate = new Predicate({ - abi: PredicateWithConfigurable.abi, - bytecode: PredicateWithConfigurable.bytecode, + const predicate = new PredicateWithConfigurable({ provider: wallet.provider, data: [defaultValues.FEE, defaultValues.ADDRESS], // set predicate input data to be the same as default configurable value }); @@ -69,9 +67,7 @@ describe('Predicate', () => { const configurableConstants = { FEE: 35 }; expect(configurableConstants.FEE).not.toEqual(defaultValues.FEE); - const predicate = new Predicate({ - abi: PredicateWithConfigurable.abi, - bytecode: PredicateWithConfigurable.bytecode, + const predicate = new PredicateWithConfigurable({ provider, data: [configurableConstants.FEE, defaultValues.ADDRESS], configurableConstants, @@ -114,9 +110,7 @@ describe('Predicate', () => { const configurableConstants = { ADDRESS: getRandomB256() }; expect(configurableConstants.ADDRESS).not.toEqual(defaultValues.ADDRESS); - const predicate = new Predicate({ - abi: PredicateWithConfigurable.abi, - bytecode: PredicateWithConfigurable.bytecode, + const predicate = new PredicateWithConfigurable({ provider, data: [defaultValues.FEE, configurableConstants.ADDRESS], configurableConstants, @@ -163,9 +157,7 @@ describe('Predicate', () => { expect(configurableConstants.FEE).not.toEqual(defaultValues.FEE); expect(configurableConstants.ADDRESS).not.toEqual(defaultValues.ADDRESS); - const predicate = new Predicate({ - abi: PredicateWithConfigurable.abi, - bytecode: PredicateWithConfigurable.bytecode, + const predicate = new PredicateWithConfigurable({ provider, data: [configurableConstants.FEE, configurableConstants.ADDRESS], configurableConstants, @@ -245,9 +237,7 @@ describe('Predicate', () => { wallets: [wallet], } = launched; - const predicate = new Predicate({ - abi: PredicateWithConfigurable.abi, - bytecode: PredicateWithConfigurable.bytecode, + const predicate = new PredicateWithConfigurable({ provider, }); @@ -269,11 +259,9 @@ describe('Predicate', () => { await expectToThrowFuelError( () => - new Predicate({ - bytecode: PredicateTrue.bytecode, - abi: PredicateTrue.abi, + new PredicateTrue({ provider, - data: ['NADA'], + // @ts-expect-error testing invalid configurable configurableConstants: { constant: 'NADA', }, @@ -292,12 +280,10 @@ describe('Predicate', () => { await expectToThrowFuelError( () => - new Predicate({ - bytecode: PredicateWithConfigurable.bytecode, - abi: PredicateWithConfigurable.abi, + new PredicateWithConfigurable({ provider, - data: ['NADA'], configurableConstants: { + // @ts-expect-error testing invalid configurable NOPE: 'NADA', }, }),