datahaven/test/cli/handlers/deploy/parameters.ts
Gonza Montiel 10362d3361
fix: 🔌 CLI connection issues (#119)
### Problem
Introducing `--network` should make easy to container nodes to find each
other. But this change was made half-way for the relayers, and it was
using the external port to find the first datahaven node (usually
Alice). So:
- In cli launch, Alice node port mapping was left to random port `-p
9944` instead of `-p 9944:9944`.
- Relayers couldn't connect to DataHaven nodes because they were using
the external WS port (now random) instead of hitting the internal port
(which for a cli launch we actually fix it to 9944).

### Solution

- [x] **Fixed Docker port mapping**: Explicit `-p 9944:9944` for Alice
node under network `cli-launch`
- [x] **Enhanced container spec**: Added `internalPorts` tracking to
`LaunchedNetwork`
- [x] **Fixed relayer connections**: Use internal ports for container
communication
2025-07-21 15:02:25 +02:00

40 lines
1.2 KiB
TypeScript

import { setDataHavenParameters } from "scripts/set-datahaven-parameters";
import { logger, printDivider, printHeader } from "utils";
import { DEFAULT_SUBSTRATE_WS_PORT } from "utils/constants";
import type { ParameterCollection } from "utils/parameters";
/**
* A helper function to set DataHaven parameters from a ParameterCollection
*
* @param options Options for setting parameters
* @param options.launchedNetwork The launched network instance
* @param options.collection The parameter collection
* @returns Promise resolving to true if parameters were set successfully
*/
export const setParametersFromCollection = async ({
collection,
skipSetParameters
}: {
collection: ParameterCollection;
skipSetParameters: boolean;
}): Promise<boolean> => {
printHeader("Setting DataHaven Runtime Parameters");
if (skipSetParameters) {
logger.info("🏳️ Skipping parameter setting");
printDivider();
return false;
}
const parametersFilePath = await collection.generateParametersFile();
const rpcUrl = `ws://127.0.0.1:${DEFAULT_SUBSTRATE_WS_PORT}`;
const parametersSet = await setDataHavenParameters({
rpcUrl,
parametersFilePath
});
printDivider();
return parametersSet;
};