diff --git a/src/main.rs b/src/main.rs index 07699116dc..3b3396c1cc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,13 +47,12 @@ use { redb::{Database, ReadableTable, Table, TableDefinition, WriteTransaction}, serde::{Deserialize, Serialize}, std::{ - cmp::Ordering, collections::VecDeque, env, fmt::{self, Display, Formatter}, fs, io, net::ToSocketAddrs, - ops::{Add, AddAssign, Deref, Mul, Sub}, + ops::{Add, AddAssign, Mul, Sub}, path::{Path, PathBuf}, process, str::FromStr, diff --git a/src/subcommand.rs b/src/subcommand.rs index d02f0a25be..b3b79d81fd 100644 --- a/src/subcommand.rs +++ b/src/subcommand.rs @@ -5,7 +5,7 @@ mod find; mod index; mod info; mod list; -mod name; +mod parse; mod range; mod server; mod supply; @@ -19,7 +19,7 @@ pub(crate) enum Subcommand { Index, Info, List(list::List), - Name(name::Name), + Parse(parse::Parse), Range(range::Range), Server(server::Server), Supply, @@ -36,7 +36,7 @@ impl Subcommand { Self::Index => index::run(options), Self::Info => info::run(options), Self::List(list) => list.run(options), - Self::Name(name) => name.run(), + Self::Parse(parse) => parse.run(), Self::Range(range) => range.run(), Self::Server(server) => server.run(options), Self::Supply => supply::run(), diff --git a/src/subcommand/name.rs b/src/subcommand/name.rs deleted file mode 100644 index ba2ce7f8a9..0000000000 --- a/src/subcommand/name.rs +++ /dev/null @@ -1,45 +0,0 @@ -use super::*; - -#[derive(Debug, Parser)] -pub(crate) struct Name { - name: String, -} - -impl Name { - pub(crate) fn run(self) -> Result { - if self.name.is_empty() || self.name.chars().any(|c| !('a'..='z').contains(&c)) { - return Err(anyhow!("Invalid name")); - } - - let mut min = 0; - let mut max = 2099999997690000; - let mut guess = max / 2; - - loop { - log::info!("min max guess: {} {} {}", min, max, guess); - - let name = Ordinal(guess).name(); - - match name - .len() - .cmp(&self.name.len()) - .then(name.deref().cmp(&self.name)) - .reverse() - { - Ordering::Less => min = guess + 1, - Ordering::Equal => break, - Ordering::Greater => max = guess, - } - - if max - min == 0 { - return Err(anyhow!("Name out of range")); - } - - guess = min + (max - min) / 2; - } - - println!("{}", guess); - - Ok(()) - } -} diff --git a/src/subcommand/parse.rs b/src/subcommand/parse.rs new file mode 100644 index 0000000000..201f445bf6 --- /dev/null +++ b/src/subcommand/parse.rs @@ -0,0 +1,13 @@ +use super::*; + +#[derive(Debug, Parser)] +pub(crate) struct Parse { + ordinal: Ordinal, +} + +impl Parse { + pub(crate) fn run(self) -> Result { + println!("{}", self.ordinal); + Ok(()) + } +} diff --git a/src/subcommand/traits.rs b/src/subcommand/traits.rs index 8239d98ee0..01d4be8d89 100644 --- a/src/subcommand/traits.rs +++ b/src/subcommand/traits.rs @@ -7,12 +7,7 @@ pub(crate) struct Traits { impl Traits { pub(crate) fn run(self) -> Result { - if self.ordinal > Ordinal::LAST { - bail!("Invalid ordinal"); - } - print!("{}", self); - Ok(()) } } diff --git a/tests/epochs.rs b/tests/epochs.rs index a828f6edac..abbb82cde2 100644 --- a/tests/epochs.rs +++ b/tests/epochs.rs @@ -2,44 +2,44 @@ use super::*; #[test] fn empty() { - Test::new() - .args(&["epochs"]) + TestCommand::new() + .command("epochs") .expected_stdout( " - 0 - 1050000000000000 - 1575000000000000 - 1837500000000000 - 1968750000000000 - 2034375000000000 - 2067187500000000 - 2083593750000000 - 2091796875000000 - 2095898437500000 - 2097949218750000 - 2098974609270000 - 2099487304530000 - 2099743652160000 - 2099871825870000 - 2099935912620000 - 2099967955890000 - 2099983977420000 - 2099991988080000 - 2099995993410000 - 2099997995970000 - 2099998997250000 - 2099999497890000 - 2099999748210000 - 2099999873370000 - 2099999935950000 - 2099999967240000 - 2099999982780000 - 2099999990550000 - 2099999994330000 - 2099999996220000 - 2099999997060000 - 2099999997480000 - 2099999997690000 + 0 + 1050000000000000 + 1575000000000000 + 1837500000000000 + 1968750000000000 + 2034375000000000 + 2067187500000000 + 2083593750000000 + 2091796875000000 + 2095898437500000 + 2097949218750000 + 2098974609270000 + 2099487304530000 + 2099743652160000 + 2099871825870000 + 2099935912620000 + 2099967955890000 + 2099983977420000 + 2099991988080000 + 2099995993410000 + 2099997995970000 + 2099998997250000 + 2099999497890000 + 2099999748210000 + 2099999873370000 + 2099999935950000 + 2099999967240000 + 2099999982780000 + 2099999990550000 + 2099999994330000 + 2099999996220000 + 2099999997060000 + 2099999997480000 + 2099999997690000 " .unindent(), ) diff --git a/tests/find.rs b/tests/find.rs index 47929913ac..d14c8826c0 100644 --- a/tests/find.rs +++ b/tests/find.rs @@ -2,7 +2,7 @@ use super::*; #[test] fn first_satoshi() { - Test::new() + SlowTest::new() .command("find 0") .expected_stdout("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0:0\n") .run(); @@ -11,7 +11,7 @@ fn first_satoshi() { #[test] #[ignore] fn first_satoshi_slot() { - Test::new() + SlowTest::new() .command("find 0 --slot") .expected_stdout("0x0x0x0\n") .blocks(1) @@ -20,7 +20,7 @@ fn first_satoshi_slot() { #[test] fn second_satoshi() { - Test::new() + SlowTest::new() .command("find 1") .expected_stdout("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0:1\n") .run(); @@ -29,7 +29,7 @@ fn second_satoshi() { #[test] #[ignore] fn second_satoshi_slot() { - Test::new() + SlowTest::new() .command("find 1 --slot") .expected_stdout("0x0x0x1\n") .blocks(1) @@ -38,7 +38,7 @@ fn second_satoshi_slot() { #[test] fn first_satoshi_of_second_block() { - Test::new() + SlowTest::new() .command("find 5000000000") .blocks(1) .expected_stdout("150ba822b458a19615e70a604d8dd9d3482fc165fa4e9cc150d74e11916ce8ae:0:0\n") @@ -48,7 +48,7 @@ fn first_satoshi_of_second_block() { #[test] #[ignore] fn first_satoshi_of_second_block_slot() { - Test::new() + SlowTest::new() .command("find 5000000000 --slot") .expected_stdout("1x0x0x0\n") .blocks(1) @@ -58,7 +58,7 @@ fn first_satoshi_of_second_block_slot() { #[test] fn first_satoshi_spent_in_second_block() { - Test::new() + SlowTest::new() .command("find 0") .blocks(101) .transaction(TransactionOptions { @@ -75,7 +75,7 @@ fn first_satoshi_spent_in_second_block() { #[test] #[ignore] fn first_satoshi_spent_in_second_block_slot() { - Test::new() + SlowTest::new() .command("find 0 --slot") .expected_stdout("1x1x0x0\n") .blocks(1) @@ -92,7 +92,7 @@ fn first_satoshi_spent_in_second_block_slot() { #[test] #[ignore] fn mining_and_spending_transaction_in_same_block() { - Test::new() + SlowTest::new() .command("find 0 --slot") .blocks(1) .blocks(1) @@ -114,7 +114,7 @@ fn mining_and_spending_transaction_in_same_block() { #[test] fn unmined_satoshi_in_second_block() { - Test::new() + SlowTest::new() .expected_stderr("error: Ordinal has not been mined as of index height\n") .expected_status(1) .command("find 5000000000") diff --git a/tests/index.rs b/tests/index.rs index b9d0c5e386..c7ddb1856b 100644 --- a/tests/index.rs +++ b/tests/index.rs @@ -2,7 +2,7 @@ use super::*; #[test] fn custom_index_size() { - let state = Test::new() + let state = SlowTest::new() .command("--max-index-size 1mib find 0") .expected_stdout("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0:0\n") .blocks(1) diff --git a/tests/info.rs b/tests/info.rs index 704a7b62ec..bc5ef84f71 100644 --- a/tests/info.rs +++ b/tests/info.rs @@ -2,9 +2,9 @@ use super::*; #[test] fn basic() { - let output = Test::new().command("index").output(); + let output = SlowTest::new().command("index").output(); - Test::with_state(output.state) + SlowTest::with_state(output.state) .command("info") .stdout_regex( r" diff --git a/tests/lib.rs b/tests/lib.rs index 5cbf5b889a..7b2b56b38f 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,7 +1,10 @@ #![allow(clippy::type_complexity)] use { - self::{expected::Expected, state::State, test::Test, transaction_options::TransactionOptions}, + self::{ + expected::Expected, slow_test::SlowTest, state::State, test_command::TestCommand, + transaction_options::TransactionOptions, + }, bdk::{ blockchain::{ rpc::{RpcBlockchain, RpcConfig}, @@ -40,12 +43,13 @@ mod find; mod index; mod info; mod list; -mod name; +mod parse; mod range; mod server; +mod slow_test; mod state; mod supply; -mod test; +mod test_command; mod traits; mod transaction_options; mod version; diff --git a/tests/list.rs b/tests/list.rs index ab5f7f6797..0431a04e10 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -2,7 +2,7 @@ use super::*; #[test] fn first_coinbase_transaction() { - Test::new() + SlowTest::new() .command("list 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0") .expected_stdout("[0,5000000000)\n") .run(); @@ -10,7 +10,7 @@ fn first_coinbase_transaction() { #[test] fn second_coinbase_transaction() { - Test::new() + SlowTest::new() .command("list 150ba822b458a19615e70a604d8dd9d3482fc165fa4e9cc150d74e11916ce8ae:0") .blocks(1) .expected_stdout("[5000000000,10000000000)\n") @@ -19,7 +19,7 @@ fn second_coinbase_transaction() { #[test] fn split_ranges_are_tracked_correctly() { - Test::new() + SlowTest::new() .command("list 36b5e3d6454fdadf762e8adc28140bbf38ee673c68bf05aaac82add84c0ff862:0") .blocks(101) .transaction(TransactionOptions { @@ -32,7 +32,7 @@ fn split_ranges_are_tracked_correctly() { .expected_stdout("[5000000000,7500000000)\n") .run(); - Test::new() + SlowTest::new() .command("list 36b5e3d6454fdadf762e8adc28140bbf38ee673c68bf05aaac82add84c0ff862:1") .blocks(101) .transaction(TransactionOptions { @@ -48,7 +48,7 @@ fn split_ranges_are_tracked_correctly() { #[test] fn merge_ranges_are_tracked_correctly() { - Test::new() + SlowTest::new() .command("list 430f77dcea637d90d82ac561f9f1955119c0d25b690da250ba98872e15e9069f:0") .blocks(101) .transaction(TransactionOptions { @@ -71,7 +71,7 @@ fn merge_ranges_are_tracked_correctly() { #[test] fn fee_paying_transaction_range() { - Test::new() + SlowTest::new() .command("list a57ccabdca48ada30a5e58459584e43691a56f4fcc51121d8aa9bf1d1c682603:0") .blocks(101) .transaction(TransactionOptions { @@ -84,7 +84,7 @@ fn fee_paying_transaction_range() { .expected_stdout("[5000000000,7499999995)\n") .run(); - Test::new() + SlowTest::new() .command("list a57ccabdca48ada30a5e58459584e43691a56f4fcc51121d8aa9bf1d1c682603:1") .blocks(101) .transaction(TransactionOptions { @@ -97,7 +97,7 @@ fn fee_paying_transaction_range() { .expected_stdout("[7499999995,9999999990)\n") .run(); - Test::new() + SlowTest::new() .command("list 721792011e3200abd01693490de5215b570da0048e55b66514201cb62396e376:0") .blocks(101) .transaction(TransactionOptions { @@ -113,7 +113,7 @@ fn fee_paying_transaction_range() { #[test] fn two_fee_paying_transaction_range() { - Test::new() + SlowTest::new() .command("list 7f3b38a0bc60f581fd7f4b178ca2a697575000e212c8752b455ec134d160ea9a:0") .blocks(102) .transaction(TransactionOptions { @@ -137,7 +137,7 @@ fn two_fee_paying_transaction_range() { #[test] fn null_output() { - Test::new() + SlowTest::new() .command("list 3dbc87de25bf5a52ddfa8038bda36e09622f4dec7951d81ac43e4b0e8c54bc5b:0") .blocks(101) .transaction(TransactionOptions { @@ -153,7 +153,7 @@ fn null_output() { #[test] fn null_input() { - Test::new() + SlowTest::new() .command("list 3dbc87de25bf5a52ddfa8038bda36e09622f4dec7951d81ac43e4b0e8c54bc5b:0") .blocks(101) .transaction(TransactionOptions { @@ -176,7 +176,7 @@ fn null_input() { #[test] #[ignore] fn old_transactions_are_pruned() { - Test::new() + SlowTest::new() .command("list 150ba822b458a19615e70a604d8dd9d3482fc165fa4e9cc150d74e11916ce8ae:0") .blocks(101) .transaction(TransactionOptions { diff --git a/tests/name.rs b/tests/name.rs deleted file mode 100644 index defc915530..0000000000 --- a/tests/name.rs +++ /dev/null @@ -1,52 +0,0 @@ -use super::*; - -#[test] -fn empty() { - Test::new() - .args(&["name", ""]) - .expected_stderr("error: Invalid name\n") - .expected_status(1) - .run() -} - -#[test] -fn a() { - Test::new() - .args(&["name", "a"]) - .expected_stdout("2099999997689999\n") - .run() -} - -#[test] -fn b() { - Test::new() - .args(&["name", "b"]) - .expected_stdout("2099999997689998\n") - .run() -} - -#[test] -fn end_of_range() { - Test::new() - .args(&["name", "nvtdijuwxlp"]) - .expected_stdout("0\n") - .run() -} - -#[test] -fn out_of_range() { - Test::new() - .args(&["name", "nvtdijuwxlr"]) - .expected_stderr("error: Name out of range\n") - .expected_status(1) - .run() -} - -#[test] -fn invalid() { - Test::new() - .args(&["name", "0"]) - .expected_stderr("error: Invalid name\n") - .expected_status(1) - .run() -} diff --git a/tests/parse.rs b/tests/parse.rs new file mode 100644 index 0000000000..cd08de4e6d --- /dev/null +++ b/tests/parse.rs @@ -0,0 +1,18 @@ +use super::*; + +#[test] +fn ok() { + TestCommand::new() + .command("parse a") + .expected_stdout("2099999997689999\n") + .run(); +} + +#[test] +fn err() { + TestCommand::new() + .command("parse A") + .stderr_regex("error: .*: invalid digit found in string.*") + .expected_status(2) + .run(); +} diff --git a/tests/range.rs b/tests/range.rs index e249cb0b8a..b91b333100 100644 --- a/tests/range.rs +++ b/tests/range.rs @@ -2,7 +2,7 @@ use super::*; #[test] fn genesis() { - Test::new() + SlowTest::new() .args(&["range", "0"]) .expected_stdout("[0,5000000000)\n") .run() @@ -10,7 +10,7 @@ fn genesis() { #[test] fn second_block() { - Test::new() + SlowTest::new() .args(&["range", "1"]) .expected_stdout("[5000000000,10000000000)\n") .run() @@ -18,7 +18,7 @@ fn second_block() { #[test] fn last_block_with_subsidy() { - Test::new() + SlowTest::new() .args(&["range", "6929999"]) .expected_stdout("[2099999997689999,2099999997690000)\n") .run() @@ -26,7 +26,7 @@ fn last_block_with_subsidy() { #[test] fn first_block_without_subsidy() { - Test::new() + SlowTest::new() .args(&["range", "6930000"]) .expected_stdout("[2099999997690000,2099999997690000)\n") .run() @@ -34,7 +34,7 @@ fn first_block_without_subsidy() { #[test] fn genesis_names() { - Test::new() + SlowTest::new() .args(&["range", "--name", "0"]) .expected_stdout("[nvtdijuwxlp,nvtcsezkbth)\n") .run() @@ -42,7 +42,7 @@ fn genesis_names() { #[test] fn names_before_last() { - Test::new() + SlowTest::new() .args(&["range", "--name", "6929998"]) .expected_stdout("[b,a)\n") .run() @@ -50,7 +50,7 @@ fn names_before_last() { #[test] fn last_name() { - Test::new() + SlowTest::new() .args(&["range", "--name", "6929999"]) .expected_stdout("[a,)\n") .run() @@ -58,7 +58,7 @@ fn last_name() { #[test] fn block_with_no_subsidy_range() { - Test::new() + SlowTest::new() .args(&["range", "--name", "6930000"]) .expected_stdout("[,)\n") .run() diff --git a/tests/test.rs b/tests/slow_test.rs similarity index 93% rename from tests/test.rs rename to tests/slow_test.rs index 0fb4b167d5..db188e0f86 100644 --- a/tests/test.rs +++ b/tests/slow_test.rs @@ -5,7 +5,7 @@ pub(crate) struct Output { pub(crate) state: State, } -pub(crate) struct Test { +pub(crate) struct SlowTest { args: Vec, expected_status: i32, expected_stderr: Expected, @@ -13,7 +13,7 @@ pub(crate) struct Test { state: State, } -impl Test { +impl SlowTest { pub(crate) fn new() -> Self { Self::with_state(State::new()) } @@ -71,13 +71,6 @@ impl Test { } } - pub(crate) fn stderr_regex(self, expected_stderr: impl AsRef) -> Self { - Self { - expected_stderr: Expected::regex(expected_stderr.as_ref()), - ..self - } - } - pub(crate) fn expected_status(self, expected_status: i32) -> Self { Self { expected_status, diff --git a/tests/supply.rs b/tests/supply.rs index 6af4303bc1..aa6738f6d4 100644 --- a/tests/supply.rs +++ b/tests/supply.rs @@ -2,14 +2,14 @@ use super::*; #[test] fn genesis() { - Test::new() - .args(&["supply"]) + TestCommand::new() + .command("supply") .expected_stdout( - &" - supply: 2099999997690000 - first: 0 - last: 2099999997689999 - last mined in block: 6929999 + " + supply: 2099999997690000 + first: 0 + last: 2099999997689999 + last mined in block: 6929999 " .unindent(), ) diff --git a/tests/test_command.rs b/tests/test_command.rs new file mode 100644 index 0000000000..83bb9a09db --- /dev/null +++ b/tests/test_command.rs @@ -0,0 +1,84 @@ +use super::*; + +pub(crate) struct TestCommand { + args: Vec, + expected_status: i32, + expected_stderr: Expected, + expected_stdout: Expected, + tempdir: TempDir, +} + +impl TestCommand { + pub(crate) fn new() -> Self { + Self { + tempdir: TempDir::new().unwrap(), + args: Vec::new(), + expected_status: 0, + expected_stderr: Expected::Ignore, + expected_stdout: Expected::String(String::new()), + } + } + + pub(crate) fn command(self, args: &str) -> Self { + Self { + args: args.split_whitespace().map(str::to_owned).collect(), + ..self + } + } + + pub(crate) fn expected_stdout(self, expected_stdout: impl AsRef) -> Self { + Self { + expected_stdout: Expected::String(expected_stdout.as_ref().to_owned()), + ..self + } + } + + pub(crate) fn stdout_regex(self, expected_stdout: impl AsRef) -> Self { + Self { + expected_stdout: Expected::regex(expected_stdout.as_ref()), + ..self + } + } + + pub(crate) fn stderr_regex(self, expected_stderr: impl AsRef) -> Self { + Self { + expected_stderr: Expected::regex(expected_stderr.as_ref()), + ..self + } + } + + pub(crate) fn expected_status(self, expected_status: i32) -> Self { + Self { + expected_status, + ..self + } + } + + pub(crate) fn run(self) { + let output = Command::new(executable_path("ord")) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(if !matches!(self.expected_stderr, Expected::Ignore) { + Stdio::piped() + } else { + Stdio::inherit() + }) + .current_dir(&self.tempdir) + .args(self.args.clone()) + .output() + .unwrap(); + + let stdout = str::from_utf8(&output.stdout).unwrap(); + let stderr = str::from_utf8(&output.stderr).unwrap(); + + if output.status.code() != Some(self.expected_status) { + panic!( + "Test failed: {}\nstdout:\n{}\nstderr:\n{}", + output.status, stdout, stderr + ); + } + + self.expected_stderr.assert_match(stderr); + self.expected_stdout.assert_match(stdout); + } +} diff --git a/tests/traits.rs b/tests/traits.rs index 96f2cb58f3..dfe88fa8de 100644 --- a/tests/traits.rs +++ b/tests/traits.rs @@ -1,18 +1,9 @@ use super::*; #[test] -fn invalid_ordinal() { - Test::new() - .args(&["traits", "2099999997690000"]) - .stderr_regex("error: Invalid value \"2099999997690000\" for '': Invalid ordinal\n.*") - .expected_status(2) - .run(); -} - -#[test] -fn valid_ordinal() { - Test::new() - .args(&["traits", "0"]) +fn traits_command_prints_ordinal_traits() { + TestCommand::new() + .command("traits 0") .expected_stdout( "\ number: 0 diff --git a/tests/version.rs b/tests/version.rs index 1603b5509e..42294eabe4 100644 --- a/tests/version.rs +++ b/tests/version.rs @@ -1,10 +1,9 @@ use super::*; #[test] -fn flag() { - Test::new() +fn version_flag_prints_version() { + TestCommand::new() .command("--version") .stdout_regex("ord .*\n") - .blocks(1) .run(); } diff --git a/tests/wallet.rs b/tests/wallet.rs index 80b9b1be12..82a0ae4841 100644 --- a/tests/wallet.rs +++ b/tests/wallet.rs @@ -10,7 +10,7 @@ fn path(path: &str) -> String { #[test] fn init_existing_wallet() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") @@ -29,7 +29,7 @@ fn init_existing_wallet() { .join(path("ord/regtest/entropy")) .exists()); - Test::with_state(state) + SlowTest::with_state(state) .command("--chain regtest wallet init") .expected_status(1) .expected_stderr("error: Wallet already exists.\n") @@ -38,7 +38,7 @@ fn init_existing_wallet() { #[test] fn init_nonexistent_wallet() { - let output = Test::new() + let output = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") @@ -61,7 +61,7 @@ fn init_nonexistent_wallet() { #[test] fn load_corrupted_entropy() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") @@ -77,7 +77,7 @@ fn load_corrupted_entropy() { fs::write(&entropy_path, entropy).unwrap(); - Test::with_state(state) + SlowTest::with_state(state) .command("--chain regtest wallet fund") .expected_status(1) .expected_stderr("error: ChecksumMismatch\n") @@ -86,14 +86,14 @@ fn load_corrupted_entropy() { #[test] fn fund_existing_wallet() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") .output() .state; - Test::with_state(state) + SlowTest::with_state(state) .command("--chain regtest wallet fund") .stdout_regex("^bcrt1.*\n") .run(); @@ -101,7 +101,7 @@ fn fund_existing_wallet() { #[test] fn fund_nonexistent_wallet() { - Test::new() + SlowTest::new() .command("--chain regtest wallet fund") .expected_status(1) .expected_stderr("error: Wallet doesn't exist.\n") @@ -110,14 +110,14 @@ fn fund_nonexistent_wallet() { #[test] fn utxos() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") .output() .state; - let output = Test::with_state(state) + let output = SlowTest::with_state(state) .command("--chain regtest wallet fund") .stdout_regex("^bcrt1.*\n") .output(); @@ -138,7 +138,7 @@ fn utxos() { ) .unwrap(); - Test::with_state(output.state) + SlowTest::with_state(output.state) .command("--chain regtest wallet utxos") .expected_status(0) .stdout_regex("^[[:xdigit:]]{64}:0 5000000000\n") @@ -147,21 +147,21 @@ fn utxos() { #[test] fn balance() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") .output() .state; - let state = Test::with_state(state) + let state = SlowTest::with_state(state) .command("--chain regtest wallet balance") .expected_status(0) .expected_stdout("0\n") .output() .state; - let output = Test::with_state(state) + let output = SlowTest::with_state(state) .command("--chain regtest wallet fund") .stdout_regex("^bcrt1.*\n") .output(); @@ -182,7 +182,7 @@ fn balance() { ) .unwrap(); - Test::with_state(output.state) + SlowTest::with_state(output.state) .command("--chain regtest wallet balance") .expected_status(0) .expected_stdout("5000000000\n") @@ -191,14 +191,14 @@ fn balance() { #[test] fn identify_single_ordinal() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") .output() .state; - let output = Test::with_state(state) + let output = SlowTest::with_state(state) .command("--chain regtest wallet fund") .stdout_regex("^bcrt1.*\n") .output(); @@ -219,7 +219,7 @@ fn identify_single_ordinal() { ) .unwrap(); - Test::with_state(output.state) + SlowTest::with_state(output.state) .command("--chain regtest wallet identify") .expected_status(0) .stdout_regex("5000000000 uncommon [[:xdigit:]]{64}:[[:digit:]]\n") @@ -228,14 +228,14 @@ fn identify_single_ordinal() { #[test] fn identify_multiple_ordinals() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") .output() .state; - let output = Test::with_state(state) + let output = SlowTest::with_state(state) .command("--chain regtest wallet fund") .stdout_regex("^bcrt1.*\n") .output(); @@ -256,7 +256,7 @@ fn identify_multiple_ordinals() { ) .unwrap(); - Test::with_state(output.state) + SlowTest::with_state(output.state) .command("--chain regtest wallet identify") .expected_status(0) .stdout_regex( @@ -275,14 +275,14 @@ fn identify_multiple_ordinals() { #[test] fn identify_sent_ordinal() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") .output() .state; - let output = Test::with_state(state) + let output = SlowTest::with_state(state) .command("--chain regtest wallet fund") .stdout_regex("^bcrt1.*\n") .output(); @@ -311,13 +311,13 @@ fn identify_sent_ordinal() { ) .unwrap(); - let output = Test::with_state(output.state) + let output = SlowTest::with_state(output.state) .command("--chain regtest wallet utxos") .expected_status(0) .stdout_regex("[[:xdigit:]]{64}:[[:digit:]] 5000000000\n") .output(); - let output = Test::with_state(output.state) + let output = SlowTest::with_state(output.state) .command("--chain regtest wallet identify") .expected_status(0) .stdout_regex("5000000000 uncommon [[:xdigit:]]{64}:[[:digit:]]\n") @@ -340,7 +340,7 @@ fn identify_sent_ordinal() { let to_address = wallet.get_address(AddressIndex::LastUnused).unwrap(); - let state = Test::with_state(output.state) + let state = SlowTest::with_state(output.state) .command(&format!( "--chain regtest wallet send --address {to_address} --ordinal 5000000000", )) @@ -357,7 +357,7 @@ fn identify_sent_ordinal() { state.client.generate_to_address(1, &to_address).unwrap(); - let output = Test::with_state(state) + let output = SlowTest::with_state(state) .command(&format!( "--chain regtest list {}", wallet.list_unspent().unwrap().first().unwrap().outpoint @@ -366,7 +366,7 @@ fn identify_sent_ordinal() { .expected_stdout("[5000000000,9999999780)\n") .output(); - Test::with_state(output.state) + SlowTest::with_state(output.state) .command("--chain regtest wallet identify") .expected_status(0) .expected_stdout("") @@ -375,14 +375,14 @@ fn identify_sent_ordinal() { #[test] fn send_uncommon_ordinal() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") .output() .state; - let output = Test::with_state(state) + let output = SlowTest::with_state(state) .command("--chain regtest wallet fund") .stdout_regex("^bcrt1.*\n") .output(); @@ -411,7 +411,7 @@ fn send_uncommon_ordinal() { ) .unwrap(); - let output = Test::with_state(output.state) + let output = SlowTest::with_state(output.state) .command("--chain regtest wallet utxos") .expected_status(0) .stdout_regex("[[:xdigit:]]{64}:[[:digit:]] 5000000000\n") @@ -434,7 +434,7 @@ fn send_uncommon_ordinal() { let to_address = wallet.get_address(AddressIndex::LastUnused).unwrap(); - let state = Test::with_state(output.state) + let state = SlowTest::with_state(output.state) .command(&format!( "--chain regtest wallet send --address {to_address} --ordinal 5000000000", )) @@ -451,7 +451,7 @@ fn send_uncommon_ordinal() { state.client.generate_to_address(1, &from_address).unwrap(); - Test::with_state(state) + SlowTest::with_state(state) .command(&format!( "--chain regtest list {}", wallet.list_unspent().unwrap().first().unwrap().outpoint @@ -463,14 +463,14 @@ fn send_uncommon_ordinal() { #[test] fn send_foreign_ordinal() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") .output() .state; - let output = Test::with_state(state) + let output = SlowTest::with_state(state) .command("--chain regtest wallet fund") .stdout_regex("^bcrt1.*\n") .output(); @@ -490,7 +490,7 @@ fn send_foreign_ordinal() { .generate_to_address(1, &from_address) .unwrap(); - let output = Test::with_state(output.state) + let output = SlowTest::with_state(output.state) .command("--chain regtest wallet utxos") .expected_status(0) .stdout_regex("[[:xdigit:]]{64}:[[:digit:]] 5000000000\n") @@ -513,7 +513,7 @@ fn send_foreign_ordinal() { let to_address = wallet.get_address(AddressIndex::LastUnused).unwrap(); - Test::with_state(output.state) + SlowTest::with_state(output.state) .command(&format!( "--chain regtest wallet send --address {to_address} --ordinal 4999999999", )) @@ -524,14 +524,14 @@ fn send_foreign_ordinal() { #[test] fn send_common_ordinal() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") .output() .state; - let output = Test::with_state(state) + let output = SlowTest::with_state(state) .command("--chain regtest wallet fund") .stdout_regex("^bcrt1.*\n") .output(); @@ -560,7 +560,7 @@ fn send_common_ordinal() { ) .unwrap(); - let output = Test::with_state(output.state) + let output = SlowTest::with_state(output.state) .command("--chain regtest wallet utxos") .expected_status(0) .stdout_regex("[[:xdigit:]]{64}:[[:digit:]] 5000000000\n") @@ -583,7 +583,7 @@ fn send_common_ordinal() { let to_address = wallet.get_address(AddressIndex::LastUnused).unwrap(); - Test::with_state(output.state) + SlowTest::with_state(output.state) .command(&format!( "--chain regtest wallet send --address {to_address} --ordinal 5000000001", )) @@ -594,14 +594,14 @@ fn send_common_ordinal() { #[test] fn send_non_unique_uncommon_ordinal() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") .output() .state; - let output = Test::with_state(state) + let output = SlowTest::with_state(state) .command("--chain regtest wallet fund") .stdout_regex("^bcrt1.*\n") .output(); @@ -626,7 +626,7 @@ fn send_non_unique_uncommon_ordinal() { output.state.blocks(1); - let output = Test::with_state(output.state) + let output = SlowTest::with_state(output.state) .command(&format!("--chain regtest list {}:0", transaction.txid())) .expected_status(0) .expected_stdout("[5000000000,10000000000)\n[10000000000,15000000000)\n") @@ -658,7 +658,7 @@ fn send_non_unique_uncommon_ordinal() { let to_address = wallet.get_address(AddressIndex::LastUnused).unwrap(); - Test::with_state(output.state) + SlowTest::with_state(output.state) .command(&format!( "--chain regtest wallet send --address {to_address} --ordinal 5000000000", )) @@ -669,14 +669,14 @@ fn send_non_unique_uncommon_ordinal() { #[test] fn protect_ordinal_from_fees() { - let state = Test::new() + let state = SlowTest::new() .command("--chain regtest wallet init") .expected_status(0) .expected_stderr("Wallet initialized.\n") .output() .state; - let output = Test::with_state(state) + let output = SlowTest::with_state(state) .command("--chain regtest wallet fund") .stdout_regex("^bcrt1.*\n") .output(); @@ -710,7 +710,7 @@ fn protect_ordinal_from_fees() { ) .unwrap(); - let output = Test::with_state(output.state) + let output = SlowTest::with_state(output.state) .command("--chain regtest wallet utxos") .expected_status(0) .stdout_regex("[[:xdigit:]]{64}:0 2500000000\n[[:xdigit:]]{64}:1 2500000000\n") @@ -733,7 +733,7 @@ fn protect_ordinal_from_fees() { let to_address = wallet.get_address(AddressIndex::LastUnused).unwrap(); - Test::with_state(output.state) + SlowTest::with_state(output.state) .command(&format!( "--chain regtest wallet send --address {to_address} --ordinal 9999999999", ))