mint_client_sanity/
mint-client-sanity.rsuse anyhow::Context;
use devimint::cmd;
use tracing::info;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
devimint::run_devfed_test(|fed, _process_mgr| async move {
let fed = fed.fed().await?;
test_note_consoliation(fed).await?;
Ok(())
})
.await
}
async fn test_note_consoliation(fed: &devimint::federation::Federation) -> anyhow::Result<()> {
let sender = fed.new_joined_client("sender").await?;
let receiver = fed.new_joined_client("receiver").await?;
let can_no_wait = cmd!(sender, "reissue", "--help")
.out_string()
.await?
.contains("no-wait");
if !can_no_wait {
info!("Version before `--no-wait` didn't have consolidation implemented");
return Ok(());
}
fed.pegin_client(10_000, &sender).await?;
let mut all_notes = vec![];
for i in 0..20 {
let info = cmd!(sender, "info").out_json().await?;
info!(%info, "sender info");
if i % 2 == 1 {
let notes = cmd!(sender, "spend", "1sat",).out_json().await?["notes"]
.as_str()
.context("invoice must be string")?
.to_owned();
cmd!(sender, "reissue", notes).run().await?;
}
let notes = cmd!(sender, "spend", "1msat",).out_json().await?["notes"]
.as_str()
.context("invoice must be string")?
.to_owned();
all_notes.push(notes);
}
for notes in &all_notes[..all_notes.len() - 1] {
cmd!(receiver, "reissue", "--no-wait", notes).run().await?;
}
cmd!(receiver, "dev", "wait-complete").run().await?;
cmd!(receiver, "reissue")
.args(&all_notes[all_notes.len() - 1..])
.run()
.await?;
let info = cmd!(receiver, "info").out_json().await?;
info!(%info, "receiver info");
assert_eq!(info["total_amount_msat"].as_i64().unwrap(), 20);
assert!(info["denominations_msat"]["1"].as_i64().unwrap() < 20);
Ok(())
}