Skip to content

Commit

Permalink
Reuse ord tempdir
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Mar 3, 2025
1 parent c4b4240 commit 03c89ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
18 changes: 15 additions & 3 deletions tests/test_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ pub(crate) struct TestServer {
bitcoin_rpc_url: String,
ord_server_handle: Handle,
port: u16,
#[allow(unused)]
tempdir: TempDir,
tempdir: Arc<TempDir>,
}

impl TestServer {
Expand Down Expand Up @@ -77,10 +76,23 @@ impl TestServer {
bitcoin_rpc_url: core.url(),
ord_server_handle,
port,
tempdir,
tempdir: tempdir.into(),
}
}

pub(crate) fn create_wallet(&self, core: &mockcore::Handle) {
CommandBuilder::new(format!("--chain {} wallet create", core.network()))
.temp_dir(self.tempdir.clone())
.core(core)
.ord(self)
.stdout_regex(".*")
.run_and_extract_stdout();
}

pub(crate) fn tempdir(&self) -> &Arc<TempDir> {
&self.tempdir
}

pub(crate) fn url(&self) -> Url {
format!("http://127.0.0.1:{}", self.port).parse().unwrap()
}
Expand Down
6 changes: 3 additions & 3 deletions tests/wallet/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ fn receive() {
let core = mockcore::spawn();
let ord = TestServer::spawn(&core);

let tempdir = create_wallet(&core, &ord);
ord.create_wallet(&core);

let output = CommandBuilder::new("wallet receive")
.temp_dir(tempdir.clone())
.temp_dir(ord.tempdir().clone())
.core(&core)
.ord(&ord)
.run_and_deserialize_output::<receive::Output>();
Expand All @@ -18,7 +18,7 @@ fn receive() {
assert!(first_address.is_valid_for_network(Network::Bitcoin));

let output = CommandBuilder::new("wallet receive")
.temp_dir(tempdir)
.temp_dir(ord.tempdir().clone())
.core(&core)
.ord(&ord)
.run_and_deserialize_output::<receive::Output>();
Expand Down

0 comments on commit 03c89ef

Please sign in to comment.