Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove spent-output-test #568

Merged
merged 3 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ mod info;
mod list;
mod parse;
mod range;
mod server;
mod slow_test;
mod state;
mod supply;
Expand Down
51 changes: 0 additions & 51 deletions tests/server.rs

This file was deleted.

86 changes: 0 additions & 86 deletions tests/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub(crate) struct State {
pub(crate) wallet: Wallet<MemoryDatabase>,
pub(crate) blockchain: RpcBlockchain,
pub(crate) bitcoind_rpc_port: u16,
ord_http_port: Option<u16>,
ord: Option<Child>,
}

Expand Down Expand Up @@ -102,7 +101,6 @@ impl State {
State {
tempdir,
bitcoind_rpc_port,
ord_http_port: None,
bitcoind,
client,
wallet,
Expand Down Expand Up @@ -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::<u64>()
.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
Expand Down