mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-24 23:19:34 -05:00
Split monero-harness into harness and rpc
This allows us to move `monero-harness` and `bitcoin-harness` into `[dev-dependencies]` of `swap`.
This commit is contained in:
parent
2a3db9bd80
commit
03078f328c
46
Cargo.lock
generated
46
Cargo.lock
generated
@ -439,9 +439,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bstr"
|
name = "bstr"
|
||||||
version = "0.2.14"
|
version = "0.2.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf"
|
checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"memchr",
|
"memchr",
|
||||||
@ -801,19 +801,6 @@ dependencies = [
|
|||||||
"generic-array 0.14.4",
|
"generic-array 0.14.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "digest_auth"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d4bce617b8491dd210e3fcbc939e2c5bbeb27355f8adf7da335b87d6cc8d5482"
|
|
||||||
dependencies = [
|
|
||||||
"digest 0.8.1",
|
|
||||||
"hex 0.4.2",
|
|
||||||
"md-5",
|
|
||||||
"rand 0.7.3",
|
|
||||||
"sha2 0.8.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "directories-next"
|
name = "directories-next"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
@ -1876,17 +1863,6 @@ version = "0.1.8"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
|
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "md-5"
|
|
||||||
version = "0.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a18af3dcaf2b0219366cdb4e2af65a6101457b415c3d1a5c71dd9c2b7c77b9c8"
|
|
||||||
dependencies = [
|
|
||||||
"block-buffer 0.7.3",
|
|
||||||
"digest 0.8.1",
|
|
||||||
"opaque-debug 0.2.3",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.3.4"
|
version = "2.3.4"
|
||||||
@ -1983,20 +1959,27 @@ name = "monero-harness"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"digest_auth",
|
|
||||||
"futures",
|
"futures",
|
||||||
|
"monero-rpc",
|
||||||
"port_check",
|
"port_check",
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"reqwest",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"spectral",
|
"spectral",
|
||||||
"testcontainers 0.12.0",
|
"testcontainers 0.12.0",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"url",
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "monero-rpc"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"reqwest",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3488,6 +3471,7 @@ dependencies = [
|
|||||||
"miniscript",
|
"miniscript",
|
||||||
"monero",
|
"monero",
|
||||||
"monero-harness",
|
"monero-harness",
|
||||||
|
"monero-rpc",
|
||||||
"pem",
|
"pem",
|
||||||
"port_check",
|
"port_check",
|
||||||
"prettytable-rs",
|
"prettytable-rs",
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["monero-harness", "swap"]
|
members = ["monero-harness", "monero-rpc", "swap"]
|
||||||
|
@ -6,17 +6,13 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
digest_auth = "0.2.3"
|
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
monero-rpc = { path = "../monero-rpc" }
|
||||||
port_check = "0.1"
|
port_check = "0.1"
|
||||||
rand = "0.7"
|
rand = "0.7"
|
||||||
reqwest = { version = "0.11", default-features = false, features = ["json", "native-tls"] }
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
|
||||||
serde_json = "1.0"
|
|
||||||
spectral = "0.6"
|
spectral = "0.6"
|
||||||
testcontainers = "0.12"
|
testcontainers = "0.12"
|
||||||
tokio = { version = "1.0", default-features = false, features = ["rt-multi-thread", "time", "macros"] }
|
tokio = { version = "1.0", default-features = false, features = ["rt-multi-thread", "time", "macros"] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-log = "0.1"
|
tracing-log = "0.1"
|
||||||
tracing-subscriber = { version = "0.2", default-features = false, features = ["fmt", "ansi", "env-filter"] }
|
tracing-subscriber = { version = "0.2", default-features = false, features = ["fmt", "ansi", "env-filter"] }
|
||||||
url = "2"
|
|
||||||
|
@ -21,18 +21,15 @@
|
|||||||
//!
|
//!
|
||||||
//! Also provides standalone JSON RPC clients for monerod and monero-wallet-rpc.
|
//! Also provides standalone JSON RPC clients for monerod and monero-wallet-rpc.
|
||||||
pub mod image;
|
pub mod image;
|
||||||
pub mod rpc;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::image::{
|
||||||
image::{
|
|
||||||
MONEROD_DAEMON_CONTAINER_NAME, MONEROD_DEFAULT_NETWORK, MONEROD_RPC_PORT, WALLET_RPC_PORT,
|
MONEROD_DAEMON_CONTAINER_NAME, MONEROD_DEFAULT_NETWORK, MONEROD_RPC_PORT, WALLET_RPC_PORT,
|
||||||
},
|
|
||||||
rpc::{
|
|
||||||
monerod,
|
|
||||||
wallet::{self, GetAddress, Refreshed, Transfer},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, bail, Result};
|
use anyhow::{anyhow, bail, Result};
|
||||||
|
use monero_rpc::{
|
||||||
|
monerod,
|
||||||
|
wallet::{self, GetAddress, Refreshed, Transfer},
|
||||||
|
};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use testcontainers::{clients::Cli, core::Port, Container, Docker, RunArgs};
|
use testcontainers::{clients::Cli, core::Port, Container, Docker, RunArgs};
|
||||||
use tokio::time;
|
use tokio::time;
|
||||||
|
12
monero-rpc/Cargo.toml
Normal file
12
monero-rpc/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "monero-rpc"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["CoBloX Team <team@coblox.tech>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1"
|
||||||
|
reqwest = { version = "0.11", default-features = false, features = ["json", "native-tls"] }
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde_json = "1.0"
|
||||||
|
tracing = "0.1"
|
12
monero-rpc/README.md
Normal file
12
monero-rpc/README.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
Monero Harness
|
||||||
|
==============
|
||||||
|
|
||||||
|
Provides an implementation of `testcontainers::Image` for a monero image to run
|
||||||
|
`monerod` and `monero-wallet-rpc` in a docker container.
|
||||||
|
|
||||||
|
Also provides two standalone JSON RPC clients, one each for `monerod` and `monero-wallet-rpc`.
|
||||||
|
|
||||||
|
Example Usage
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Please see `tests/*` for example usage.
|
1
monero-rpc/rust-toolchain
Normal file
1
monero-rpc/rust-toolchain
Normal file
@ -0,0 +1 @@
|
|||||||
|
1.46.0
|
9
monero-rpc/rustfmt.toml
Normal file
9
monero-rpc/rustfmt.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
edition = "2018"
|
||||||
|
condense_wildcard_suffixes = true
|
||||||
|
format_macro_matchers = true
|
||||||
|
imports_granularity = "Crate"
|
||||||
|
use_field_init_shorthand = true
|
||||||
|
format_code_in_doc_comments = true
|
||||||
|
normalize_comments = true
|
||||||
|
wrap_comments = true
|
||||||
|
overflow_delimited_expr = true
|
17
monero-rpc/src/lib.rs
Normal file
17
monero-rpc/src/lib.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#![warn(
|
||||||
|
unused_extern_crates,
|
||||||
|
missing_debug_implementations,
|
||||||
|
missing_copy_implementations,
|
||||||
|
rust_2018_idioms,
|
||||||
|
clippy::cast_possible_truncation,
|
||||||
|
clippy::cast_sign_loss,
|
||||||
|
clippy::fallible_impl_from,
|
||||||
|
clippy::cast_precision_loss,
|
||||||
|
clippy::cast_possible_wrap,
|
||||||
|
clippy::dbg_macro
|
||||||
|
)]
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
|
mod rpc;
|
||||||
|
|
||||||
|
pub use self::rpc::*;
|
@ -39,7 +39,6 @@ struct Response<T> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use spectral::prelude::*;
|
|
||||||
|
|
||||||
#[derive(Serialize, Debug, Clone)]
|
#[derive(Serialize, Debug, Clone)]
|
||||||
struct Params {
|
struct Params {
|
||||||
@ -58,6 +57,7 @@ mod tests {
|
|||||||
let want =
|
let want =
|
||||||
"{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"get_block\",\"params\":{\"val\":0}}"
|
"{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"get_block\",\"params\":{\"val\":0}}"
|
||||||
.to_string();
|
.to_string();
|
||||||
assert_that!(got).is_equal_to(want);
|
|
||||||
|
assert_eq!(got, want);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
use crate::rpc::{Request, Response};
|
use crate::rpc::{Request, Response};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
@ -20,7 +20,6 @@ backoff = { version = "0.3", features = ["tokio"] }
|
|||||||
base64 = "0.12"
|
base64 = "0.12"
|
||||||
bdk = { version = "0.4" }
|
bdk = { version = "0.4" }
|
||||||
bitcoin = { version = "0.26", features = ["rand", "use-serde"] }
|
bitcoin = { version = "0.26", features = ["rand", "use-serde"] }
|
||||||
bitcoin-harness = { git = "https://github.com/coblox/bitcoin-harness-rs" }
|
|
||||||
config = { version = "0.10", default-features = false, features = ["toml"] }
|
config = { version = "0.10", default-features = false, features = ["toml"] }
|
||||||
conquer-once = "0.3"
|
conquer-once = "0.3"
|
||||||
curve25519-dalek = "3"
|
curve25519-dalek = "3"
|
||||||
@ -33,7 +32,7 @@ libp2p-async-await = { git = "https://github.com/comit-network/rust-libp2p-async
|
|||||||
log = { version = "0.4", features = ["serde"] }
|
log = { version = "0.4", features = ["serde"] }
|
||||||
miniscript = { version = "5", features = ["serde"] }
|
miniscript = { version = "5", features = ["serde"] }
|
||||||
monero = { version = "0.10", features = ["serde_support"] }
|
monero = { version = "0.10", features = ["serde_support"] }
|
||||||
monero-harness = { path = "../monero-harness" }
|
monero-rpc = { path = "../monero-rpc" }
|
||||||
pem = "0.8"
|
pem = "0.8"
|
||||||
prettytable-rs = "0.8"
|
prettytable-rs = "0.8"
|
||||||
rand = "0.7"
|
rand = "0.7"
|
||||||
@ -62,8 +61,10 @@ uuid = { version = "0.8", features = ["serde", "v4"] }
|
|||||||
void = "1"
|
void = "1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
bitcoin-harness = { git = "https://github.com/coblox/bitcoin-harness-rs" }
|
||||||
get-port = "3"
|
get-port = "3"
|
||||||
hyper = "0.14"
|
hyper = "0.14"
|
||||||
|
monero-harness = { path = "../monero-harness" }
|
||||||
port_check = "0.1"
|
port_check = "0.1"
|
||||||
serde_cbor = "0.11"
|
serde_cbor = "0.11"
|
||||||
spectral = "0.6"
|
spectral = "0.6"
|
||||||
|
@ -3,7 +3,7 @@ use crate::{
|
|||||||
protocol::{bob, bob::BobState},
|
protocol::{bob, bob::BobState},
|
||||||
};
|
};
|
||||||
use ::bitcoin::hashes::core::fmt::Display;
|
use ::bitcoin::hashes::core::fmt::Display;
|
||||||
use monero_harness::rpc::wallet::BlockHeight;
|
use monero_rpc::wallet::BlockHeight;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||||
|
@ -7,7 +7,7 @@ use anyhow::Result;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use backoff::{backoff::Constant as ConstantBackoff, future::retry};
|
use backoff::{backoff::Constant as ConstantBackoff, future::retry};
|
||||||
use bitcoin::hashes::core::sync::atomic::AtomicU32;
|
use bitcoin::hashes::core::sync::atomic::AtomicU32;
|
||||||
use monero_harness::rpc::wallet;
|
use monero_rpc::wallet;
|
||||||
use std::{
|
use std::{
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
sync::{atomic::Ordering, Arc},
|
sync::{atomic::Ordering, Arc},
|
||||||
|
@ -21,7 +21,7 @@ use ecdsa_fun::{
|
|||||||
nonce::Deterministic,
|
nonce::Deterministic,
|
||||||
Signature,
|
Signature,
|
||||||
};
|
};
|
||||||
use monero_harness::rpc::wallet::BlockHeight;
|
use monero_rpc::wallet::BlockHeight;
|
||||||
use rand::{CryptoRng, RngCore};
|
use rand::{CryptoRng, RngCore};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
|
Loading…
Reference in New Issue
Block a user