The launchNodeAndGetWallets
method lets you launch a local Fuel node with various customizations.
In the code snippet below, we provide a snapshot directory containing a couple of files:
chainConfig.json
stateCondig.json
metadata.json
You can use custom snapshots to customize things like the chain's consensus parameters or specify some initial states for the chain.
Here are some examples:
const snapshotDir = path.join(cwd(), '.fuel-core/configs');
const { stop, provider } = await launchNodeAndGetWallets({
launchNodeOptions: {
args: ['--snapshot', snapshotDir],
loggingEnabled: false,
},
});
const {
consensusParameters: {
feeParameters: { gasPerByte },
},
} = provider.getChain();
const expectedGasPerByte = 63;
expect(gasPerByte.toNumber()).toEqual(expectedGasPerByte);
stop();
As you can see in the previous code snippet, you can optionally pass in a walletCount
and some launchNodeOptions
to the launchNodeAndGetWallets
method.
The walletCount
option lets you specify how many wallets you want to generate. The default value is 10.
The launchNodeOptions
option lets you specify some additional options for the node. The available options are:
/**
* Launches a fuel-core node.
* @param ip - the ip to bind to. (optional, defaults to 0.0.0.0)
* @param port - the port to bind to. (optional, defaults to 4000 or the next available port)
* @param args - additional arguments to pass to fuel-core.
* @param fuelCorePath - the path to the fuel-core binary. (optional, defaults to 'fuel-core')
* @param loggingEnabled - whether the node should output logs. (optional, defaults to true)
* @param debugEnabled - whether the node should log debug messages. (optional, defaults to false)
* @param basePath - the base path to use for the temporary folder. (optional, defaults to os.tmpdir())
* */
Note: You can see all the available fuel-core args by running
pnpm fuels core run -h
.