Skip to content

Commit ec13d29

Browse files
authored
fix: provider async methods and tests (#3867)
* Provider initialization must be awaited on a per case basis * Adding changeset * Awaiting provider initialization * Fixing test * Fixing script project I mean, was this ever used before? * Fixing test * Increasing POA interval a bit
1 parent f4b22b7 commit ec13d29

File tree

6 files changed

+15
-5
lines changed

6 files changed

+15
-5
lines changed

.changeset/light-moose-visit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fuel-ts/account": patch
3+
---
4+
5+
fix: provider async methods and tests

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"test:coverage-diff": "tsx ./scripts/tests-coverage-diff.ts",
2929
"test:watch": "vitest --watch --config vitest.node.config.mts --project node $(scripts/tests-find.sh --node)",
3030
"test:validate": "./scripts/tests-validate.sh",
31-
"test:browser:filter": "vitest --run --coverage false --config vitest.browser.config.mts --project node",
31+
"test:browser:filter": "vitest --run --coverage false --config vitest.browser.config.mts --project browser",
3232
"test:e2e": "vitest --run --config vitest.node.config.mts --project node $(scripts/tests-find.sh --e2e)",
3333
"test:integration": "vitest --run --config vitest.node.config.mts --project node $(scripts/tests-find.sh --integration)",
3434
"test:forc": "turbo run test:forc",

packages/account/src/providers/provider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ export default class Provider {
750750
* Returns some helpful parameters related to gas fees.
751751
*/
752752
async getGasConfig() {
753+
await this.init();
754+
753755
const {
754756
txParameters: { maxGasPerTx },
755757
predicateParameters: { maxGasPerPredicate },

packages/account/src/providers/utils/serialization.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ describe('Serialization', () => {
7474
using launched = await setupTestProviderAndWallets();
7575
const { provider } = launched;
7676

77+
await provider.init();
78+
7779
const cache = await serializeProviderCache(provider);
7880
const deserializedCache = deserializeProviderCache(cache);
7981

@@ -89,7 +91,6 @@ describe('Serialization', () => {
8991
using launched = await setupTestProviderAndWallets();
9092
const { provider } = launched;
9193
const cache = await serializeProviderCache(provider);
92-
9394
const jsonCache = JSON.parse(JSON.stringify(cache));
9495

9596
expect(jsonCache).toEqual(cache);

packages/account/src/test-utils/setup-test-provider-and-wallets.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export async function setupTestProviderAndWallets({
103103

104104
try {
105105
provider = new Provider(url, providerOptions);
106-
await provider.init();
107106
} catch (err) {
108107
cleanup();
109108
throw err;

packages/fuel-gauge/src/transaction.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ describe('Transaction', () => {
2121
it('should ensure a mint transaction can be decoded just fine', async () => {
2222
using launched = await launchTestNode({
2323
nodeOptions: {
24-
args: ['--poa-instant', 'false', '--poa-interval-period', '1ms'],
25-
loggingEnabled: false,
24+
args: ['--poa-instant', 'false', '--poa-interval-period', '100ms'],
2625
},
2726
});
27+
28+
// Wait 1ms for the transaction to be added
29+
await sleep(200);
30+
2831
const { provider } = launched;
2932

3033
const {

0 commit comments

Comments
 (0)