Skip to content

Commit

Permalink
fix: launchTestNode multiple contracts type inference (#2756)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedsalk committed Jul 11, 2024
1 parent 1b4b033 commit 7579259
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/soft-cycles-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/contract": patch
---

fix: `launchTestNode` multiple contracts type inference
2 changes: 1 addition & 1 deletion packages/contract/src/test-utils/launch-test-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function getWalletForDeployment(config: DeployContractConfig, wallets: WalletUnl
return wallets[config.walletIndex];
}

export async function launchTestNode<TFactories extends DeployContractConfig[]>({
export async function launchTestNode<const TFactories extends DeployContractConfig[]>({
providerOptions = {},
walletsConfig = {},
nodeOptions = {},
Expand Down
29 changes: 29 additions & 0 deletions packages/fuel-gauge/src/launch-test-node-types.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { launchTestNode } from 'fuels/test-utils';

import type { AdvancedLoggingAbi, CallTestContractAbi } from '../test/typegen';
import { AdvancedLoggingAbi__factory, CallTestContractAbi__factory } from '../test/typegen';
import AdvancedLoggingBytecode from '../test/typegen/contracts/AdvancedLoggingAbi.hex';
import CallTestContractBytecode from '../test/typegen/contracts/CallTestContractAbi.hex';

/**
* @group node
* @group browser
*/
describe('type level tests for launchTestNode', () => {
test('infers types correctly', async () => {
using launched = await launchTestNode({
contractsConfigs: [
{ deployer: AdvancedLoggingAbi__factory, bytecode: AdvancedLoggingBytecode },
{ deployer: CallTestContractAbi__factory, bytecode: CallTestContractBytecode },
{ deployer: AdvancedLoggingAbi__factory, bytecode: AdvancedLoggingBytecode },
],
});
const {
contracts: [c1, c2, c3],
} = launched;

expectTypeOf(c1).toMatchTypeOf<AdvancedLoggingAbi>();
expectTypeOf(c2).toMatchTypeOf<CallTestContractAbi>();
expectTypeOf(c3).toMatchTypeOf<AdvancedLoggingAbi>();
});
});

0 comments on commit 7579259

Please sign in to comment.