Skip to content

Commit

Permalink
fix(test-tooling): substrate test ledger fails if WS_PORT not specified
Browse files Browse the repository at this point in the history
Docker expects environment variables passed to the container
to be strings.
The null coalescing code was making it so that if the test case
did not pass in a custom WS_PORT  env var, then it would default
to using a value for the port that was a number not a string.
This would crash the serialization logic within docker that was
trying to apply the environment variables to the container when
starting it.

Switching the type of 9944 default WS port to "9944" (string) fixes it.
Also specifying explicitly the `wsPort` variable's type to be
string so that the next time someone tries to make this mistake
the compiler will slap their hands right away.

Fixes #2213

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz authored and takeutak committed Nov 30, 2022
1 parent 3387715 commit c668c41
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class SubstrateTestLedger {
(pairs) => `${pairs[0]}=${pairs[1]}`,
);

const wsPort = this.envVars.get("WS_PORT") ?? 9944;
const wsPort: string = this.envVars.get("WS_PORT") ?? "9944";
const portToExpose = `${wsPort}/tcp`;

// TODO: dynamically expose ports for custom port mapping
Expand Down

0 comments on commit c668c41

Please sign in to comment.