Skip to content

Commit

Permalink
Move test Bitcoin Core RPC server into sub-crate (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Sep 27, 2022
1 parent ad85693 commit f28be8f
Show file tree
Hide file tree
Showing 16 changed files with 337 additions and 288 deletions.
18 changes: 13 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ license = "CC0-1.0"
edition = "2021"
autotests = false

[workspace]
members = [".", "test-bitcoincore-rpc"]

[dependencies]
anyhow = { version = "1.0.56", features = ["backtrace"] }
axum = "0.5.6"
Expand Down Expand Up @@ -41,19 +44,15 @@ tower = "0.4.13"
tower-http = { version = "0.3.3", features = ["cors"] }

[dev-dependencies]
bdk = { version = "0.22.0", features = ["rpc", "keys-bip39", "sqlite"] }
executable-path = "1.0.0"
hex = "0.4.3"
jsonrpc-core = "18.0.0"
jsonrpc-core-client = "18.0.0"
jsonrpc-derive = "18.0.0"
jsonrpc-http-server = "18.0.0"
log = "0.4.14"
nix = "0.24.1"
pretty_assertions = "1.2.1"
reqwest = { version = "0.11.10", features = ["blocking"] }
tempfile = "3.2.0"
test-bitcoincore-rpc = { path = "test-bitcoincore-rpc" }
unindent = "0.1.7"
bdk = { version = "0.22.0", features = ["rpc", "keys-bip39", "sqlite"] }

[[test]]
name = "integration"
Expand Down
16 changes: 8 additions & 8 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ mod tests {

#[test]
fn height_limit() {
let bitcoin_rpc_server = BitcoinRpcServer::spawn();
let bitcoin_rpc_server = test_bitcoincore_rpc::spawn();

bitcoin_rpc_server.mine_blocks(1);

Expand All @@ -561,13 +561,13 @@ mod tests {
format!(
"
ord
--rpc-url http://127.0.0.1:{}
--rpc-url {}
--data-dir {}
--cookie-file {}
--height-limit 0
--chain regtest
",
bitcoin_rpc_server.port,
bitcoin_rpc_server.url(),
tempdir.path().display(),
cookie_file.display(),
)
Expand All @@ -587,13 +587,13 @@ mod tests {
format!(
"
ord
--rpc-url http://127.0.0.1:{}
--rpc-url {}
--data-dir {}
--cookie-file {}
--height-limit 1
--chain regtest
",
bitcoin_rpc_server.port,
bitcoin_rpc_server.url(),
tempdir.path().display(),
cookie_file.display(),
)
Expand All @@ -611,7 +611,7 @@ mod tests {

#[test]
fn first_coinbase_transaction() {
let bitcoin_rpc_server = BitcoinRpcServer::spawn();
let bitcoin_rpc_server = test_bitcoincore_rpc::spawn();

bitcoin_rpc_server.mine_blocks(1);

Expand All @@ -625,13 +625,13 @@ mod tests {
format!(
"
ord
--rpc-url http://127.0.0.1:{}
--rpc-url {}
--data-dir {}
--cookie-file {}
--height-limit 0
--chain regtest
",
bitcoin_rpc_server.port,
bitcoin_rpc_server.url(),
tempdir.path().display(),
cookie_file.display(),
)
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ mod tests {
use {super::*, reqwest::Url, std::net::TcpListener, tempfile::TempDir};

struct TestServer {
bitcoin_rpc_server: BitcoinRpcServerHandle,
bitcoin_rpc_server: test_bitcoincore_rpc::Handle,
index: Arc<Index>,
ord_server_handle: Handle,
url: Url,
Expand All @@ -532,7 +532,7 @@ mod tests {

impl TestServer {
fn new() -> Self {
let bitcoin_rpc_server = BitcoinRpcServer::spawn();
let bitcoin_rpc_server = test_bitcoincore_rpc::spawn();

let tempdir = TempDir::new().unwrap();

Expand Down
Loading

0 comments on commit f28be8f

Please sign in to comment.