Skip to content

Commit

Permalink
chore: add e2e test for decode txs (#2354)
Browse files Browse the repository at this point in the history
  • Loading branch information
Torres-ssf authored May 21, 2024
1 parent 6d1db46 commit c83efa0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .changeset/polite-carpets-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
37 changes: 33 additions & 4 deletions packages/fuel-gauge/src/e2e-script.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import { Provider, WalletUnlocked } from 'fuels';
import { Provider, TransactionType, WalletUnlocked } from 'fuels';

import { getScript } from './utils';

Expand All @@ -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;
Expand All @@ -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);
});
});

1 comment on commit c83efa0

@Oly6
Copy link

@Oly6 Oly6 commented on c83efa0 May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok good

Please sign in to comment.