mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-15 16:48:58 -05:00
wip: Provide enough funds to both parties
Also use cosntant backoff retry strategy as opposed to exponential backoff. This is in case retrying several times quickly causes the retry intervals to become large enough that the test is very slow and/or the Bitcoin lock transaction expires. The current problem occurs on the last message i.e. Bob sending tx_redeem_encsig to Alice. The action is yielded for Bob to do it, but Alice appears to never receive it (unconfirmed claim, requires more logging).
This commit is contained in:
parent
eb6bbe6180
commit
a37f43a1ba
7 changed files with 55 additions and 37 deletions
|
|
@ -24,10 +24,12 @@ async fn swap() {
|
|||
let bitcoind = Bitcoind::new(&cli, "0.19.1").unwrap();
|
||||
let _ = bitcoind.init(5).await;
|
||||
|
||||
let btc = bitcoin::Amount::ONE_BTC;
|
||||
let _btc_alice = bitcoin::Amount::ZERO;
|
||||
let btc = bitcoin::Amount::from_sat(1_000_000);
|
||||
let btc_alice = bitcoin::Amount::ZERO;
|
||||
let btc_bob = btc * 10;
|
||||
|
||||
// this xmr value matches the logic of alice::calculate_amounts i.e. btc *
|
||||
// 10_000 * 100
|
||||
let xmr = 1_000_000_000_000;
|
||||
let xmr_alice = xmr * 10;
|
||||
let xmr_bob = 0;
|
||||
|
|
@ -54,8 +56,8 @@ async fn swap() {
|
|||
let bob_xmr_wallet = Arc::new(swap::monero::Wallet(monero.bob_wallet_rpc_client()));
|
||||
|
||||
let alice_swap = alice::swap(
|
||||
alice_btc_wallet,
|
||||
alice_xmr_wallet,
|
||||
alice_btc_wallet.clone(),
|
||||
alice_xmr_wallet.clone(),
|
||||
alice_multiaddr.clone(),
|
||||
None,
|
||||
);
|
||||
|
|
@ -63,15 +65,33 @@ async fn swap() {
|
|||
let (cmd_tx, mut _cmd_rx) = mpsc::channel(1);
|
||||
let (mut rsp_tx, rsp_rx) = mpsc::channel(1);
|
||||
let bob_swap = bob::swap(
|
||||
bob_btc_wallet,
|
||||
bob_xmr_wallet,
|
||||
bob_btc_wallet.clone(),
|
||||
bob_xmr_wallet.clone(),
|
||||
btc.as_sat(),
|
||||
alice_multiaddr,
|
||||
cmd_tx,
|
||||
rsp_rx,
|
||||
);
|
||||
|
||||
// automate the verification step by accepting any amounts sent over by Alice
|
||||
rsp_tx.try_send(swap::Rsp::VerifiedAmounts).unwrap();
|
||||
|
||||
try_join(alice_swap, bob_swap).await.unwrap();
|
||||
|
||||
let btc_alice_final = alice_btc_wallet.as_ref().balance().await.unwrap();
|
||||
let btc_bob_final = bob_btc_wallet.as_ref().balance().await.unwrap();
|
||||
|
||||
let xmr_alice_final = alice_xmr_wallet.as_ref().get_balance().await.unwrap();
|
||||
|
||||
monero.wait_for_bob_wallet_block_height().await.unwrap();
|
||||
let xmr_bob_final = bob_xmr_wallet.as_ref().get_balance().await.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
btc_alice_final,
|
||||
btc_alice + btc - bitcoin::Amount::from_sat(xmr_btc::bitcoin::TX_FEE)
|
||||
);
|
||||
assert!(btc_bob_final <= btc_bob - btc);
|
||||
|
||||
assert!(xmr_alice_final.as_piconero() <= xmr_alice - xmr);
|
||||
assert_eq!(xmr_bob_final.as_piconero(), xmr_bob + xmr);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue