use super::helpers::*;
use libtest_mimic::{Arguments, Failed, Trial};
use std::time::Duration;
#[derive(Debug, clap::Args)]
pub struct CalibnetMpoolTestCommand {}
impl CalibnetMpoolTestCommand {
pub async fn run(self) -> anyhow::Result<()> {
let args = Arguments {
test_threads: Some(8),
..Default::default()
};
libtest_mimic::run(&args, tests()).exit();
}
}
fn tests() -> Vec<Trial> {
vec![Trial::test(
"mpool_replace_auto_unblocks_pending",
mpool_replace_auto_unblocks_pending,
)]
}
fn mpool_replace_auto_unblocks_pending() -> Result<(), Failed> {
for i in (0..3).rev() {
if i <= 0 {
block_on(mpool_replace_auto_unblocks_pending_async());
break;
} else if std::panic::catch_unwind(|| block_on(mpool_replace_auto_unblocks_pending_async()))
.is_err()
{
std::thread::sleep(Duration::from_secs(5));
} else {
break;
}
}
Ok(())
}
async fn mpool_replace_auto_unblocks_pending_async() {
let addr = FOREST_TEST_PRELOADED_ADDRESS.as_str();
let nonce = mpool_nonce(addr).unwrap();
let cid = send_from_no_wait(addr, addr, FIL_AMT, Backend::Local).unwrap();
poll_until_pending_nonce(addr, nonce).await.unwrap();
forest_cli(&[
"mpool",
"replace",
"--from",
addr,
"--nonce",
&nonce.to_string(),
"--auto",
])
.unwrap();
assert!(
poll_until_state_search_msg(&cid).await.is_ok(),
"mpool replace --auto should replace message {cid} from {addr} at nonce {nonce}."
);
}