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:
Lucas Soriano del Pino 2020-10-23 23:05:34 +11:00
parent 964640154d
commit e84c56378c
6 changed files with 735 additions and 591 deletions

View file

@ -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;
}
}