mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-05-02 14:56:10 -04:00
Merge pull request #54 from comit-network/bob-unhappy-paths
Punish Test
This commit is contained in:
commit
f88ed9183b
8 changed files with 882 additions and 683 deletions
|
@ -799,6 +799,9 @@ impl State4 {
|
|||
t1_timeout.await;
|
||||
Ok(())
|
||||
}
|
||||
pub fn tx_lock_id(&self) -> bitcoin::Txid {
|
||||
self.tx_lock.txid()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
|
|
|
@ -6,6 +6,7 @@ pub struct Config {
|
|||
pub bob_time_to_act: Duration,
|
||||
pub bitcoin_finality_confirmations: u32,
|
||||
pub bitcoin_avg_block_time: Duration,
|
||||
pub monero_max_finality_time: Duration,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
|
@ -14,6 +15,10 @@ impl Config {
|
|||
bob_time_to_act: *mainnet::BOB_TIME_TO_ACT,
|
||||
bitcoin_finality_confirmations: mainnet::BITCOIN_FINALITY_CONFIRMATIONS,
|
||||
bitcoin_avg_block_time: *mainnet::BITCOIN_AVG_BLOCK_TIME,
|
||||
// We apply a scaling factor (1.5) so that the swap is not aborted when the
|
||||
// blockchain is slow
|
||||
monero_max_finality_time: (*mainnet::MONERO_AVG_BLOCK_TIME).mul_f64(1.5)
|
||||
* mainnet::MONERO_FINALITY_CONFIRMATIONS,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +27,10 @@ impl Config {
|
|||
bob_time_to_act: *regtest::BOB_TIME_TO_ACT,
|
||||
bitcoin_finality_confirmations: regtest::BITCOIN_FINALITY_CONFIRMATIONS,
|
||||
bitcoin_avg_block_time: *regtest::BITCOIN_AVG_BLOCK_TIME,
|
||||
// We apply a scaling factor (1.5) so that the swap is not aborted when the
|
||||
// blockchain is slow
|
||||
monero_max_finality_time: (*regtest::MONERO_AVG_BLOCK_TIME).mul_f64(1.5)
|
||||
* regtest::MONERO_FINALITY_CONFIRMATIONS,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,15 +44,23 @@ mod mainnet {
|
|||
pub static BITCOIN_FINALITY_CONFIRMATIONS: u32 = 3;
|
||||
|
||||
pub static BITCOIN_AVG_BLOCK_TIME: Lazy<Duration> = Lazy::new(|| Duration::from_secs(10 * 60));
|
||||
|
||||
pub static MONERO_FINALITY_CONFIRMATIONS: u32 = 15;
|
||||
|
||||
pub static MONERO_AVG_BLOCK_TIME: Lazy<Duration> = Lazy::new(|| Duration::from_secs(2 * 60));
|
||||
}
|
||||
|
||||
mod regtest {
|
||||
use super::*;
|
||||
|
||||
// In test, set to 5 seconds to fail fast
|
||||
pub static BOB_TIME_TO_ACT: Lazy<Duration> = Lazy::new(|| Duration::from_secs(10));
|
||||
// In test, we set a shorter time to fail fast
|
||||
pub static BOB_TIME_TO_ACT: Lazy<Duration> = Lazy::new(|| Duration::from_secs(30));
|
||||
|
||||
pub static BITCOIN_FINALITY_CONFIRMATIONS: u32 = 1;
|
||||
|
||||
pub static BITCOIN_AVG_BLOCK_TIME: Lazy<Duration> = Lazy::new(|| Duration::from_secs(5));
|
||||
|
||||
pub static MONERO_FINALITY_CONFIRMATIONS: u32 = 1;
|
||||
|
||||
pub static MONERO_AVG_BLOCK_TIME: Lazy<Duration> = Lazy::new(|| Duration::from_secs(60));
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use anyhow::Result;
|
|||
use async_trait::async_trait;
|
||||
use rand::{CryptoRng, RngCore};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::ops::{Add, Sub};
|
||||
use std::ops::{Add, Mul, Sub};
|
||||
|
||||
pub use curve25519_dalek::scalar::Scalar;
|
||||
pub use monero::*;
|
||||
|
@ -97,6 +97,14 @@ impl Sub for Amount {
|
|||
}
|
||||
}
|
||||
|
||||
impl Mul<u64> for Amount {
|
||||
type Output = Amount;
|
||||
|
||||
fn mul(self, rhs: u64) -> Self::Output {
|
||||
Self(self.0 * rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Amount> for u64 {
|
||||
fn from(from: Amount) -> u64 {
|
||||
from.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue