Skip to content

Commit

Permalink
fix(watchtower): disable utxo/utxo watchers temporarily (#1897)
Browse files Browse the repository at this point in the history
This commit disables the utxo/utxo watchtower functionality temporarily due to #1887. It should be activated again once #1887 is resolved.
  • Loading branch information
caglaryucekaya authored Jul 6, 2023
1 parent f878c56 commit 19c8218
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
2 changes: 1 addition & 1 deletion mm2src/coins/utxo/bch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ impl SwapOps for BchCoin {
MmError::err(ValidateInstructionsErr::UnsupportedCoin(self.ticker().to_string()))
}

fn is_supported_by_watchers(&self) -> bool { true }
fn is_supported_by_watchers(&self) -> bool { std::env::var("USE_WATCHERS").is_ok() }
}

#[async_trait]
Expand Down
2 changes: 1 addition & 1 deletion mm2src/coins/utxo/qtum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ impl SwapOps for QtumCoin {
MmError::err(ValidateInstructionsErr::UnsupportedCoin(self.ticker().to_string()))
}

fn is_supported_by_watchers(&self) -> bool { true }
fn is_supported_by_watchers(&self) -> bool { std::env::var("USE_WATCHERS").is_ok() }
}

#[async_trait]
Expand Down
2 changes: 1 addition & 1 deletion mm2src/coins/utxo/utxo_standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ impl SwapOps for UtxoStandardCoin {
MmError::err(ValidateInstructionsErr::UnsupportedCoin(self.ticker().to_string()))
}

fn is_supported_by_watchers(&self) -> bool { true }
fn is_supported_by_watchers(&self) -> bool { std::env::var("USE_WATCHERS").is_ok() }
}

