From e71717a79b68ef33cbe854e3b2251a3c4218dcbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Mon, 20 May 2024 09:38:50 -0300 Subject: [PATCH 01/14] add generateFakeResources to Account class --- packages/account/src/account.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/account/src/account.ts b/packages/account/src/account.ts index d62faa37dc3..0f35430f10d 100644 --- a/packages/account/src/account.ts +++ b/packages/account/src/account.ts @@ -1,10 +1,12 @@ +import { UTXO_ID_LEN } from '@fuel-ts/abi-coder'; import { Address } from '@fuel-ts/address'; +import { randomBytes } from '@fuel-ts/crypto'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { AbstractAccount } from '@fuel-ts/interfaces'; import type { AbstractAddress, BytesLike } from '@fuel-ts/interfaces'; import type { BigNumberish, BN } from '@fuel-ts/math'; import { bn } from '@fuel-ts/math'; -import { arrayify, isDefined } from '@fuel-ts/utils'; +import { arrayify, hexlify, isDefined } from '@fuel-ts/utils'; import { clone } from 'ramda'; import type { FuelConnector } from './connectors'; @@ -50,6 +52,8 @@ export type EstimatedTxParams = Pick< >; const MAX_FUNDING_ATTEMPTS = 2; +export type FakeResources = Partial & Required>; + /** * `Account` provides an abstraction for interacting with accounts or wallets on the network. */ @@ -602,6 +606,22 @@ export class Account extends AbstractAccount { return this.provider.simulate(transactionRequest, { estimateTxDependencies: false }); } + /** + * Generates an array of fake resources based on the provided coins. + * + * @param coins - An array of `FakeResources` objects representing the coins. + * @returns An array of `Resource` objects with generated properties. + */ + generateFakeResources(coins: FakeResources[]): Array { + return coins.map((coin) => ({ + id: hexlify(randomBytes(UTXO_ID_LEN)), + owner: this.address, + blockCreated: bn(1), + txCreatedIdx: bn(1), + ...coin, + })); + } + private validateGasLimitAndMaxFee({ gasUsed, maxFee, From 809e974dbc92de5aca79720c86e8b9b19e27401d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Mon, 20 May 2024 09:39:07 -0300 Subject: [PATCH 02/14] add generateFakeResources to Predicate class --- packages/account/src/predicate/predicate.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/account/src/predicate/predicate.ts b/packages/account/src/predicate/predicate.ts index c16d07f3f96..191d4ce2216 100644 --- a/packages/account/src/predicate/predicate.ts +++ b/packages/account/src/predicate/predicate.ts @@ -5,6 +5,7 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import type { BytesLike } from '@fuel-ts/interfaces'; import { arrayify, hexlify } from '@fuel-ts/utils'; +import type { FakeResources } from '../account'; import { Account } from '../account'; import { transactionRequestify, @@ -13,6 +14,7 @@ import { } from '../providers'; import type { CallResult, + Coin, CoinQuantityLike, ExcludeResourcesOption, Provider, @@ -195,6 +197,20 @@ export class Predicate extends Account { })); } + /** + * Generates an array of fake resources based on the provided coins. + * + * @param coins - An array of `FakeResources` objects representing the coins. + * @returns An array of `Resource` objects with generated properties. + */ + generateFakeResources(coins: FakeResources[]): Array { + return this.generateFakeResources(coins).map((coin) => ({ + ...coin, + predicate: hexlify(this.bytes), + predicateData: hexlify(this.getPredicateData()), + })); + } + /** * Sets the configurable constants for the predicate. * From ea4661a45114bba358dea05034980dfa6c9b8d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Mon, 20 May 2024 09:39:22 -0300 Subject: [PATCH 03/14] add test case --- packages/account/src/account.test.ts | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/account/src/account.test.ts b/packages/account/src/account.test.ts index 54b3a2995ab..52efda3bd9e 100644 --- a/packages/account/src/account.test.ts +++ b/packages/account/src/account.test.ts @@ -6,6 +6,7 @@ import { bn } from '@fuel-ts/math'; import { PolicyType } from '@fuel-ts/transactions'; import { ASSET_A, ASSET_B } from '@fuel-ts/utils/test-utils'; +import type { FakeResources } from './account'; import { Account } from './account'; import { FUEL_NETWORK_URL } from './configs'; import { ScriptTransactionRequest, Provider } from './providers'; @@ -588,6 +589,40 @@ describe('Account', () => { expect(receiverBalances).toEqual([{ assetId: baseAssetId, amount: bn(110) }]); }); + it('can generate and use fake coins', async () => { + const sender = Wallet.generate({ + provider, + }); + + const amount1 = bn(100_000); + const amount2 = bn(200_000); + const amount3 = bn(300_000); + + const fakeCoinsConfig: FakeResources[] = [ + { amount: amount1, assetId: baseAssetId }, + { amount: amount2, assetId: ASSET_A }, + { amount: amount3, assetId: ASSET_B }, + ]; + + const fakeCoins = sender.generateFakeResources(fakeCoinsConfig); + const request = new ScriptTransactionRequest({ + gasLimit: bn(1500), + maxFee: bn(1700), + }); + + request.addResources(fakeCoins); + request.addCoinOutput(Address.fromRandom(), amount1.div(3), baseAssetId); + request.addCoinOutput(Address.fromRandom(), amount2, ASSET_A); + request.addCoinOutput(Address.fromRandom(), amount3, ASSET_B); + + const { dryRunStatus } = await provider.call(request, { + utxoValidation: false, + estimateTxDependencies: false, + }); + + expect(dryRunStatus?.type).toBe('DryRunSuccessStatus'); + }); + it('can withdraw an amount of base asset using mutiple uxtos', async () => { const sender = Wallet.generate({ provider, From 58fe72cb26cf019ac08698bf7e15c4f0fef11533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Tue, 21 May 2024 11:56:27 -0300 Subject: [PATCH 04/14] fix method type signature --- packages/account/src/predicate/predicate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/account/src/predicate/predicate.ts b/packages/account/src/predicate/predicate.ts index 191d4ce2216..bca27a6cf6e 100644 --- a/packages/account/src/predicate/predicate.ts +++ b/packages/account/src/predicate/predicate.ts @@ -203,8 +203,8 @@ export class Predicate extends Account { * @param coins - An array of `FakeResources` objects representing the coins. * @returns An array of `Resource` objects with generated properties. */ - generateFakeResources(coins: FakeResources[]): Array { - return this.generateFakeResources(coins).map((coin) => ({ + generateFakeResources(coins: FakeResources[]): Array { + return super.generateFakeResources(coins).map((coin) => ({ ...coin, predicate: hexlify(this.bytes), predicateData: hexlify(this.getPredicateData()), From 03624af8c086663a144fba43434db10a44746d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Tue, 21 May 2024 11:56:34 -0300 Subject: [PATCH 05/14] add test suite --- .../src/predicate/predicate-general.test.ts | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 packages/fuel-gauge/src/predicate/predicate-general.test.ts diff --git a/packages/fuel-gauge/src/predicate/predicate-general.test.ts b/packages/fuel-gauge/src/predicate/predicate-general.test.ts new file mode 100644 index 00000000000..eb69a1d4df3 --- /dev/null +++ b/packages/fuel-gauge/src/predicate/predicate-general.test.ts @@ -0,0 +1,68 @@ +import { ASSET_A, ASSET_B } from '@fuel-ts/utils/test-utils'; +import type { BN, FakeResources } from 'fuels'; +import { + Address, + FUEL_NETWORK_URL, + Predicate, + Provider, + ScriptTransactionRequest, + bn, +} from 'fuels'; + +import { FuelGaugeProjectsEnum, getFuelGaugeForcProject } from '../../test/fixtures'; + +describe('Predicate', () => { + it('can generate and use fake predicate coins', async () => { + const provider = await Provider.create(FUEL_NETWORK_URL); + const baseAssetId = provider.getBaseAssetId(); + const { binHexlified, abiContents } = getFuelGaugeForcProject( + FuelGaugeProjectsEnum.PREDICATE_SUM + ); + + const amount1 = bn(100_000); + const amount2 = bn(200_000); + const amount3 = bn(300_000); + + const fakeCoinsConfig: FakeResources[] = [ + { amount: amount1, assetId: baseAssetId }, + { amount: amount2, assetId: ASSET_A }, + { amount: amount3, assetId: ASSET_B }, + ]; + + const value2 = bn(200); + const value1 = bn(100); + + const predicate = new Predicate<[BN, BN]>({ + bytecode: binHexlified, + abi: abiContents, + provider, + inputData: [value1, value2], + }); + + const fakeCoins = predicate.generateFakeResources(fakeCoinsConfig); + + let request = new ScriptTransactionRequest({ + gasLimit: bn(1500), + maxFee: bn(1700), + }); + + fakeCoins.forEach((coin) => { + expect(coin.predicate).toBeDefined(); + expect(coin.predicateData).toBeDefined(); + }); + + request.addResources(fakeCoins); + request.addCoinOutput(Address.fromRandom(), amount1.div(3), baseAssetId); + request.addCoinOutput(Address.fromRandom(), amount2, ASSET_A); + request.addCoinOutput(Address.fromRandom(), amount3, ASSET_B); + + request = await provider.estimatePredicates(request); + + const { dryRunStatus } = await provider.call(request, { + utxoValidation: false, + estimateTxDependencies: false, + }); + + expect(dryRunStatus?.type).toBe('DryRunSuccessStatus'); + }); +}); From a74af46552a81ef1525154dfa767685953246579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Tue, 21 May 2024 12:16:05 -0300 Subject: [PATCH 06/14] liniting --- packages/account/src/predicate/predicate.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/account/src/predicate/predicate.ts b/packages/account/src/predicate/predicate.ts index bca27a6cf6e..b525d686e69 100644 --- a/packages/account/src/predicate/predicate.ts +++ b/packages/account/src/predicate/predicate.ts @@ -14,7 +14,6 @@ import { } from '../providers'; import type { CallResult, - Coin, CoinQuantityLike, ExcludeResourcesOption, Provider, From e3abd536ee5a5585a8596083f4324f811ec8f49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Tue, 21 May 2024 12:35:39 -0300 Subject: [PATCH 07/14] add test group to test suite --- packages/fuel-gauge/src/predicate/predicate-general.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/fuel-gauge/src/predicate/predicate-general.test.ts b/packages/fuel-gauge/src/predicate/predicate-general.test.ts index eb69a1d4df3..4fa1e2fb0a5 100644 --- a/packages/fuel-gauge/src/predicate/predicate-general.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-general.test.ts @@ -11,6 +11,9 @@ import { import { FuelGaugeProjectsEnum, getFuelGaugeForcProject } from '../../test/fixtures'; +/** + * @group node + */ describe('Predicate', () => { it('can generate and use fake predicate coins', async () => { const provider = await Provider.create(FUEL_NETWORK_URL); From e28b0cb88b5f78d95e4e8aac414e476d3c9e1f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Tue, 21 May 2024 13:19:15 -0300 Subject: [PATCH 08/14] add changeset --- .changeset/lazy-readers-flash.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lazy-readers-flash.md diff --git a/.changeset/lazy-readers-flash.md b/.changeset/lazy-readers-flash.md new file mode 100644 index 00000000000..04beb9b42db --- /dev/null +++ b/.changeset/lazy-readers-flash.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": minor +--- + +feat: implement `generateFakeResources` on `Account` class From fe9980afee894dc64b015bc876a6f99d0e873eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Tue, 21 May 2024 14:41:52 -0300 Subject: [PATCH 09/14] fix changeset --- .changeset/lazy-readers-flash.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/lazy-readers-flash.md b/.changeset/lazy-readers-flash.md index 04beb9b42db..532354c46ed 100644 --- a/.changeset/lazy-readers-flash.md +++ b/.changeset/lazy-readers-flash.md @@ -1,5 +1,5 @@ --- -"@fuel-ts/account": minor +"@fuel-ts/account": patch --- feat: implement `generateFakeResources` on `Account` class From 0524495324f6d739a915274681215e926829a90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Wed, 22 May 2024 14:34:50 -0300 Subject: [PATCH 10/14] refact test --- packages/account/src/account.test.ts | 3 ++- packages/fuel-gauge/src/predicate/predicate-general.test.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/account/src/account.test.ts b/packages/account/src/account.test.ts index 407b5912a10..2c8e9bf4241 100644 --- a/packages/account/src/account.test.ts +++ b/packages/account/src/account.test.ts @@ -667,6 +667,7 @@ describe('Account', () => { const amount1 = bn(100_000); const amount2 = bn(200_000); const amount3 = bn(300_000); + const amountToTransferBaseAsset = bn(1000); const fakeCoinsConfig: FakeResources[] = [ { amount: amount1, assetId: baseAssetId }, @@ -681,7 +682,7 @@ describe('Account', () => { }); request.addResources(fakeCoins); - request.addCoinOutput(Address.fromRandom(), amount1.div(3), baseAssetId); + request.addCoinOutput(Address.fromRandom(), amountToTransferBaseAsset, baseAssetId); request.addCoinOutput(Address.fromRandom(), amount2, ASSET_A); request.addCoinOutput(Address.fromRandom(), amount3, ASSET_B); diff --git a/packages/fuel-gauge/src/predicate/predicate-general.test.ts b/packages/fuel-gauge/src/predicate/predicate-general.test.ts index 4fa1e2fb0a5..d769d2a4029 100644 --- a/packages/fuel-gauge/src/predicate/predicate-general.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-general.test.ts @@ -25,6 +25,7 @@ describe('Predicate', () => { const amount1 = bn(100_000); const amount2 = bn(200_000); const amount3 = bn(300_000); + const amountToTransferBaseAsset = bn(1000); const fakeCoinsConfig: FakeResources[] = [ { amount: amount1, assetId: baseAssetId }, @@ -55,7 +56,7 @@ describe('Predicate', () => { }); request.addResources(fakeCoins); - request.addCoinOutput(Address.fromRandom(), amount1.div(3), baseAssetId); + request.addCoinOutput(Address.fromRandom(), amountToTransferBaseAsset, baseAssetId); request.addCoinOutput(Address.fromRandom(), amount2, ASSET_A); request.addCoinOutput(Address.fromRandom(), amount3, ASSET_B); From a298df4ff3bf7d76f365e9f209c32d59409956c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Tue, 28 May 2024 12:17:07 -0300 Subject: [PATCH 11/14] add script to doc snippets --- apps/docs-snippets/test/fixtures/forc-projects/Forc.toml | 1 + apps/docs-snippets/test/fixtures/forc-projects/index.ts | 1 + .../test/fixtures/forc-projects/return-script/Forc.toml | 6 ++++++ .../test/fixtures/forc-projects/return-script/src/main.sw | 7 +++++++ 4 files changed, 15 insertions(+) create mode 100644 apps/docs-snippets/test/fixtures/forc-projects/return-script/Forc.toml create mode 100644 apps/docs-snippets/test/fixtures/forc-projects/return-script/src/main.sw diff --git a/apps/docs-snippets/test/fixtures/forc-projects/Forc.toml b/apps/docs-snippets/test/fixtures/forc-projects/Forc.toml index d0d87a6a099..1d453e4e9e3 100644 --- a/apps/docs-snippets/test/fixtures/forc-projects/Forc.toml +++ b/apps/docs-snippets/test/fixtures/forc-projects/Forc.toml @@ -16,6 +16,7 @@ members = [ "simple-token-abi", "echo-configurables", "transfer-to-address", + "return-script", "return-true-predicate", "echo-employee-data-vector", "whitelisted-address-predicate", diff --git a/apps/docs-snippets/test/fixtures/forc-projects/index.ts b/apps/docs-snippets/test/fixtures/forc-projects/index.ts index dd0ea7f8ac8..1db65624c5a 100644 --- a/apps/docs-snippets/test/fixtures/forc-projects/index.ts +++ b/apps/docs-snippets/test/fixtures/forc-projects/index.ts @@ -12,6 +12,7 @@ export enum DocSnippetProjectsEnum { SUM_OPTION_U8 = 'sum-option-u8', ECHO_U64_ARRAY = 'echo-u64-array', RETURN_CONTEXT = 'return-context', + RETURN_SCRIPT = 'return-script', TOKEN_DEPOSITOR = 'token-depositor', TOKEN = 'token', LIQUIDITY_POOL = 'liquidity-pool', diff --git a/apps/docs-snippets/test/fixtures/forc-projects/return-script/Forc.toml b/apps/docs-snippets/test/fixtures/forc-projects/return-script/Forc.toml new file mode 100644 index 00000000000..e8fdc98ec27 --- /dev/null +++ b/apps/docs-snippets/test/fixtures/forc-projects/return-script/Forc.toml @@ -0,0 +1,6 @@ +[project] +entry = "main.sw" +license = "Apache-2.0" +name = "return-script" + +[dependencies] diff --git a/apps/docs-snippets/test/fixtures/forc-projects/return-script/src/main.sw b/apps/docs-snippets/test/fixtures/forc-projects/return-script/src/main.sw new file mode 100644 index 00000000000..290ac83ef0d --- /dev/null +++ b/apps/docs-snippets/test/fixtures/forc-projects/return-script/src/main.sw @@ -0,0 +1,7 @@ +// #region generate-fake-resources-1 +script; + +fn main() -> u64 { + return 1337; +} +// #endregion generate-fake-resources-1 From 33c46397835fa686a17407de41f2a28f885213ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Tue, 28 May 2024 12:17:40 -0300 Subject: [PATCH 12/14] add doc page --- .../cookbook/generate-fake-resources.test.ts | 54 +++++++++++++++++++ apps/docs/.vitepress/config.ts | 4 ++ .../guide/cookbook/generate-fake-resources.md | 13 +++++ 3 files changed, 71 insertions(+) create mode 100644 apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts create mode 100644 apps/docs/src/guide/cookbook/generate-fake-resources.md diff --git a/apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts b/apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts new file mode 100644 index 00000000000..8eafe192ce4 --- /dev/null +++ b/apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts @@ -0,0 +1,54 @@ +import type { TransactionResultReturnDataReceipt } from 'fuels'; +import { + FUEL_NETWORK_URL, + Provider, + ReceiptType, + ScriptTransactionRequest, + Wallet, + bn, +} from 'fuels'; + +import { + DocSnippetProjectsEnum, + getDocsSnippetsForcProject, +} from '../../../test/fixtures/forc-projects'; + +describe(__filename, () => { + it('should generate fake resources just fine', async () => { + const provider = await Provider.create(FUEL_NETWORK_URL); + const wallet = Wallet.generate({ provider }); + const baseAssetId = provider.getBaseAssetId(); + + const { binHexlified: scriptHexBytes } = getDocsSnippetsForcProject( + DocSnippetProjectsEnum.RETURN_SCRIPT + ); + + // #region generate-fake-resources-2 + const transactionRequest = new ScriptTransactionRequest({ + gasLimit: bn(62_000), + maxFee: bn(60_000), + script: scriptHexBytes, + }); + + const resources = wallet.generateFakeResources([ + { + amount: bn(100_000), + assetId: baseAssetId, + }, + ]); + + transactionRequest.addResources(resources); + + const dryrunResult = await provider.call(transactionRequest); + + const returnReceipt = dryrunResult.receipts.find( + (receipt) => receipt.type === ReceiptType.ReturnData + ) as TransactionResultReturnDataReceipt; + + const { data: returnedValue } = returnReceipt; + // #endregion generate-fake-resources-2 + + expect(bn(returnedValue).toNumber()).toBe(1337); + expect(dryrunResult.dryRunStatus?.type).toBe('DryRunSuccessStatus'); + }); +}); diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index f5103710a36..8ccb9a333f0 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -358,6 +358,10 @@ export default defineConfig({ text: 'Custom Transactions from Contract Calls', link: '/guide/cookbook/custom-transactions-from-contract-calls', }, + { + text: 'Generate Fake Resources', + link: '/guide/cookbook/generate-fake-resources', + }, { text: 'Transactions with Multiple Signers', link: '/guide/cookbook/transactions-with-multiple-signers', diff --git a/apps/docs/src/guide/cookbook/generate-fake-resources.md b/apps/docs/src/guide/cookbook/generate-fake-resources.md new file mode 100644 index 00000000000..7ceb8fd8ab2 --- /dev/null +++ b/apps/docs/src/guide/cookbook/generate-fake-resources.md @@ -0,0 +1,13 @@ +# Generate Fake Resources + +When working with an unfunded account, you can generate fake resources to perform a dry-run on your transactions. This is useful for testing purposes without the need for real funds. + +Below is an example script that returns the value `1337`. You can use fake resources to execute a dry-run of this script and obtain the returned value. + +<<< @/../../docs-snippets/test/fixtures/forc-projects/return-script/src/main.sw#generate-fake-resources-1{rust:line-numbers} + +To execute a dry-run, use the `Provider.call` method. Ensure you set the `utxo_validation` flag to true, as this script uses fake UTXOs: + +<<< @/../../docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts#generate-fake-resources-2{ts:line-numbers} + +By setting `utxo_validation` to `true`, you can successfully execute the dry-run and retrieve the returned value from the script without requiring actual funds. From 902a21a650cffc6af48b14e832f519c918aeff4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Wed, 29 May 2024 09:33:31 -0300 Subject: [PATCH 13/14] add test group --- .../src/guide/cookbook/generate-fake-resources.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts b/apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts index 8eafe192ce4..c169a7aed39 100644 --- a/apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts +++ b/apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts @@ -13,6 +13,9 @@ import { getDocsSnippetsForcProject, } from '../../../test/fixtures/forc-projects'; +/** + * @group node + */ describe(__filename, () => { it('should generate fake resources just fine', async () => { const provider = await Provider.create(FUEL_NETWORK_URL); From 8955f97225eb31e98102d63a7a83c2055925eba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Thu, 30 May 2024 12:28:30 -0300 Subject: [PATCH 14/14] fix funding amounts --- packages/account/src/account.test.ts | 4 ++-- packages/fuel-gauge/src/predicate/predicate-general.test.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/account/src/account.test.ts b/packages/account/src/account.test.ts index af504ff9b60..73b7d9f368e 100644 --- a/packages/account/src/account.test.ts +++ b/packages/account/src/account.test.ts @@ -677,8 +677,8 @@ describe('Account', () => { const fakeCoins = sender.generateFakeResources(fakeCoinsConfig); const request = new ScriptTransactionRequest({ - gasLimit: bn(1500), - maxFee: bn(1700), + gasLimit: bn(60_000), + maxFee: bn(62_000), }); request.addResources(fakeCoins); diff --git a/packages/fuel-gauge/src/predicate/predicate-general.test.ts b/packages/fuel-gauge/src/predicate/predicate-general.test.ts index d769d2a4029..773317b1474 100644 --- a/packages/fuel-gauge/src/predicate/predicate-general.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-general.test.ts @@ -22,7 +22,7 @@ describe('Predicate', () => { FuelGaugeProjectsEnum.PREDICATE_SUM ); - const amount1 = bn(100_000); + const amount1 = bn(500_000); const amount2 = bn(200_000); const amount3 = bn(300_000); const amountToTransferBaseAsset = bn(1000); @@ -46,8 +46,8 @@ describe('Predicate', () => { const fakeCoins = predicate.generateFakeResources(fakeCoinsConfig); let request = new ScriptTransactionRequest({ - gasLimit: bn(1500), - maxFee: bn(1700), + gasLimit: bn(270_000), + maxFee: bn(250_000), }); fakeCoins.forEach((coin) => {