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

Allow running a faucet from linera net up #3115

Merged
merged 7 commits into from
Jan 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test
  • Loading branch information
ma2bd committed Jan 13, 2025
commit 1b3b1498e4a321a155c66eb4388053fc41f452a2
59 changes: 37 additions & 22 deletions linera-service/tests/local_net_tests.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ use linera_service::{
local_net::{
get_node_port, Database, LocalNet, LocalNetConfig, PathProvider, ProcessInbox,
},
ClientWrapper, FaucetOption, LineraNet, LineraNetConfig, Network, OnClientDrop,
ClientWrapper, Faucet, FaucetOption, LineraNet, LineraNetConfig, Network, OnClientDrop,
},
faucet::ClaimOutcome,
test_name,
@@ -733,7 +733,14 @@ async fn test_storage_service_linera_net_up_simple() -> Result<()> {
tracing::info!("Starting test {}", test_name!());

let mut command = Command::new(env!("CARGO_BIN_EXE_linera"));
command.args(["net", "up"]);
command.args([
"net",
"up",
"--with-faucet-chain",
"1",
"--faucet-port",
"7999",
]);
let mut child = command
.stdout(Stdio::piped())
.stderr(Stdio::piped())
@@ -742,31 +749,39 @@ async fn test_storage_service_linera_net_up_simple() -> Result<()> {
let stdout = BufReader::new(child.stdout.take().unwrap());
let stderr = BufReader::new(child.stderr.take().unwrap());

let mut is_ready = false;
for line in stderr.lines() {
let line = line?;
if line.starts_with("READY!") {
let mut exports = stdout.lines();
assert!(exports
.next()
.unwrap()?
.starts_with("export LINERA_WALLET="));
assert!(exports
.next()
.unwrap()?
.starts_with("export LINERA_STORAGE="));
assert_eq!(exports.next().unwrap()?, "");

// Send SIGINT to the child process.
Command::new("kill")
.args(["-s", "INT", &child.id().to_string()])
.output()?;

assert!(exports.next().is_none());
assert!(child.wait()?.success());
return Ok(());
is_ready = true;
break;
}
}
panic!("Unexpected EOF for stderr");
assert!(is_ready, "Unexpected EOF for stderr");

let mut exports = stdout.lines();
assert!(exports
.next()
.unwrap()?
.starts_with("export LINERA_WALLET="));
assert!(exports
.next()
.unwrap()?
.starts_with("export LINERA_STORAGE="));
assert_eq!(exports.next().unwrap()?, "");

// Test faucet.
let faucet = Faucet::new("http://localhost:7999/".to_string());
faucet.version_info().await.unwrap();

// Send SIGINT to the child process.
Command::new("kill")
.args(["-s", "INT", &child.id().to_string()])
.output()?;

assert!(exports.next().is_none());
assert!(child.wait()?.success());
return Ok(());
}

#[cfg(feature = "benchmark")]
Loading