#[async_trait]
Expand Down
5 changes: 4 additions & 1 deletion mm2src/mm2_core/src/mm_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ impl MmCtx {

pub fn is_watcher(&self) -> bool { self.conf["is_watcher"].as_bool().unwrap_or_default() }

pub fn use_watchers(&self) -> bool { self.conf["use_watchers"].as_bool().unwrap_or(true) }
pub fn use_watchers(&self) -> bool {
std::env::var("USE_WATCHERS").is_ok()
//self.conf["use_watchers"].as_bool().unwrap_or(true)
}

pub fn netid(&self) -> u16 {
let netid = self.conf["netid"].as_u64().unwrap_or(0);
Expand Down
46 changes: 35 additions & 11 deletions mm2src/mm2_main/tests/docker_tests/swap_watcher_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ fn test_watcher_spends_maker_payment_utxo_utxo() {
25.,
25.,
2.,
&[],
&[("USE_WATCHERS", "")],
SwapFlow::WatcherSpendsMakerPayment,
&alice_privkey,
&bob_privkey,
Expand Down Expand Up @@ -306,7 +306,7 @@ fn test_watcher_spends_maker_payment_utxo_eth() {
0.01,
0.01,
1.,
&[("USE_WATCHER_REWARD", "")],
&[("USE_WATCHERS", ""), ("USE_WATCHER_REWARD", "")],
SwapFlow::WatcherSpendsMakerPayment,
alice_privkey,
bob_privkey,
Expand Down Expand Up @@ -339,7 +339,11 @@ fn test_watcher_spends_maker_payment_eth_utxo() {
100.,
100.,
0.01,
&[("TEST_COIN_PRICE", "0.01"), ("USE_WATCHER_REWARD", "")],
&[
("USE_WATCHERS", ""),
("TEST_COIN_PRICE", "0.01"),
("USE_WATCHER_REWARD", ""),
],
SwapFlow::WatcherSpendsMakerPayment,
alice_privkey,
bob_privkey,
Expand Down Expand Up @@ -385,7 +389,11 @@ fn test_watcher_spends_maker_payment_eth_erc20() {
100.,
100.,
0.01,
&[("TEST_COIN_PRICE", "0.01"), ("USE_WATCHER_REWARD", "")],
&[
("USE_WATCHERS", ""),
("TEST_COIN_PRICE", "0.01"),
("USE_WATCHER_REWARD", ""),
],
SwapFlow::WatcherSpendsMakerPayment,
alice_privkey,
bob_privkey,
Expand Down Expand Up @@ -418,7 +426,7 @@ fn test_watcher_spends_maker_payment_erc20_eth() {
0.01,
0.01,
1.,
&[("USE_WATCHER_REWARD", "")],
&[("USE_WATCHERS", ""), ("USE_WATCHER_REWARD", "")],
SwapFlow::WatcherSpendsMakerPayment,
alice_privkey,
bob_privkey,
Expand Down Expand Up @@ -451,7 +459,11 @@ fn test_watcher_spends_maker_payment_utxo_erc20() {
1.,
1.,
1.,
&[("TEST_COIN_PRICE", "0.01"), ("USE_WATCHER_REWARD", "")],
&[
("USE_WATCHERS", ""),
("TEST_COIN_PRICE", "0.01"),
("USE_WATCHER_REWARD", ""),
],
SwapFlow::WatcherSpendsMakerPayment,
alice_privkey,
bob_privkey,
Expand Down Expand Up @@ -484,7 +496,11 @@ fn test_watcher_spends_maker_payment_erc20_utxo() {
1.,
1.,
1.,
&[("TEST_COIN_PRICE", "0.01"), ("USE_WATCHER_REWARD", "")],
&[
("USE_WATCHERS", ""),
("TEST_COIN_PRICE", "0.01"),
("USE_WATCHER_REWARD", ""),
],
SwapFlow::WatcherSpendsMakerPayment,
alice_privkey,
bob_privkey,
Expand Down Expand Up @@ -536,7 +552,7 @@ fn test_watcher_refunds_taker_payment_utxo() {
25.,
25.,
2.,
&[("USE_TEST_LOCKTIME", "")],
&[("USE_WATCHERS", ""), ("USE_TEST_LOCKTIME", "")],
SwapFlow::WatcherRefundsTakerPayment,
alice_privkey,
bob_privkey,
Expand All @@ -562,7 +578,11 @@ fn test_watcher_refunds_taker_payment_eth() {
0.01,
0.01,
1.,
&[("USE_TEST_LOCKTIME", ""), ("USE_WATCHER_REWARD", "")],
&[
("USE_WATCHERS", ""),
("USE_TEST_LOCKTIME", ""),
("USE_WATCHER_REWARD", ""),
],
SwapFlow::WatcherRefundsTakerPayment,
alice_privkey,
bob_privkey,
Expand All @@ -589,6 +609,7 @@ fn test_watcher_refunds_taker_payment_erc20() {
100.,
0.01,
&[
("USE_WATCHERS", ""),
("USE_TEST_LOCKTIME", ""),
("TEST_COIN_PRICE", "0.01"),
("USE_WATCHER_REWARD", ""),
Expand Down Expand Up @@ -640,7 +661,11 @@ fn test_watcher_waits_for_taker_eth() {
100.,
100.,
0.01,
&[("TEST_COIN_PRICE", "0.01"), ("USE_WATCHER_REWARD", "")],
&[
("USE_WATCHERS", ""),
("TEST_COIN_PRICE", "0.01"),
("USE_WATCHER_REWARD", ""),
],
SwapFlow::TakerSpendsMakerPayment,
alice_privkey,
bob_privkey,
Expand All @@ -649,7 +674,6 @@ fn test_watcher_waits_for_taker_eth() {
}

#[test]
#[ignore]
fn test_two_watchers_spend_maker_payment_eth_erc20() {
let coins = json!([eth_testnet_conf(), eth_jst_testnet_conf()]);

Expand Down

0 comments on commit 19c8218

Please sign in to comment.