Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(testnet): provide bootstrap peer when launching faucet #625

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions sn_testnet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ async fn main() -> Result<()> {
return Ok(());
}

run_network(
let gen_multi_addr = run_network(
node_bin_path,
args.node_launch_interval
.unwrap_or(DEFAULT_NODE_LAUNCH_INTERVAL),
Expand All @@ -214,7 +214,7 @@ async fn main() -> Result<()> {
}

info!("Launching DBC faucet server");
run_faucet(faucet_bin_path).await?;
run_faucet(gen_multi_addr, faucet_bin_path).await?;

println!("Testnet and faucet launched successfully");
Ok(())
Expand Down Expand Up @@ -297,7 +297,8 @@ async fn build_binaries(binaries_to_build: Vec<String>) -> Result<()> {
Ok(())
}

async fn run_faucet(bin_path: PathBuf) -> Result<()> {
/// Start the faucet from the provided bin_path and with the given bootstrap peer
async fn run_faucet(gen_multi_addr: String, bin_path: PathBuf) -> Result<()> {
let testnet = Testnet::configure().node_bin_path(bin_path).build()?;
let launch_bin = testnet.node_bin_path;

Expand All @@ -313,6 +314,8 @@ async fn run_faucet(bin_path: PathBuf) -> Result<()> {

let mut args = vec!["--log-output-dest".to_string()];
args.push(log_dir);
args.push("--peer".to_string());
args.push(gen_multi_addr);
args.push("server".to_string());
testnet.launcher.launch(&launch_bin, args)?;
// The launch will immediately complete after fire the cmd out.
Expand All @@ -321,13 +324,14 @@ async fn run_faucet(bin_path: PathBuf) -> Result<()> {
Ok(())
}

// Start the network and return the MultiAddr of the genesis node
async fn run_network(
node_bin_path: PathBuf,
node_launch_interval: u64,
node_count: u32,
mut node_args: Vec<String>,
flamegraph_mode: bool,
) -> Result<()> {
) -> Result<String> {
let mut testnet = Testnet::configure()
.node_bin_path(node_bin_path)
.node_launch_interval(node_launch_interval)
Expand All @@ -337,12 +341,12 @@ async fn run_network(
let gen_multi_addr = testnet.launch_genesis(node_args.clone()).await?;

node_args.push("--peer".to_string());
node_args.push(gen_multi_addr);
node_args.push(gen_multi_addr.clone());
testnet.launch_nodes(node_count as usize, node_args)?;

sn_testnet::check_testnet::run(&testnet.nodes_dir_path, node_count).await?;

Ok(())
Ok(gen_multi_addr)
}

async fn join_network(
Expand Down