From ad856938684b48b2bad79e2213a4667cf1bacc5d Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 27 Sep 2022 13:16:32 -0700 Subject: [PATCH] Remove spent output test (#568) --- tests/lib.rs | 1 - tests/server.rs | 51 ----------------------------- tests/state.rs | 86 ------------------------------------------------- 3 files changed, 138 deletions(-) delete mode 100644 tests/server.rs diff --git a/tests/lib.rs b/tests/lib.rs index c7affaae42..5bc9f1c656 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -43,7 +43,6 @@ mod info; mod list; mod parse; mod range; -mod server; mod slow_test; mod state; mod supply; diff --git a/tests/server.rs b/tests/server.rs deleted file mode 100644 index 86deb05650..0000000000 --- a/tests/server.rs +++ /dev/null @@ -1,51 +0,0 @@ -use super::*; - -#[test] -#[ignore] -fn spent_output_returns_200() { - let mut state = State::new(); - - state.blocks(101); - - let txid = state - .transaction(TransactionOptions { - slots: &[(1, 0, 0)], - output_count: 1, - fee: 0, - recipient: None, - }) - .txid(); - - state.blocks(1); - - state.request_regex( - &format!("output/{txid}:0"), - 200, - &format!( - ".*Output {txid}:0.*

Output {txid}:0

-

Ordinal Ranges

-.*" - ), - ); - - let transaction = state.transaction(TransactionOptions { - slots: &[(102, 1, 0)], - output_count: 1, - fee: 0, - recipient: None, - }); - - state.blocks(1); - - state.request_regex( - &format!("output/{txid}:0"), - 200, - &format!( - ".*

Spent by transaction {}.

.*", - transaction.txid(), - transaction.txid() - ), - ); -} diff --git a/tests/state.rs b/tests/state.rs index 0ad3ed4ca7..b150632b23 100644 --- a/tests/state.rs +++ b/tests/state.rs @@ -15,7 +15,6 @@ pub(crate) struct State { pub(crate) wallet: Wallet, pub(crate) blockchain: RpcBlockchain, pub(crate) bitcoind_rpc_port: u16, - ord_http_port: Option, ord: Option, } @@ -102,7 +101,6 @@ impl State { State { tempdir, bitcoind_rpc_port, - ord_http_port: None, bitcoind, client, wallet, @@ -201,90 +199,6 @@ impl State { tx } - pub(crate) fn request_regex(&mut self, path: &str, status: u16, expected_response: &str) { - self.request_expected(path, status, Expected::regex(expected_response)); - } - - pub(crate) fn request_expected(&mut self, path: &str, status: u16, expected: Expected) { - if self.ord_http_port.is_none() { - let ord_http_port = free_port(); - - fs::create_dir(self.tempdir.path().join("server")).unwrap(); - - let ord = Command::new(executable_path("ord")) - .current_dir(self.tempdir.path().join("server")) - .env("HOME", self.tempdir.path()) - .arg(format!("--rpc-url=localhost:{}", self.bitcoind_rpc_port)) - .arg("--cookie-file=../bitcoin/regtest/.cookie") - .args([ - "server", - "--address", - "127.0.0.1", - "--http-port", - &ord_http_port.to_string(), - ]) - .spawn() - .unwrap(); - - for attempt in 0..=300 { - match reqwest::blocking::get(&format!("http://127.0.0.1:{ord_http_port}/status")) { - Ok(response) if response.status().is_success() => break, - result => { - if attempt == 300 { - panic!("Failed to connect to ord server: {result:?}"); - } - } - } - sleep(Duration::from_millis(100)); - } - - self.ord = Some(ord); - self.ord_http_port = Some(ord_http_port); - } - - for attempt in 0..=300 { - let best_hash = self.client.get_best_block_hash().unwrap(); - let bitcoind_height = self - .client - .get_block_header_info(&best_hash) - .unwrap() - .height as u64; - - let ord_height = reqwest::blocking::get(&format!( - "http://127.0.0.1:{}/height", - self.ord_http_port.unwrap() - )) - .unwrap() - .text() - .unwrap() - .parse::() - .unwrap(); - - if ord_height == bitcoind_height { - break; - } else { - if attempt == 300 { - panic!("Ord height {ord_height} did not catch up to bitcoind height {bitcoind_height}"); - } - - sleep(Duration::from_millis(100)); - } - } - - let response = reqwest::blocking::get(&format!( - "http://127.0.0.1:{}/{}", - self.ord_http_port.unwrap(), - path - )) - .unwrap(); - - log::info!("{:?}", response); - - assert_eq!(response.status().as_u16(), status); - - expected.assert_match(&response.text().unwrap()); - } - pub(crate) fn ord_data_dir(&self) -> PathBuf { self .tempdir