mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-08 14:32:24 -04:00
Test that both parties refund if Alice does not redeem
Also: - Move generator functions to `alice` and `bob` modules. This makes using `tracing` a lot easier, since the context of the file name let's us differentiate between Alice's and Bob's generator logs more clearly. - Accept 0 confirmations when watching for the Monero lock transaction. This should eventually be configured by the application, but in the tests it's making things unexpectedly slower.
This commit is contained in:
parent
964640154d
commit
e84c56378c
6 changed files with 735 additions and 591 deletions
|
@ -190,6 +190,16 @@ pub trait WatchForRawTransaction {
|
|||
async fn watch_for_raw_transaction(&self, txid: Txid) -> Transaction;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait BlockHeight {
|
||||
async fn block_height(&self) -> u32;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait TransactionBlockHeight {
|
||||
async fn transaction_block_height(&self, txid: Txid) -> u32;
|
||||
}
|
||||
|
||||
pub fn recover(S: PublicKey, sig: Signature, encsig: EncryptedSignature) -> Result<SecretKey> {
|
||||
let adaptor = Adaptor::<Sha256, Deterministic<Sha256>>::default();
|
||||
|
||||
|
@ -200,3 +210,16 @@ pub fn recover(S: PublicKey, sig: Signature, encsig: EncryptedSignature) -> Resu
|
|||
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
pub async fn poll_until_block_height_is_gte<B>(client: &B, target: u32)
|
||||
where
|
||||
B: BlockHeight,
|
||||
{
|
||||
loop {
|
||||
if client.block_height().await >= target {
|
||||
return;
|
||||
}
|
||||
|
||||
tokio::time::delay_for(std::time::Duration::from_secs(1)).await;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue