From c83efa04182d22778927262ad04b4c907fe38197 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:49:19 -0300 Subject: [PATCH] chore: add e2e test for decode txs (#2354) --- .changeset/polite-carpets-return.md | 2 ++ packages/fuel-gauge/src/e2e-script.test.ts | 37 +++++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 .changeset/polite-carpets-return.md diff --git a/.changeset/polite-carpets-return.md b/.changeset/polite-carpets-return.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/polite-carpets-return.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/fuel-gauge/src/e2e-script.test.ts b/packages/fuel-gauge/src/e2e-script.test.ts index 78909543a99..bf90d9bbb5f 100644 --- a/packages/fuel-gauge/src/e2e-script.test.ts +++ b/packages/fuel-gauge/src/e2e-script.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -import { Provider, WalletUnlocked } from 'fuels'; +import { Provider, TransactionType, WalletUnlocked } from 'fuels'; import { getScript } from './utils'; @@ -8,14 +8,30 @@ import { getScript } from './utils'; * @group e2e */ describe('Live Script Test', () => { - it('can use script against live Fuel Node', async () => { + const MINT_TX_ID = '0x03299946676ddc0044a52a675dd201d3173886c998a7301262141334b6d5a29e'; + const UPGRADE_TX_ID = '0xe2c03044fe708e9b112027881baf9f892e6b64a630a629998922c1cab918c094'; + const UPLOAD_TX_ID = '0x94bc2a189b8211796c8fe5b9c6b67624fe97d2007e104bf1b30739944f43bd73'; + + let provider: Provider; + let wallet: WalletUnlocked; + let shouldSkip: boolean; + + beforeAll(async () => { if (!process.env.TEST_WALLET_PVT_KEY || !process.env.FUEL_TESTNET_NETWORK_URL) { console.log('Skipping live Fuel Node test'); + shouldSkip = true; + return; + } + + provider = await Provider.create(process.env.FUEL_TESTNET_NETWORK_URL); + wallet = new WalletUnlocked(process.env.TEST_WALLET_PVT_KEY, provider); + }); + + it('can use script against live Fuel Node', async () => { + if (shouldSkip) { return; } - const provider = await Provider.create(process.env.FUEL_TESTNET_NETWORK_URL); - const wallet = new WalletUnlocked(process.env.TEST_WALLET_PVT_KEY, provider); const scriptInstance = getScript<[boolean], boolean>('script-main-arg-bool', wallet); let output: boolean = false; @@ -39,4 +55,17 @@ describe('Live Script Test', () => { expect(output).toBe(true); }); + + it.each([ + ['Mint', MINT_TX_ID, TransactionType.Mint], + ['Upgrade', UPGRADE_TX_ID, TransactionType.Upgrade], + ['Upload', UPLOAD_TX_ID, TransactionType.Upload], + ])('can query and decode a %s transaction', async (_, txId, type) => { + if (shouldSkip) { + return; + } + const transaction = await provider.getTransaction(txId); + + expect(transaction?.type).toBe(type); + }); });