Skip to content

Commit

Permalink
chore: fixing flaky tests (#3115)
Browse files Browse the repository at this point in the history
* Increasing test's timeout

* Adding changeset
  • Loading branch information
arboleya authored Sep 6, 2024
1 parent 2ce9ce5 commit 2ad34e1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 29 deletions.
4 changes: 4 additions & 0 deletions .changeset/pink-apricots-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore: fixing flaky tests
4 changes: 2 additions & 2 deletions packages/account/src/test-utils/launchNode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ vi.mock('fs', async () => {
/**
* @group node
*/
describe('launchNode', { timeout: 10000 }, () => {
describe('launchNode', () => {
test('using ephemeral port 0 is possible', async () => {
const { cleanup, port, url } = await launchNode({ port: '0' });
expect(await fetch(url)).toBeTruthy();
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('launchNode', { timeout: 10000 }, () => {
cleanup();
});

test('should throw on error and log error message', async () => {
test('should throw on error and log error message', { timeout: 15000 }, async () => {
const logSpy = vi.spyOn(console, 'log');

const invalidCoin = {
Expand Down
58 changes: 31 additions & 27 deletions packages/fuel-gauge/src/contract-factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,33 +292,37 @@ describe('Contract Factory', () => {
expect(value.toNumber()).toBe(1001);
}, 15000);

it('deploys large contracts via blobs and awaits transaction id', async () => {
using launched = await launchTestNode({
nodeOptions: {
args: ['--tx-pool-ttl', '1s'],
},
providerOptions: {
resourceCacheTTL: -1,
},
});

const {
wallets: [wallet],
} = launched;

const factory = new ContractFactory(LargeContractFactory.bytecode, LargeContract.abi, wallet);
const deploy = await factory.deployAsBlobTx<LargeContract>();
const initTxId = deploy.waitForTransactionId();
expect(initTxId).toStrictEqual(new Promise(() => {}));
const { contract } = await deploy.waitForResult();
expect(contract.id).toBeDefined();
const awaitTxId = await deploy.waitForTransactionId();
expect(awaitTxId).toBeTruthy();

const call = await contract.functions.something().call();
const { value } = await call.waitForResult();
expect(value.toNumber()).toBe(1001);
});
it(
'deploys large contracts via blobs and awaits transaction id',
{ timeout: 15000 },
async () => {
using launched = await launchTestNode({
nodeOptions: {
args: ['--tx-pool-ttl', '1s'],
},
providerOptions: {
resourceCacheTTL: -1,
},
});

const {
wallets: [wallet],
} = launched;

const factory = new ContractFactory(LargeContractFactory.bytecode, LargeContract.abi, wallet);
const deploy = await factory.deployAsBlobTx<LargeContract>();
const initTxId = deploy.waitForTransactionId();
expect(initTxId).toStrictEqual(new Promise(() => {}));
const { contract } = await deploy.waitForResult();
expect(contract.id).toBeDefined();
const awaitTxId = await deploy.waitForTransactionId();
expect(awaitTxId).toBeTruthy();

const call = await contract.functions.something().call();
const { value } = await call.waitForResult();
expect(value.toNumber()).toBe(1001);
}
);

it('deploys large contracts via blobs [padded]', async () => {
using launched = await launchTestNode({
Expand Down

0 comments on commit 2ad34e1

Please sign in to comment.