Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

test-utils: programatically spawn dev nodes #14704

Merged

Conversation

liamaharon
Copy link
Contributor

@liamaharon liamaharon commented Aug 3, 2023

I am in the process of migrating try-runtime-cli into an independent repo (paritytech/try-runtime-cli#6).

Multiple try-runtime-cli tests use substrate_cli_test_utils::start_node to spawn a node to run commands against.

Unfortunately, substrate_cli_test_utils::start_node depends on the substrate-node binary being accessible by cargo_bin (calls cargo_bin("substrate-node")), which is not the case outside of substrate.

In this PR I create a new method substrate_cli_test_utils::start_node_inline.

The new method functions similarly to start_node, but can be run in environments without the ability to access a node binary with cargo_bin("substrate-node").

Honestly I am not sure if this is the best approach to solving this problem, I'm open to other suggestions if there're better ones.

@liamaharon liamaharon added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Aug 3, 2023
test-utils/cli/src/lib.rs Outdated Show resolved Hide resolved
@liamaharon liamaharon changed the title node-template: enable programatically spawning dev nodes in external projects node-template: enable programatically spawning dev nodes Aug 3, 2023
Copy link
Contributor

@sam0x17 sam0x17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I stand by this being a very sound approach. Any good CLI app exposes both a binary and a lib that allows you to easily use its underlying functionality, lest people write horrible zombies of wrappers around binaries around wrappers around binaries.

Since all this exposes is the same functionality exposed by the CLI interface itself, this is a zero-risk net positive 💯

test-utils/cli/src/lib.rs Outdated Show resolved Hide resolved
test-utils/cli/src/lib.rs Outdated Show resolved Hide resolved
test-utils/cli/src/lib.rs Outdated Show resolved Hide resolved
test-utils/cli/src/lib.rs Outdated Show resolved Hide resolved
bin/node-template/node/Cargo.toml Outdated Show resolved Hide resolved
test-utils/cli/src/lib.rs Outdated Show resolved Hide resolved
@liamaharon liamaharon changed the title node-template: enable programatically spawning dev nodes test-utils: programatically spawn dev nodes Aug 8, 2023
@liamaharon
Copy link
Contributor Author

bot merge force

@paritytech-processbot paritytech-processbot bot merged commit c0ee512 into master Aug 8, 2023
@paritytech-processbot paritytech-processbot bot deleted the liam-enable-spinning-up-dev-node-without-binary branch August 8, 2023 11:53
@paritytech paritytech deleted a comment from command-bot bot Aug 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants