From 2f3ac25b45cb7a55e46573e9a0961a2a46f988c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Fri, 22 Dec 2023 15:00:35 -0300 Subject: [PATCH 1/4] fix flaky test --- packages/providers/test/provider.test.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/providers/test/provider.test.ts b/packages/providers/test/provider.test.ts index 66dc48cce75..3b6880cdcc6 100644 --- a/packages/providers/test/provider.test.ts +++ b/packages/providers/test/provider.test.ts @@ -8,6 +8,7 @@ import type { Receipt } from '@fuel-ts/transactions'; import { InputType, ReceiptType, TransactionType } from '@fuel-ts/transactions'; import { versions } from '@fuel-ts/versions'; import * as fuelTsVersionsMod from '@fuel-ts/versions'; +import exp from 'constants'; import { getBytesCopy, hexlify } from 'ethers'; import type { BytesLike } from 'ethers'; @@ -298,11 +299,17 @@ describe('Provider', () => { const { height: latestBlockNumberBeforeProduce } = block; const amountOfBlocksToProduce = 3; - const latestBlockNumber = await provider.produceBlocks(amountOfBlocksToProduce); + await provider.produceBlocks(amountOfBlocksToProduce); - expect(latestBlockNumber.toHex()).toEqual( - latestBlockNumberBeforeProduce.add(amountOfBlocksToProduce).toHex() - ); + const blocks = await provider.getBlocks({ + last: 20, + }); + + const oldLatestIdx = blocks.findIndex((b) => b.height.eq(latestBlockNumberBeforeProduce)); + + const newBlocks = blocks.slice(oldLatestIdx + 1); + + expect(newBlocks.length).toBeGreaterThanOrEqual(amountOfBlocksToProduce); // #endregion Provider-produce-blocks }); From c4faffc56631709a853bf8b34446d5370d74d0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Fri, 22 Dec 2023 15:02:53 -0300 Subject: [PATCH 2/4] add empty changeset --- .changeset/wicked-timers-push.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/wicked-timers-push.md diff --git a/.changeset/wicked-timers-push.md b/.changeset/wicked-timers-push.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/wicked-timers-push.md @@ -0,0 +1,2 @@ +--- +--- From 0779def6c6e3b3b8b0f87e8b62b369f82bd4986a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Fri, 22 Dec 2023 15:06:05 -0300 Subject: [PATCH 3/4] remove accidental import --- packages/providers/test/provider.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/providers/test/provider.test.ts b/packages/providers/test/provider.test.ts index 3b6880cdcc6..0e114f3a3e3 100644 --- a/packages/providers/test/provider.test.ts +++ b/packages/providers/test/provider.test.ts @@ -8,7 +8,6 @@ import type { Receipt } from '@fuel-ts/transactions'; import { InputType, ReceiptType, TransactionType } from '@fuel-ts/transactions'; import { versions } from '@fuel-ts/versions'; import * as fuelTsVersionsMod from '@fuel-ts/versions'; -import exp from 'constants'; import { getBytesCopy, hexlify } from 'ethers'; import type { BytesLike } from 'ethers'; From c36a580b3501aa6bdeb289192641299c658e5187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Fri, 22 Dec 2023 15:20:13 -0300 Subject: [PATCH 4/4] Update packages/providers/test/provider.test.ts Co-authored-by: Anderson Arboleya --- packages/providers/test/provider.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/providers/test/provider.test.ts b/packages/providers/test/provider.test.ts index 0e114f3a3e3..246e45b3799 100644 --- a/packages/providers/test/provider.test.ts +++ b/packages/providers/test/provider.test.ts @@ -304,9 +304,9 @@ describe('Provider', () => { last: 20, }); - const oldLatestIdx = blocks.findIndex((b) => b.height.eq(latestBlockNumberBeforeProduce)); + const lastBlockIndex = blocks.findIndex((b) => b.height.eq(latestBlockNumberBeforeProduce)); - const newBlocks = blocks.slice(oldLatestIdx + 1); + const newBlocks = blocks.slice(lastBlockIndex + 1); expect(newBlocks.length).toBeGreaterThanOrEqual(amountOfBlocksToProduce); // #endregion Provider-produce-blocks