Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: added test for equality of transaction responses #2970

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion packages/fuel-gauge/src/transaction-response.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ErrorCode } from '@fuel-ts/errors';
import { TransactionResponse, Wallet, ScriptTransactionRequest } from 'fuels';
import { TransactionResponse, Wallet, ScriptTransactionRequest, normalizeJSON, bn } from 'fuels';

Check warning on line 2 in packages/fuel-gauge/src/transaction-response.test.ts

View workflow job for this annotation

GitHub Actions / Lint

'bn' is defined but never used
import { expectToThrowFuelError, launchTestNode } from 'fuels/test-utils';
import type { MockInstance } from 'vitest';

Expand Down Expand Up @@ -102,6 +102,31 @@
expect(response.gqlTransaction?.id).toBe(transactionId);
});

it('should ensure that the transaction result from ID and request are equal', async () => {
using launched = await launchTestNode();

const {
provider,
wallets: [adminWallet],
} = launched;

const baseAssetId = provider.getBaseAssetId();
const recipient = Wallet.generate({ provider });

// From transaction request
const transfer = await adminWallet.transfer(recipient.address, 100, baseAssetId);
const responseFromRequest = await transfer.waitForResult();
const summaryFromRequest = await transfer.getTransactionSummary();

// From transaction ID
const response = await TransactionResponse.create(transfer.id, provider);
const responseFromId = await response.assembleResult();
const summaryFromId = await response.getTransactionSummary();

expect(normalizeJSON(responseFromRequest)).toEqual(normalizeJSON(responseFromId));
expect(normalizeJSON(summaryFromRequest)).toEqual(normalizeJSON(summaryFromId));
});

it('should ensure getTransactionSummary fetches a transaction and assembles transaction summary', async () => {
using launched = await launchTestNode({
nodeOptions: {
Expand Down
Loading