Update xmr-btc lib to use new monero-harness

This commit is contained in:
Philipp Hoenisch 2020-11-02 21:12:38 +11:00
parent 2d064f305f
commit 0b9e8c145e
No known key found for this signature in database
GPG key ID: E5F8E74C672BC666
7 changed files with 113 additions and 46 deletions

View file

@ -28,12 +28,12 @@ tracing = "0.1"
[dev-dependencies]
backoff = { version = "0.2", features = ["tokio"] }
base64 = "0.12"
bitcoin-harness = { git = "https://github.com/coblox/bitcoin-harness-rs", rev = "f1bbe6a4540d0741f1f4f22577cfeeadbfd7aaaf" }
bitcoin-harness = { git = "https://github.com/coblox/bitcoin-harness-rs", rev = "3be644cd9512c157d3337a189298b8257ed54d04" }
futures = "0.3"
monero-harness = { path = "../monero-harness" }
reqwest = { version = "0.10", default-features = false }
serde_cbor = "0.11"
tempfile = "3"
testcontainers = "0.10"
testcontainers = "0.11"
tracing = "0.1"
tracing-subscriber = "0.2"

View file

@ -32,7 +32,13 @@ mod tests {
.set_default();
let cli = Cli::default();
let (monero, _container) = Monero::new(&cli).unwrap();
let (monero, _container) =
Monero::new(&cli, Some("hp".to_string()), Some("hp".to_string()), vec![
"alice".to_string(),
"bob".to_string(),
])
.await
.unwrap();
let bitcoind = init_bitcoind(&cli).await;
let (
@ -75,7 +81,7 @@ mod tests {
let alice_final_xmr_balance = alice_node.monero_wallet.get_balance().await.unwrap();
monero.wait_for_bob_wallet_block_height().await.unwrap();
monero.wallet("bob").unwrap().refresh().await.unwrap();
let bob_final_xmr_balance = bob_node.monero_wallet.get_balance().await.unwrap();
@ -106,7 +112,13 @@ mod tests {
.set_default();
let cli = Cli::default();
let (monero, _container) = Monero::new(&cli).unwrap();
let (monero, _container) =
Monero::new(&cli, Some("br".to_string()), Some("br".to_string()), vec![
"alice".to_string(),
"bob".to_string(),
])
.await
.unwrap();
let bitcoind = init_bitcoind(&cli).await;
let (
@ -158,7 +170,7 @@ mod tests {
.await
.unwrap();
monero.wait_for_alice_wallet_block_height().await.unwrap();
monero.wallet("alice").unwrap().refresh().await.unwrap();
let alice_final_xmr_balance = alice_node.monero_wallet.get_balance().await.unwrap();
let bob_final_xmr_balance = bob_node.monero_wallet.get_balance().await.unwrap();
@ -182,7 +194,14 @@ mod tests {
.set_default();
let cli = Cli::default();
let (monero, _container) = Monero::new(&cli).unwrap();
let (monero, _containers) =
Monero::new(&cli, Some("ap".to_string()), Some("ap".to_string()), vec![
"alice".to_string(),
"bob".to_string(),
])
.await
.unwrap();
let bitcoind = init_bitcoind(&cli).await;
let (

View file

@ -132,8 +132,8 @@ pub async fn init_test(
let fund_bob = 0;
monero.init(fund_alice, fund_bob).await.unwrap();
let alice_monero_wallet = wallet::monero::Wallet(monero.alice_wallet_rpc_client());
let bob_monero_wallet = wallet::monero::Wallet(monero.bob_wallet_rpc_client());
let alice_monero_wallet = wallet::monero::Wallet(monero.wallet("alice").unwrap().inner());
let bob_monero_wallet = wallet::monero::Wallet(monero.wallet("bob").unwrap().inner());
let alice_btc_wallet = wallet::bitcoin::Wallet::new("alice", &bitcoind.node_url)
.await

View file

@ -238,7 +238,14 @@ async fn swap_as_bob(
#[tokio::test]
async fn on_chain_happy_path() {
let cli = Cli::default();
let (monero, _container) = Monero::new(&cli).unwrap();
let (monero, _container) = Monero::new(
&cli,
Some("ochp".to_string()),
Some("ochp".to_string()),
vec!["alice".to_string(), "bob".to_string()],
)
.await
.unwrap();
let bitcoind = init_bitcoind(&cli).await;
let (alice_state0, bob_state0, mut alice_node, mut bob_node, initial_balances, swap_amounts) =
@ -304,7 +311,7 @@ async fn on_chain_happy_path() {
let alice_final_xmr_balance = alice_monero_wallet.get_balance().await.unwrap();
monero.wait_for_bob_wallet_block_height().await.unwrap();
monero.wallet("bob").unwrap().refresh().await.unwrap();
let bob_final_xmr_balance = bob_monero_wallet.get_balance().await.unwrap();
assert_eq!(
@ -329,7 +336,14 @@ async fn on_chain_happy_path() {
#[tokio::test]
async fn on_chain_both_refund_if_alice_never_redeems() {
let cli = Cli::default();
let (monero, _container) = Monero::new(&cli).unwrap();
let (monero, _container) = Monero::new(
&cli,
Some("ocbr".to_string()),
Some("ocbr".to_string()),
vec!["alice".to_string(), "bob".to_string()],
)
.await
.unwrap();
let bitcoind = init_bitcoind(&cli).await;
let (alice_state0, bob_state0, mut alice_node, mut bob_node, initial_balances, swap_amounts) =
@ -396,7 +410,7 @@ async fn on_chain_both_refund_if_alice_never_redeems() {
.await
.unwrap();
monero.wait_for_alice_wallet_block_height().await.unwrap();
monero.wallet("alice").unwrap().refresh().await.unwrap();
let alice_final_xmr_balance = alice_monero_wallet.get_balance().await.unwrap();
let bob_final_xmr_balance = bob_monero_wallet.get_balance().await.unwrap();
@ -419,7 +433,14 @@ async fn on_chain_both_refund_if_alice_never_redeems() {
#[tokio::test]
async fn on_chain_alice_punishes_if_bob_never_acts_after_fund() {
let cli = Cli::default();
let (monero, _container) = Monero::new(&cli).unwrap();
let (monero, _container) = Monero::new(
&cli,
Some("ocap".to_string()),
Some("ocap".to_string()),
vec!["alice".to_string(), "bob".to_string()],
)
.await
.unwrap();
let bitcoind = init_bitcoind(&cli).await;
let (alice_state0, bob_state0, mut alice_node, mut bob_node, initial_balances, swap_amounts) =