forest/dev/subcommands/tests_cmd/
mpool.rs1use super::helpers::*;
10use libtest_mimic::{Arguments, Trial};
11
12#[derive(Debug, clap::Args)]
14pub struct MpoolTestCommand {}
15
16impl MpoolTestCommand {
17 pub async fn run(self) -> anyhow::Result<()> {
18 let args = Arguments {
19 test_threads: Some(1),
20 ..Default::default()
21 };
22 libtest_mimic::run(&args, tests()).exit();
23 }
24}
25
26fn tests() -> Vec<Trial> {
27 vec![
28 Trial::test("mpool_nonce_fix_auto_unblocks_pending", || {
29 block_on(mpool_nonce_fix_auto_unblocks_pending());
30 Ok(())
31 }),
32 Trial::test("mpool_replace_auto_unblocks_pending", || {
33 block_on(mpool_replace_auto_unblocks_pending());
34 Ok(())
35 }),
36 ]
37}
38
39async fn mpool_nonce_fix_auto_unblocks_pending() {
40 let addr = FOREST_TEST_PRELOADED_ADDRESS.as_str();
41 let nonce = mpool_nonce(addr).unwrap();
42 let next_nonce = nonce + 1;
44 forest_cli(&[
45 "mpool",
46 "nonce-fix",
47 "--addr",
48 addr,
49 "--start",
50 &next_nonce.to_string(),
51 "--end",
52 &(next_nonce + 1).to_string(),
53 ])
54 .unwrap();
55 poll_until_pending_nonce(addr, next_nonce).await.unwrap();
56
57 forest_cli(&["mpool", "nonce-fix", "--addr", addr, "--auto"]).unwrap();
58
59 assert!(
60 poll_until_pending_nonce(addr, nonce).await.is_ok(),
61 "nonce-fix --auto should fill nonce gap at {nonce} for {addr}."
62 );
63}
64
65async fn mpool_replace_auto_unblocks_pending() {
66 let addr = FOREST_TEST_PRELOADED_ADDRESS.as_str();
67 let nonce = mpool_nonce(addr).unwrap();
68
69 let cid = send_from_no_wait(addr, addr, FIL_AMT, Backend::Local).unwrap();
70 poll_until_pending_nonce(addr, nonce).await.unwrap();
71
72 forest_cli(&[
73 "mpool",
74 "replace",
75 "--from",
76 addr,
77 "--nonce",
78 &nonce.to_string(),
79 "--auto",
80 ])
81 .unwrap();
82
83 assert!(
84 poll_until_state_search_msg(&cid).await.is_ok(),
85 "mpool replace --auto should replace message {cid} from {addr} at nonce {nonce}."
86 );
87}